sync
This commit is contained in:
@ -5,6 +5,7 @@ define(['modules/sections/section', 'modules/sections/addsection', 'common', 'mo
|
||||
this.namecontrol = undefined;
|
||||
this.displaytextcontrol = undefined;
|
||||
this.notescontrol = undefined;
|
||||
this.displayonreportcontrol = undefined;
|
||||
this.onNameChanged = undefined;
|
||||
this.datacontent = null;
|
||||
|
||||
@ -28,18 +29,19 @@ define(['modules/sections/section', 'modules/sections/addsection', 'common', 'mo
|
||||
tb.append(tr);
|
||||
tr.append('<td class="label" style="width:154px;">' + GetTextByKey("P_IPT_NAME_COLON", "Name:") + '<span class="redasterisk">*</span></td>');
|
||||
_this.namecontrol = $('<input type="text" class="form-control" maxlength="100" autocomplete="off"/>');
|
||||
var addiText = $('<span class="spanbtn iconmultitext" style="font-size:14px;" title="' + GetTextByKey("P_IPT_XXX", "Language Selection") + '"/>');
|
||||
var addiText = $('<span class="spanbtn iconmultitext" style="font-size:14px;" title="' + GetTextByKey("P_IPT_LANGUAGESELECTION", "Language Selection") + '"/>');
|
||||
addiText.click(function () {
|
||||
Common.createMultiTextDialog(_this.namecontrol);
|
||||
});
|
||||
tr.append($('<td style="white-space:nowrap;"></td>').append(_this.namecontrol).append(addiText));
|
||||
tr.append($('<td style="white-space:nowrap;width:370px;"></td>').append(_this.namecontrol).append(addiText));
|
||||
_this.namecontrol.change(function () {
|
||||
if (_this.onNameChanged)
|
||||
_this.onNameChanged($.trim(_this.namecontrol.val()))
|
||||
})
|
||||
|
||||
tr.append($('<td></td>'));
|
||||
tb.append(tr);
|
||||
tr.append('<td class="label" style="width:154px;">' + GetTextByKey("P_IPT_NOTES_COLON", "Notes:") + '</td>');
|
||||
|
||||
tr.append('<td class="label" style="width:100px;">' + GetTextByKey("P_IPT_NOTES_COLON", "Notes:") + '</td>');
|
||||
_this.notescontrol = $('<textarea id="dialog_notes" class="form-control" maxlength="500" autocomplete="off" style="width: 540px; margin-top:6px;height:55px;"></textarea>');
|
||||
tr.append($('<td rowspan="2"></td>').append(_this.notescontrol));
|
||||
|
||||
@ -47,19 +49,27 @@ define(['modules/sections/section', 'modules/sections/addsection', 'common', 'mo
|
||||
tb.append(tr);
|
||||
tr.append('<td class="label" style="width:154px;">' + GetTextByKey("P_IPT_DISPLAYTEXT_COLON", "Display Text:") + '<span class="redasterisk">*</span></td>');
|
||||
_this.displaytextcontrol = $('<input type="text" class="form-control" maxlength="200" autocomplete="off"/>');
|
||||
addiText = $('<span class="spanbtn iconmultitext" style="font-size:14px;" title="' + GetTextByKey("P_IPT_XXX", "Language Selection") + '"/>');
|
||||
addiText = $('<span class="spanbtn iconmultitext" style="font-size:14px;" title="' + GetTextByKey("P_IPT_LANGUAGESELECTION", "Language Selection") + '"/>');
|
||||
addiText.click(function () {
|
||||
Common.createMultiTextDialog(_this.displaytextcontrol);
|
||||
});
|
||||
tr.append($('<td style="white-space:nowrap;"></td>').append(_this.displaytextcontrol).append(addiText));
|
||||
|
||||
var td_displayonreport = $('<td></td>')
|
||||
.attr('title', GetTextByKey("P_IPT_PAGEDISPLAYONREPORTTIPS", 'Checked indicates that there will be a \n Page Break and Page Title on the report.\n\n Unchecked indicates that the Page Break \n is only visible during inspection completion.'));
|
||||
|
||||
tr.append(td_displayonreport);
|
||||
_this.displayonreportcontrol = $('<input id="tempchk1" type="checkbox"/>');
|
||||
td_displayonreport.append(_this.displayonreportcontrol);
|
||||
td_displayonreport.append("<label for='tempchk1' data-lgid='P_IPT_DISPLAYONREPORT'>Display on Report</label>");
|
||||
|
||||
var sectioncontent = createSectionContent();
|
||||
div_main.append(sectioncontent);
|
||||
return div_main;
|
||||
}
|
||||
|
||||
function createSectionContent() {
|
||||
var content = $('<div style="min-width:1820px;"></div>');
|
||||
var content = $('<div style="min-width:1780px;"></div>');
|
||||
|
||||
function createSectionHeader() {
|
||||
var header = $('<div></div>');
|
||||
@ -72,7 +82,7 @@ define(['modules/sections/section', 'modules/sections/addsection', 'common', 'mo
|
||||
// updateContent(true);
|
||||
//}
|
||||
//$('#right_popup1').empty().append(s.createContent()).show();
|
||||
var section = {};
|
||||
var section = { DisplayOnReport: true };
|
||||
_this.page.Sections.push(section);
|
||||
addSectionModule(section);
|
||||
});
|
||||
@ -91,11 +101,12 @@ define(['modules/sections/section', 'modules/sections/addsection', 'common', 'mo
|
||||
|
||||
var dataheader = $('<div class="question-holder no-hover" style="font-weight: bold;font-size:14px;"></div>');
|
||||
dataheader.append('<div style="width: 60px; flex-shrink: 0"></div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 200px">' + GetTextByKey("P_IPT_NAME", "Name") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 235px">' + GetTextByKey("P_IPT_NAME", "Name") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 310px">' + GetTextByKey("P_IPT_DISPLAYTEXT", "Display Text") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 400px">' + GetTextByKey("P_IPT_TYPE", "Type") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 80px; text-align: center">' + GetTextByKey("P_IPT_REQUIRED", "Required") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 65px; text-align: center;white-space:normal;line-height:20px;">' + GetTextByKey("P_IPT_XXX", "Include Comment") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 370px">' + GetTextByKey("P_IPT_TYPE", "Type") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 80px; text-align: center;white-space:normal;line-height:20px;">' + GetTextByKey("P_IPT_DISPLAYONREPORT", "Display on Report") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 80px; text-align: center;">' + GetTextByKey("P_IPT_REQUIRED", "Required") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 65px; text-align: center;white-space:normal;line-height:20px;">' + GetTextByKey("P_IPT_INCLUDECOMMENT", "Include Comment") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 70px; text-align: center;white-space:normal;line-height:20px;">' + GetTextByKey("P_IPT_ISIMPORTANT", "Is Important") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 70px; text-align: center;white-space:normal;line-height:20px;"">' + GetTextByKey("P_IPT_CUSTOMERVISIBLE", "Customer Visible") + '</div>');
|
||||
dataheader.append('<div class="question-cell" style="width: 80px; text-align: center;white-space:normal;line-height:20px;">' + GetTextByKey("P_IPT_SEVERITYLEVEL", "Severity Level") + '</div>');
|
||||
@ -114,6 +125,7 @@ define(['modules/sections/section', 'modules/sections/addsection', 'common', 'mo
|
||||
_this.namecontrol.val(_this.page.Name).data("texts", _this.page.LocalNames);
|
||||
_this.displaytextcontrol.val(_this.page.DisplayText).data("texts", _this.page.LocalDisplayTexts);
|
||||
_this.notescontrol.val(_this.page.Notes);
|
||||
_this.displayonreportcontrol.attr('checked', _this.page.DisplayOnReport);
|
||||
}
|
||||
|
||||
if (_this.page.Sections) {
|
||||
@ -121,20 +133,22 @@ define(['modules/sections/section', 'modules/sections/addsection', 'common', 'mo
|
||||
_this.datacontent.empty();
|
||||
for (var i = 0; i < _this.page.Sections.length; i++) {
|
||||
//var s = new Section(_this.page.Sections[i], null, _this);
|
||||
addSectionModule(_this.page.Sections[i]);
|
||||
addSectionModule(_this.page.Sections[i], i);
|
||||
}
|
||||
} else
|
||||
_this.page.Sections = [];
|
||||
}
|
||||
|
||||
function addSectionModule(s) {
|
||||
var sectionmodule = new Section(s, null, _this);
|
||||
function addSectionModule(s, index) {
|
||||
var sectionmodule = new Section(s, null, _this, index);
|
||||
sectionmodule.oncopy = function (section) {
|
||||
section = JSON.parse(JSON.stringify(section));
|
||||
section.Id = "";
|
||||
section.Conditional = null;
|
||||
if (!section.IsLink && section.Questions) {
|
||||
for (var j = 0; j < section.Questions.length; j++) {
|
||||
section.Questions[j].Id = "";
|
||||
section.Questions[j].Conditional = null;
|
||||
}
|
||||
}
|
||||
_this.page.Sections.push(section);
|
||||
@ -152,6 +166,7 @@ define(['modules/sections/section', 'modules/sections/addsection', 'common', 'mo
|
||||
_this.namecontrol.prop('disabled', true);
|
||||
_this.displaytextcontrol.prop('disabled', true);
|
||||
_this.notescontrol.prop('disabled', true);
|
||||
_this.displayonreportcontrol.prop('disabled', true);
|
||||
|
||||
content.find(".iconmultitext").hide();
|
||||
content.find(".iconimage").hide();
|
||||
@ -179,7 +194,7 @@ define(['modules/sections/section', 'modules/sections/addsection', 'common', 'mo
|
||||
}
|
||||
if (sections && sections.length > 0) {
|
||||
for (var i = 0; i < sections.length; i++) {
|
||||
var it = sections[i].Values;
|
||||
var it = sections[i];
|
||||
if (it.Selected && linkedSectionIds.indexOf(it.Id) >= 0) {
|
||||
showAlert(GetTextByKey("P_IPT_ALREADYLINKED", '{0} has already been linked to current template.').replace("{0}", it.Name), GetTextByKey("P_ADDGLOBALSECTION", "Add Global Section"));
|
||||
return;
|
||||
@ -205,7 +220,7 @@ define(['modules/sections/section', 'modules/sections/addsection', 'common', 'mo
|
||||
if (sections && sections.length > 0) {
|
||||
var sids = [];
|
||||
for (var i = 0; i < sections.length; i++) {
|
||||
var it = sections[i].Values;
|
||||
var it = sections[i];
|
||||
if (it.Selected)
|
||||
sids.push(it.Id);
|
||||
}
|
||||
@ -252,6 +267,7 @@ define(['modules/sections/section', 'modules/sections/addsection', 'common', 'mo
|
||||
page.Name = this.namecontrol.val();
|
||||
page.DisplayText = this.displaytextcontrol.val();
|
||||
page.Notes = this.notescontrol.val();
|
||||
page.DisplayOnReport = this.displayonreportcontrol.prop('checked');
|
||||
|
||||
var texts = this.namecontrol.data("texts");
|
||||
if (texts) {
|
||||
@ -308,6 +324,69 @@ define(['modules/sections/section', 'modules/sections/addsection', 'common', 'mo
|
||||
this.sectionmodules.splice(tindex, 0, sm);
|
||||
}
|
||||
};
|
||||
|
||||
p.prototype.refreshIdIndex = function () {
|
||||
var id = 0;
|
||||
var needRefreshes = [];
|
||||
var needReloads = [];
|
||||
for (var s = 0; s < this.sectionmodules.length; s++) {
|
||||
var section = this.sectionmodules[s];
|
||||
section.index = s;
|
||||
section.btncondition.css('display', section.conditionalTree.init() ? '' : 'none');
|
||||
for (var i = 0; i < section.questionmodules.length; i++) {
|
||||
var question = section.questionmodules[i];
|
||||
question.idIndex = ++id;
|
||||
question.questionholder.children('.question-index').text('#' + String(id));
|
||||
question.btncondition.css('display', question.conditionalTree.init() ? '' : 'none');
|
||||
if (question.conditional?.QuestionId != null) {
|
||||
needReloads.push(question);
|
||||
}
|
||||
var root = question.conditionalTree;
|
||||
if (root == null) {
|
||||
continue;
|
||||
}
|
||||
root.initialized = false;
|
||||
if (root.tree?.is(':visible')) {
|
||||
needRefreshes.push(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
var qs = this.sectionmodules.reduce(function (array, s) { return array.concat(s.questionmodules) }, []);
|
||||
for (var i = 0; i < needReloads.length; i++) {
|
||||
var q = needReloads[i];
|
||||
var conditional = q.conditional;
|
||||
var r = cleanConditional(conditional, q.idIndex, qs);
|
||||
if (r) {
|
||||
q.conditional.QuestionId = '-';
|
||||
q.conditional.SubItems = [];
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < needRefreshes.length; i++) {
|
||||
needRefreshes[i].refresh();
|
||||
}
|
||||
};
|
||||
|
||||
function cleanConditional(c, index, qs) {
|
||||
if (!['-', 'or', 'and'].includes(c.QuestionId)) {
|
||||
var cq = qs.find(function (q) { return q.question.Id == c.QuestionId });
|
||||
if (cq == null) {
|
||||
return true;
|
||||
}
|
||||
if (cq.idIndex >= index) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (c.SubItems?.length > 0) {
|
||||
for (var i = c.SubItems.length - 1; i >= 0; i--) {
|
||||
var r = cleanConditional(c.SubItems[i], index, qs);
|
||||
if (r) {
|
||||
c.SubItems.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return p;
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user