Version 8 (modified by 5年 ago) (diff) | ,
---|
Ticket 问题描述模板定义规则
按照下面的格式定义:
- 使用== 开头定义模板名字,这个名字会显示在模板选择列表里
- 使用{{{、}}}将模板内容包含起来,模板内容可以是任意符合wiki语法的文本
== 模板名字 {{{ 模板内容 }}}
补丁申请模板(html)
<!-- html template --> <style type="text/css"> tr.panel-row textarea { height: 85px; padding-right: 0.4em; } .required-field-label { color: red; } input.date-picker { width: 100px; } #propertyform table.trac-properties { table-layout: unset; } #properties table.trac-properties > tbody > tr > th.col2 { border-left: 0px; } #properties table.trac-properties > tbody > tr > td.col1 { width: 28.2%; } #properties table.trac-properties > tbody > tr > td.col2 { width: 15%; } #propertyform table select { width: 99%; } #content.ticket { width: 68em; } #properties table.trac-properties > tbody > tr > th, #properties table.trac-properties > colgroup > col.th { width: 12%; } #propertyform table.trac-properties td input[type="text"], #propertyform table.trac-properties td textarea { width: 99%; } #properties table.trac-properties > tbody > tr > td, #properties table.trac-properties > colgroup > col.td { width: 0%; } </style> <script type="text/javascript"> function clearDescriptionCookie() { $.cookie("description_panel", ""); } function getDescriptionCookie() { return $.cookie("description_panel"); } function setDescriptionCookie(value) { $.cookie("description_panel", value); } function createDescriptionPanel() { let template = $("#panel tbody").html(); $("#panel").remove(); let description_row = $("label#field-description-help").parent().parent(); description_row.css("display", "none"); description_row.before(template); $("#field-summary").parent().attr("colspan", "5"); $("#field-reporter").parent().attr("colspan", "5"); $("#properties table th").css("vertical-align", "super"); let required_fields = [ 'field-summary', 'field-reporter', 'field-type', 'field-component', 'field-priority', 'field-severity', 'field-version', 'field-chip' ]; for (let i = 0; i < required_fields.length; i++) { let element = $(`label[for='${required_fields[i]}']`); if (element.length != 0) { let text = element.html().replace(':', ''); element.html(`${text} <span class="required-field-label">*</span>:`); } $(`#${required_fields[i]}`).attr("class", "required-field"); } $(".date-picker").datepicker({ changeMonth: true, changeYear: true, onClose: function(date_text, picker) { let warning_tip = $(this).parent().find("span.empty-warning"); if (warning_tip.length != 0) warning_tip.remove(); } }); $(".date-picker").datepicker("option", "dateFormat", "yy-mm-dd"); if (window.location.href.split(window.location.host)[1] != $("#propertyform").attr("action")) { clearDescriptionCookie(); } $("#developer-resolve-date").val("[=#developer-resolve-date]"); $(".required-field").blur(function(event) { let warning_tip = $(event.target).parent().find("span.empty-warning"); if ($(event.target).val() == "") { if (warning_tip.length == 0) $(event.target).parent().append('<span class="required-field-label empty-warning">内容不能为空</span>'); } else { if (warning_tip.length != 0) warning_tip.remove(); } }); let description_panel = getDescriptionCookie(); if (description_panel != undefined && description_panel != "") { let panel_info = JSON.parse(description_panel); $(".panel-row label").each(function(index, element) { let text_element = $(element).parent().next("td").find("input:text")[0]; if (text_element == undefined) { text_element = $(element).parent().next("td").find("textarea")[0]; } if ($(text_element).attr("class") != undefined && $(text_element).attr("class").match(/date-picker/) != null) $(text_element).datepicker("setDate", panel_info[index]); else $(text_element).val(panel_info[index]); }); } function updateDescriptionForServer(event) { let found_empty_field = false; let required_elements = $(".required-field"); for (let i = 0; i < required_elements.length; i++) { if ($(required_elements.get(i)).val() == "") { found_empty_field = true; break; } } if (found_empty_field) { event.preventDefault(); alert('有必填项为空,请补充。带 * 的为必填项。'); } let data = populateDescription(); if (data != null) { setDescriptionCookie(data.panel_info); $("#field-description").val(data.description); } } $("input:submit[name='preview']").click(function(event) { updateDescriptionForServer(event); }); $("input:submit[name='submit']").click(function(event) { updateDescriptionForServer(event); }); } function populateDescription() { let boundary = "|------"; let panel_info = []; let description = ""; let exchange_tags = [] $(".panel-row").each(function(index, element) { let labels = $(element).find("th label"); let row_data = []; let title = $(element).attr("title"); description += "== " + title + "\n"; if (labels.length == 1) { let value = $(element).find("td").children("input:text").val(); if (value == undefined) { value = $(element).find("td").children("textarea").val(); } if (title == "出错日志") description += "{{{\n" + value + "\n}}}\n"; else description += value + "\n"; panel_info.push(value); } else { let values = $(element).find("td input:text"); for (let i = 0; i < labels.length; i++) { let label_name = $(labels.get(i)).text(); label_name = label_name.replace(/\s*\*/, ''); let input_val = $(values.get(i)).val(); let label_class = $(labels.get(i)).attr("class"); let tag = null; if (label_class != undefined) { let matched = label_class.match(/exchange-\d+/); if (matched != null) { tag = matched[0]; exchange_tags.push(tag); } } if (tag != null) description += `- <${tag}>${label_name}${input_val}</${tag}>\n`; else description += `- ${label_name}${input_val}\n`; panel_info.push(input_val); } } description += boundary + "\n"; }); for (let i = 0; i < exchange_tags.length; i++) { let tag = exchange_tags[i]; let tag_pattern = new RegExp(`<${tag}>.*</${tag}>`, 'g'); let content_pattern = new RegExp(`<${tag}>(.*)</${tag}>`); let matched = description.match(tag_pattern); if (matched != null) { description = description.replace(matched[0], matched[1].match(content_pattern)[1]); description = description.replace(matched[1], matched[0].match(content_pattern)[1]); } } return {panel_info: JSON.stringify(panel_info), description: description}; } </script> <table id="panel"> <tbody> <tr title="问题描述" class="panel-row"> <th><label>问题描述 <span class="required-field-label">*</span>:</label></th> <td colspan="5"><textarea class="required-field"></textarea></td> </tr> <tr title="问题场景" class="panel-row"> <th><label>问题场景 <span class="required-field-label">*</span>:</label></th> <td colspan="5"><textarea class="required-field"></textarea></td> </tr> <tr title="复现步骤" class="panel-row"> <th><label>复现步骤 <span class="required-field-label">*</span>:</label></th> <td colspan="5"><textarea class="required-field"></textarea></td> </tr> <tr title="出错日志" class="panel-row"> <th><label>出错日志:</label></th> <td colspan="5"><textarea></textarea></td> </tr> <tr title="初步定位" class="panel-row"> <th><label>初步定位:</label></th> <td colspan="5"><textarea></textarea></td> </tr> <tr title="问题处理时间段" class="panel-row"> <th><label>发现日期 <span class="required-field-label">*</span>:</label></th> <td><input type="text" id="issue-occur-date" class="date-picker required-field"></td> <th><label class="exchange-1">沟通联系人 <span class="required-field-label">*</span>:</label></th> <td><input type="text" class="required-field"></td> <th style="display: none"><label>开发人员预期解决日期:</label></th> <td style="display: none"><input type="text" id="developer-resolve-date"></td> </tr> <tr title="联系人信息" class="panel-row"> <th><label class="exchange-1">期望解决日期 <span class="required-field-label">*</span>:</label></th> <td><input type="text" id="issue-resolve-date" class="date-picker required-field"></td> <th><label>电话 <span class="required-field-label">*</span>:</label></th> <td><input type="text" class="required-field"></td> <th style="width: 28px"><label>邮箱:</label></th> <td><input type="text" style="width: 96%;"></td> </tr> </tbody> </table>
附件 (1)
- toolbar.png (1.0 KB) - added by 5年 ago.
Download all attachments as: .zip