sync
This commit is contained in:
@ -1,14 +1,32 @@
|
||||
define(['modules/sections/question', 'modules/sections/addsection', 'modules/sections/addquestion', 'common', 'modules/templates/picture']
|
||||
, function (Question, AddSection, AddQuestion, Common, Picture) {
|
||||
var s = function (section, gsm, pm) {
|
||||
define(['modules/sections/question', 'modules/sections/addsection', 'modules/sections/addquestion', 'modules/sections/conditional', 'common', 'modules/templates/picture']
|
||||
, function (Question, AddSection, AddQuestion, ConditionalTree, Common, Picture) {
|
||||
var s = function (section, gsm, pm, index) {
|
||||
this.section = section;
|
||||
this.content = null;
|
||||
this.holder = null;
|
||||
this.gsmodule = gsm;
|
||||
this.pagemodule = pm;
|
||||
if (pm != null) {
|
||||
if (isNaN(index)) {
|
||||
index = pm.page.Sections.length - 1;
|
||||
}
|
||||
this.index = index;
|
||||
// calc id index
|
||||
var idIndex = 1;
|
||||
var ss = pm.page.Sections;
|
||||
for (var i = 0; i < index; i++) {
|
||||
idIndex += ss[i].Questions.length;
|
||||
}
|
||||
this.idIndex = idIndex;
|
||||
} else {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
this.txtName = null;
|
||||
this.txtDisplayText = null;
|
||||
this.displayonreportcontrol = null;
|
||||
this.conditionholder = null;
|
||||
this.btncondition = null;
|
||||
|
||||
if (!this.section.Questions)
|
||||
this.section.Questions = [];
|
||||
@ -22,23 +40,25 @@ define(['modules/sections/question', 'modules/sections/addsection', 'modules/sec
|
||||
s.prototype.createContent = function () {
|
||||
var content = $('<div></div>');
|
||||
this.content = content;
|
||||
var div = $('<div class="sectionitem"></div>');
|
||||
var holder = $('<div class="section-holder"></div>');
|
||||
content.append(holder);
|
||||
var _this = this;
|
||||
if (sectiontype === 0) {
|
||||
if (!_this.section.IssueId || _this.section.IssueId == "")
|
||||
editable = true;
|
||||
else
|
||||
editable = false;
|
||||
div.append(holder);
|
||||
var isGlobal = this.pagemodule == null;
|
||||
if (!isGlobal) {
|
||||
var cholder = $('<div style="display: none"></div>'); // conditional hierarchy holder
|
||||
div.append(cholder);
|
||||
this.conditionholder = cholder;
|
||||
}
|
||||
content.append(div);
|
||||
var _this = this;
|
||||
|
||||
if (sectiontype === 0) {
|
||||
var package = $('<div class="question-icon section-packages" style="width:30px;padding-left:10px;"><em class="fa icon-menu icon-packages"></em></div>');
|
||||
var package = $('<div class="question-icon section-packages" style="width:30px;"><em class="spanbtn icon-packages" style="font-size:16px;"></em></div>');
|
||||
holder.append(package);
|
||||
}
|
||||
|
||||
if (sectiontype == 1) {
|
||||
var drag = $('<div class="question-icon" style="width:30px;" title="' + GetTextByKey("P_IPT_XXX","Move Section") + '"><em class="spanbtn iconmove rowdrag"></em></div>');
|
||||
var drag = $('<div class="question-icon" style="width:30px;" title="' + GetTextByKey("P_IPT_MOVESECTION", "Move Section") + '"><em class="spanbtn iconmove rowdrag"></em></div>');
|
||||
holder.append(drag);
|
||||
if (sectiontype == 1) {
|
||||
drag.attr('draggable', true);
|
||||
@ -102,21 +122,21 @@ define(['modules/sections/question', 'modules/sections/addsection', 'modules/sec
|
||||
}
|
||||
});
|
||||
holder.append(btnsection);
|
||||
this.txtName = $('<input type="text" class="section-input" maxlength="100" autocomplete="off" style="width:156px;" />');
|
||||
this.txtName = $('<input type="text" class="section-input" maxlength="100" autocomplete="off" style="width:191px;" />');
|
||||
this.txtName.change(function () {
|
||||
_this.onsave();
|
||||
});
|
||||
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.txtName, _this.section);
|
||||
});
|
||||
holder.append($('<div class="section-cell section-name" style="width:200px;flex-grow:0;"></div>').append(this.txtName).append(addiText));
|
||||
holder.append($('<div class="section-cell section-name" style="width:235px;flex-grow:0;"></div>').append(this.txtName).append(addiText));
|
||||
|
||||
this.txtDisplayText = $('<input type="text" class="section-input" maxlength="200" autocomplete="off" style="width:236px;" />');
|
||||
this.txtDisplayText.change(function () {
|
||||
_this.onsave();
|
||||
});
|
||||
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.txtDisplayText, _this.section);
|
||||
});
|
||||
@ -125,11 +145,55 @@ define(['modules/sections/question', 'modules/sections/addsection', 'modules/sec
|
||||
var picturemodule = new Picture(false, _this.section, function () { _this.onsave() });
|
||||
picturemodule.createContent();
|
||||
});
|
||||
holder.append($('<div class="section-cell section-display" style="width:230px;flex-grow: 1;"><span></span></div>').append(this.txtDisplayText).append(addiText).append(imgicon));
|
||||
if (sectiontype === 0)
|
||||
holder.append($('<div class="section-cell section-createdby" style="text-align:center;"><span></span></div>'));
|
||||
|
||||
var funcs = $('<div class="section-cell section-func" style="width: 120px;text-align:right;padding-right:20px;"></div>');
|
||||
holder.append($('<div class="section-cell section-display" style="flex-grow: 0;"><span></span></div>').css('width', isGlobal ? 680 : 425).append(this.txtDisplayText).append(addiText).append(imgicon));
|
||||
this.displayonreportcontrol = $('<input type="checkbox" />')
|
||||
.attr('title', GetTextByKey("P_IPT_SECITONDISPLAYONREPORTTIPS", 'Checked indicates that the section breakout \n will appear on the final report.\n\n Unchecked indicates that the section is only \n visible during inspection completion.'));
|
||||
this.displayonreportcontrol.change(function () {
|
||||
_this.onsave();
|
||||
});
|
||||
|
||||
if (!isGlobal) {
|
||||
var tb = (function () {
|
||||
var tb = $('<table style="line-height:unset;"></table>');
|
||||
var tr = $('<tr></tr>');
|
||||
tb.append(tr);
|
||||
var td = $('<td></td>');
|
||||
tr.append(td);
|
||||
_this.btncondition = $('<span class="spanbtn iconconditional" style="font-size: 12px" title="' + GetTextByKey("P_IPT_CONDITIONALHIERARCHY", "Conditional Hierarchy") + '"></span>');
|
||||
td.append(_this.btncondition);
|
||||
_this.btncondition.click(function () {
|
||||
var icon = $(this);
|
||||
if (icon.hasClass('iconbold')) {
|
||||
icon.removeClass('iconbold');
|
||||
_this.conditionholder.hide();
|
||||
}
|
||||
else {
|
||||
icon.addClass('iconbold');
|
||||
_this.conditionalTree.refresh();
|
||||
_this.conditionholder.show();
|
||||
}
|
||||
});
|
||||
return tb;
|
||||
})();
|
||||
holder.append($('<div class="section-cell" style="width: 255px; flex-grow: 0"></div>').append(tb));
|
||||
|
||||
!(function createConditionHierarchy() {
|
||||
var div = $('<div style="width:680px;margin-left:540px;padding-left:5px;padding-bottom:5px; border: 1px solid #a8a8a8;line-height:32px;"></div>');
|
||||
_this.conditionholder.append(div);
|
||||
|
||||
div.append($('<span style="font-weight: bold; margin-right: 5px"></span>').text(GetTextByKey('P_IPT_CONDITIONHIERARCHY', 'Condition Hierarchy')));
|
||||
var root = new ConditionalTree(_this, 'section', _this.pagemodule);
|
||||
_this.conditionalTree = root;
|
||||
div.append(root.tree);
|
||||
})();
|
||||
}
|
||||
|
||||
holder.append($('<div class="section-cell section-displayonreport" style="width:80px;text-align:center;flex-grow:0;"></div>').append(this.displayonreportcontrol));
|
||||
|
||||
holder.append($('<div style="min-width:265px;flex-grow:1;"></div>'));//ռλ
|
||||
|
||||
var funcs = $('<div class="section-cell section-func" style="width: 160px;text-align:right;padding-right:20px;"></div>');
|
||||
holder.append(funcs);
|
||||
|
||||
//holder.find('.section-name span').click(function () {
|
||||
@ -163,7 +227,19 @@ define(['modules/sections/question', 'modules/sections/addsection', 'modules/sec
|
||||
// }
|
||||
// $('#right_popup1').empty().append(aq.createContent()).show();
|
||||
//}
|
||||
var question = { QuestionType: '0', IsRequired: false, CanComment: false, IsImportant: false, SeverityLevel: 0, LookupSource: 0, SelectItems: [] };
|
||||
var question = {
|
||||
_isadd: true,
|
||||
QuestionType: '0',
|
||||
IsRequired: false,
|
||||
CanComment: false,
|
||||
IsImportant: false,
|
||||
SeverityLevel: 0,
|
||||
LookupSource: 0,
|
||||
SelectItems: []
|
||||
};
|
||||
if (!isGlobal) {
|
||||
question.Id = $.generateUUID();
|
||||
}
|
||||
_this.section.Questions.push(question);
|
||||
_this.addQuestionModule(question);
|
||||
}).attr('title', GetTextByKey("P_IPT_ADDQUESTION", 'Add Question')));
|
||||
@ -207,6 +283,7 @@ define(['modules/sections/question', 'modules/sections/addsection', 'modules/sec
|
||||
if (templatereadonly || !editable) {
|
||||
this.txtName.prop('disabled', true);
|
||||
this.txtDisplayText.prop('disabled', true);
|
||||
this.displayonreportcontrol.prop('disabled', true);
|
||||
|
||||
this.holder.find(".iconmultitext").hide();
|
||||
this.holder.find(".iconimage").hide();
|
||||
@ -236,23 +313,29 @@ define(['modules/sections/question', 'modules/sections/addsection', 'modules/sec
|
||||
s.prototype.updateContent = function (section) {
|
||||
if (section) {
|
||||
if (sectiontype === 0) {
|
||||
if (!section.IssueId || section.IssueId == "") {
|
||||
if (!section.IssueId || section.IssueId == "")
|
||||
this.holder.find('.section-packages em').hide();
|
||||
this.holder.find('.section-createdby span').text('');
|
||||
}
|
||||
else {
|
||||
else
|
||||
this.holder.find('.section-packages em').show();
|
||||
this.holder.find('.section-createdby span').text(section.IssueName);
|
||||
}
|
||||
}
|
||||
this.txtName.val(section.Name).data("texts", section.LocalNames);
|
||||
this.txtDisplayText.val(section.DisplayText).data("texts", section.LocalDisplayTexts);;
|
||||
this.txtDisplayText.val(section.DisplayText).data("texts", section.LocalDisplayTexts);
|
||||
|
||||
if (this.btncondition != null) {
|
||||
if (section.Conditional != null) {
|
||||
this.btncondition.addClass('iconexists');
|
||||
} else {
|
||||
this.btncondition.removeClass('iconexists');
|
||||
}
|
||||
}
|
||||
this.displayonreportcontrol.attr('checked', section.DisplayOnReport);
|
||||
}
|
||||
};
|
||||
s.prototype.getSectionValue = function (noalert, nocheck) {
|
||||
var section = this.section;
|
||||
section.Name = this.txtName.val();
|
||||
section.DisplayText = this.txtDisplayText.val();
|
||||
section.DisplayOnReport = this.displayonreportcontrol.prop('checked');
|
||||
var alerttitle = GetTextByKey("P_IPT_SECTION", "Section");
|
||||
if (!nocheck) {
|
||||
if (!section.Name || section.Name.length == 0) {
|
||||
@ -282,6 +365,11 @@ define(['modules/sections/question', 'modules/sections/addsection', 'modules/sec
|
||||
section.Questions.push(q);
|
||||
}
|
||||
}
|
||||
var conditional = this.conditionalTree?.getConditional(nocheck, alerttitle);
|
||||
if (conditional === false) {
|
||||
return false;
|
||||
}
|
||||
section.Conditional = conditional;
|
||||
return section;
|
||||
};
|
||||
s.prototype.updateQuestions = function (questions) {
|
||||
@ -291,10 +379,11 @@ define(['modules/sections/question', 'modules/sections/addsection', 'modules/sec
|
||||
this.questionmodules = [];
|
||||
this.content.children('.question-holder').remove();
|
||||
for (var i = 0; i < questions.length; i++) {
|
||||
this.addQuestionModule(questions[i]);
|
||||
this.addQuestionModule(questions[i], true);
|
||||
}
|
||||
this.pagemodule?.refreshIdIndex();
|
||||
};
|
||||
s.prototype.addQuestionModule = function (q) {
|
||||
s.prototype.addQuestionModule = function (q, init) {
|
||||
var _this = this;
|
||||
if (this.section.IsLink)
|
||||
q.IsLink = true;
|
||||
@ -305,13 +394,21 @@ define(['modules/sections/question', 'modules/sections/addsection', 'modules/sec
|
||||
qmodule.ondelete = function (qm) {//qm:question module
|
||||
_this.section.Questions.splice(_this.section.Questions.indexOf(qm.question), 1);
|
||||
_this.questionmodules.splice(_this.questionmodules.indexOf(qm), 1);
|
||||
_this.pagemodule?.refreshIdIndex();
|
||||
}
|
||||
this.questionmodules.push(qmodule);
|
||||
this.content.append(qmodule.createContent());
|
||||
if (!init) {
|
||||
this.pagemodule?.refreshIdIndex();
|
||||
}
|
||||
};
|
||||
s.prototype.oncopyquestion = function (question) {
|
||||
question = JSON.parse(JSON.stringify(question));
|
||||
question.Id = "";
|
||||
question._isadd = true;
|
||||
if (this.pagemodule != null) {
|
||||
question.Id = $.generateUUID();
|
||||
}
|
||||
question.Conditional = null;
|
||||
//question.IsLink = false;
|
||||
//question.ReferenceId = "";
|
||||
if (!this.section.Questions)
|
||||
@ -366,6 +463,7 @@ define(['modules/sections/question', 'modules/sections/addsection', 'modules/sec
|
||||
if (this.section.Questions.length == 0) {
|
||||
this.section.Questions.push(qm.question);
|
||||
this.questionmodules.push(qm);
|
||||
this.pagemodule?.refreshIdIndex();
|
||||
return;
|
||||
}
|
||||
var tindex = 0;
|
||||
@ -377,6 +475,7 @@ define(['modules/sections/question', 'modules/sections/addsection', 'modules/sec
|
||||
if (tindex >= 0) {
|
||||
this.section.Questions.splice(tindex, 0, qm.question);
|
||||
this.questionmodules.splice(tindex, 0, qm);
|
||||
this.pagemodule?.refreshIdIndex();
|
||||
}
|
||||
};
|
||||
s.prototype.dragInSection = function () {//called when section dragged end at question
|
||||
|
Reference in New Issue
Block a user