This commit is contained in:
2023-04-28 12:22:26 +08:00
parent 88e0a25ecd
commit c9723008af
1047 changed files with 443540 additions and 1 deletions

View File

@ -0,0 +1,673 @@
define(['modules/templates/pages', 'modules/templates/filters', 'modules/templates/picture'], function (Pages, Filters, Picture) {
var s = function (gs, template) {
this.template = template || {};
currenttemplate = this.template;
this.gsmodule = gs;
this.datasaved = false;
this.content = null;
};
s.prototype.description = "Add or edit template";
s.prototype.version = "1.0.0.0";
var namecontrol = undefined;
var locationenabledcontrol = undefined;
var needsignaturecontrol = undefined;
var forworkordercontrol = undefined;
var displaycommittimecontrol = undefined;
var displaycommitbycontrol = undefined;
var displayinspectiontitlecontrol = undefined;
var layoutcontrol = undefined;
var lockedcontrol = undefined;
var notescontrol = undefined;
var otheremailcontrol = undefined;
var pages = undefined;
var filtertd = undefined;
var filtersmodule = undefined;
var picturesdiv = undefined;
var picturesadd = undefined;
var grid_contactdt;
var pagesicon = undefined;
var pagescontent = undefined;
s.prototype.createContent = function () {
var content = $('<div style="min-width:1350px;"></div>');
this.content = content;
var _this = this;
function createHeader() {
var header = $('<div></div>');
var func = $('<div class="function_title"></div>');
if (!templatereadonly) {
var btn = $('<span class="sbutton iconsave">' + GetTextByKey("P_IPT_SAVE", "Save") + '</span>').click(function () {
onSave(0, 0);
});
func.append(btn);
btn = $('<span class="sbutton iconsave">' + GetTextByKey("P_IPT_SAVE1", "Save and Exit") + '</span>').click(function () {
onSave(1, 0);
});
func.append(btn);
if ((templatestatus == 0 || (!_this.template.Id && templatestatus == 1))
&& (!_this.template.Id || _this.template.Editable || IsForesight)) {
btn = $('<span class="sbutton iconshare">' + GetTextByKey("P_IPT_SAVEANDPUBLISH", "Save and Publish") + '</span>').click(function () {
onSave(1, 1);
});
func.append(btn);
}
}
btn = $('<span class="sbutton iconexit">' + GetTextByKey("P_IPT_SAVE2", "Exit Without Saving") + '</span>').click(function () {
showRightPopup(false);
if (_this.datasaved)
_this.gsmodule.refresh();
});
func.append(btn);
header.append(func)
return header;
}
function createTemplateContent() {
var div_main = $('<div class="content_main" style="overflow: auto;margin-top:5px;"></div>');
var div_content = $('<div class="edit-content"></div>');
div_main.append(div_content);
var tb = $('<table></table>');
div_content.append(tb);
var tr = $('<tr></tr>');
tb.append(tr);
var td = $('<td class="label" style="width:160px;"></td>');
tr.append(td);
//tr.append('<td class="label" style="width:100px;">Name:<span class="redasterisk">*</span></td>');
var btnsummary = $('<span class="section-icon" style="width:30px;margin-left:8px;margin-right:10px;font-size:18px;color:#666;cursor:pointer;">' + GetTextByKey("P_IPT_SUMMARY", "Summary") + '<em class="spanbtn iconangledown" style="font-size:18px;color:#666;"></em></span>');
btnsummary.click(function () {
var icon = btnsummary.find('.spanbtn');
if (icon.hasClass('iconangledown')) {
icon.removeClass('iconangledown').addClass('iconangleright');
_this.content.find('.templatetr').hide();
}
else {
icon.removeClass('iconangleright').addClass('iconangledown');
_this.content.find('.templatetr').show();
}
});
td.append(btnsummary).append('<span>' + GetTextByKey("P_IPT_NAME_COLON", "Name:") + '</span><span class="redasterisk">*</span>');
namecontrol = $('<input type="text" class="form-control" maxlength="100" autocomplete="off"/>');
tr.append($('<td></td>').append(namecontrol));
tr = $('<tr class="templatetr"></tr>');
tb.append(tr);
tr.append('<td class="label" style="width:160px;">' + GetTextByKey("P_IPT_LOCATIONENABLED_COLON", "Location Enabled:") + '</td>');
locationenabledcontrol = $('<input type="checkbox"/>');
needsignaturecontrol = $('<input type="checkbox"/>');
var td = $('<td></td>').append(
locationenabledcontrol,
$('<span style="margin-left:40px"></span>').text(GetTextByKey("P_IPT_SIGNATUREREQUIRED_COLON", "Signature Required:")),
needsignaturecontrol
);
if (!teamintelligence) {
td.append($('<span style="margin-left:40px"></span>').text(GetTextByKey("P_IPT_FORWORKORDER_COLON", "For Work Order:")));
forworkordercontrol = $('<input type="checkbox"/>');
td.append(forworkordercontrol);
}
tr.append(td);
tr = $('<tr class="templatetr"></tr>');
tb.append(tr);
tr.append('<td class="label" style="width:160px;">' + GetTextByKey("P_IPT_XXXXX_COLON", "Display Commit Time:") + '</td>');
displaycommittimecontrol = $('<input type="checkbox" checked="checked"/>');
displaycommitbycontrol = $('<input type="checkbox" checked="checked"/>');
displayinspectiontitlecontrol = $('<input type="checkbox" checked="checked"/>');
var td = $('<td></td>').append(
displaycommittimecontrol,
$('<span style="margin-left:40px"></span>').text(GetTextByKey("P_IPT_XXXXXX_COLON", "Display Commit By:")),
displaycommitbycontrol,
$('<span style="margin-left:40px"></span>').text(GetTextByKey("P_IPT_XXXXXX_COLON", "Display Inspection Title:")),
displayinspectiontitlecontrol
);
tr.append(td);
tr = $('<tr class="templatetr"></tr>');
tb.append(tr);
tr.append($('<td class="label" style="width:160px;"></td>').text(GetTextByKey("P_LAYOUT_COLON", "Layout:")));
layoutcontrol = $('<select id="select-layout" class="form-control" style="height: 24px"></select>');
tr.append($('<td></td>').append(layoutcontrol));
if (!teamintelligence) {
tr = $('<tr class="templatetr" style="height:30px;"></tr>');
tb.append(tr);
tr.append('<td class="label" style="width:160px;vertical-align:top;">' + GetTextByKey("P_IPT_FILTER_COLON", "Filter:") + '</td>')
.attr("title", GetTextByKey("P_IPT_FILTERTOOLTIPS", "Multiple filters can be applied that act as independent assignments"));
filtertd = $('<td></td>');
tr.append(filtertd);
}
picturesdiv = $('<div style="width:540px;"><div>');
tr = $('<tr class="templatetr" style="height:30px;"></tr>');
tb.append(tr);
tr.append('<td class="label" style="width:160px;vertical-align:top;">' + GetTextByKey("P_IPT_PICTURE_COLON", "Picture:") + '</td>');
picturesadd = $('<span class="sbutton iconadd">' + GetTextByKey("P_IPT_ADD", "Add") + '</span>').click(function () {
var picturemodule = new Picture(true, _this.template, setPictures);
picturemodule.createContent();
});
tr.append($('<td></td>').append(picturesadd));
tr = $('<tr class="templatetr" style="height:30px;"></tr>');
tb.append(tr);
tr.append('<td class="label" style="width:160px;vertical-align:top;"></td>');
tr.append($('<td></td>').append(picturesdiv));
if (IsForesight) {
tr = $('<tr class="templatetr"></tr>');
tb.append(tr);
tr.append('<td class="label" style="width:160px;">' + GetTextByKey("P_IPT_LOCKED_COLON", "Locked:") + '</td>');
lockedcontrol = $('<input type="checkbox"/>');
lockedcontrol.prop('checked', false);
tr.append($('<td></td>').append(lockedcontrol));
lockedcontrol.click(function () {
editable = !$(this).prop("checked");
_this.template.Editable = editable;
updateContent();
});
}
tr = $('<tr class="templatetr"></tr>');
tb.append(tr);
tr.append('<td class="label" style="width:160px;">' + GetTextByKey("P_IPT_NOTES_COLON", "Notes:") + '</td>');
notescontrol = $('<textarea id="dialog_notes" class="inputbox form-control" maxlength="500" autocomplete="off" style="width: 540px; margin-top: 6px;height:80px;"></textarea>');
tr.append($('<td></td>').append(notescontrol));
//Email
tr = $('<tr></tr>');
tb.append(tr);
td = $('<td class="label" style="width:160px;"></td>');
tr.append(td);
var btnemail = $('<span class="section-icon" style="float:left;width:65px;margin-left:42px;margin-top:10px;margin-right:10px;font-size:18px;color:#666;cursor:pointer;">' + GetTextByKey("P_IPT_EMAIL", "Email") + '<em class="spanbtn iconangledown" style="font-size:18px;color:#666;"></em></span>');
btnemail.click(function () {
var icon = btnemail.find('.spanbtn');
if (icon.hasClass('iconangledown')) {
icon.removeClass('iconangledown').addClass('iconangleright');
_this.content.find('.emailtd').hide();
}
else {
icon.removeClass('iconangleright').addClass('iconangledown');
_this.content.find('.emailtd').show();
}
});
td.append(btnemail);
tr.append($('<td class="emailtd"></td>').append(createEmailContent()));
return div_main;
}
function createEmailContent() {
var tb = $('<table style="line-height:25px;margin-top:10px;"></table>');
var tr = $('<tr></tr>');
tb.append(tr);
tr.append($('<td>' + GetTextByKey('P_IPT_SENDTHISTO', 'Who do you want to send this to? Select from existing relationships or manual entry.') + '</td>'));
tr = $('<tr></tr>');
tb.append(tr);
tr.append($('<td></td>').append(InitContactGridData()));
tr = $('<tr></tr>');
tb.append(tr);
tr.append($('<td>' + GetTextByKey("P_IPT_EMAILADDRESSESTIPS", "Separate multiple manually entered email addresses with a semi-colon (;).") + '</td>'));
tr = $('<tr></tr>');
tb.append(tr);
otheremailcontrol = $('<input type="text" class="form-control" maxlength="1000" autocomplete="off" style="margin-left:5px;width: 312px;" autocomplete="off" />');
tr.append($('<td><span>' + GetTextByKey("P_IPT_OTHEREMAILADDRESS", "Other Email Address") + '</span></td>').append(otheremailcontrol));
td = $('<td></td>');
tr.append(td);
return tb;
}
function InitContactGridData() {
var div_grid = $('<div style="width:430px;height:160px;"></div>');
grid_contactdt = new GridView(div_grid);
grid_contactdt.lang = {
all: GetTextByKey("P_GRID_ALL", "(All)"),
ok: GetTextByKey("P_GRID_OK", "OK"),
reset: GetTextByKey("P_GRID_RESET", "Reset")
};
var list_columns = [
{ name: 'UserName', caption: GetTextByKey("P_IPT_CONTACTNAME", "Contact Name"), valueIndex: 'UserName', css: { 'width': 180, 'text-align': 'left' } },
{ name: 'ContactType', caption: GetTextByKey("P_IPT_CONTACTTYPE", "Contact Type"), valueIndex: 'ContactType', css: { 'width': 180, 'text-align': 'left' } },
//{ name: 'Text', caption: "Text", valueIndex: 'Text', type: 3, css: { 'width': 45, 'text-align': 'center' } },
{ name: 'Selected', caption: GetTextByKey("P_IPT_EMAIL", "Email"), valueIndex: 'Selected', type: 3, css: { 'width': 45, 'text-align': 'center' } }
];
var columns = [];
// head
for (var hd in list_columns) {
var col = {};
col.name = list_columns[hd].name;
col.caption = list_columns[hd].caption;
col.visible = true;
col.sortable = true;
col.width = list_columns[hd].css.width;
col.align = list_columns[hd].css["text-align"]
col.key = list_columns[hd].valueIndex;
if (list_columns[hd].type) {
col.type = list_columns[hd].type;
}
columns.push(col);
if (col.name === "Email") {
col.attrs = function (item) {
}
}
}
grid_contactdt.canMultiSelect = false;
grid_contactdt.columns = columns;
grid_contactdt.init();
grid_contactdt.selectedrowchanged = function (rowindex) {
var rowdata = grid_contactdt.source[rowindex];
if (rowdata) {
}
}
return div_grid;
}
function GetInspectEmailList() {
inspectionrequest("GetInspectEmailList", teamintelligence, function (data) {
if (typeof (data) !== "string") {
showInspectEmailList(data);
}
}, function (err) {
});
}
function getReportLayouts() {
inspectionrequest('GetInspectLayouts', JSON.stringify([teamintelligence ? 1 : 0, '']), function (data) {
if ($.isArray(data)) {
var sid = _this.template && _this.template.ReportLayoutId;
layoutcontrol.empty().append($('<option value=""> </option>').prop('selected', sid == null || sid == ''));
for (var l of data) {
layoutcontrol.append($('<option></option>').val(l.Id).text(l.Name).prop('selected', sid == l.Id));
}
}
}, function () { });
}
function showInspectEmailList(data) {
var rows = [];
for (var i = 0; i < data.length; i++) {
var r = data[i];
r.Selected = false;
if (_this.template && _this.template.EmailList) {
for (var j = 0; j < _this.template.EmailList.length; j++) {
if (r.UserIID.toLowerCase() == _this.template.EmailList[j].UserIID.toLowerCase()) {
r.Selected = true;
break;
}
}
}
var fr = { Values: r };
rows.push(fr);
}
grid_contactdt.setData(rows);
}
function getTemplateInfo(id) {
var p = JSON.stringify([teamintelligence, htmlencode(id)]);
inspectionrequest("GetTemplate", p, function (data) {
if (typeof (data) !== "string") {
_this.template = data;
currenttemplate = _this.template;
getReportLayouts();
GetInspectEmailList();
updateContent();
}
}, function (err) {
});
}
function updateContent() {
if (pagesicon) {
pagesicon.remove();
pagesicon = undefined;
}
if (pagescontent) {
pagescontent.remove();
pagescontent = undefined;
}
if (filtertd)
filtertd.empty();
pagesicon = $('<div class="section-icon" style="width:30px;margin:10px 0 5px 15px;font-size:18px;color:#666;">' + GetTextByKey("P_IPT_PAGES", "Pages") + '</div>');
content.append(pagesicon);
var template = _this.template;
if (template.Id) {
if ((!template.IssueId || template.IssueId == "") && (template.Editable))
editable = true;
else
editable = false;
namecontrol.val(template.Name);
locationenabledcontrol.prop('checked', template.LocationEnabled);
needsignaturecontrol.prop('checked', template.NeedSignature);
if (forworkordercontrol)
forworkordercontrol.prop('checked', template.ForWorkOrder);
displaycommittimecontrol.prop('checked', template.DisplayCommitTime);
displaycommitbycontrol.prop('checked', template.DisplayCommitBy);
displayinspectiontitlecontrol.prop('checked', template.DisplayInspectionTitle);
layoutcontrol.val(template.ReportLayoutId);
if (IsForesight) {
lockedcontrol.prop('checked', !template.Editable);
if (template.IssueId && template.IssueId != "")
lockedcontrol.prop('disabled', true);
}
notescontrol.val(template.Notes);
otheremailcontrol.val(template.Emails);
setPictures();
var next = function () {
pages = new Pages(template.Pages);
pagescontent = pages.createContent();
content.append(pagescontent);
if (!teamintelligence) {
filtersmodule = new Filters(template.Filters)
filtertd.append(filtersmodule.createContent(template));
}
};
inspectionrequest("GetFuelTypes", '', function (data) {
if ($.isArray(data)) {
window.fuelTypes = data;
}
next();
}, function () {
// TODO: network error
});
}
else {
var next = function () {
pages = new Pages();
pagescontent = pages.createContent();
content.append(pagescontent);
if (!teamintelligence) {
filtersmodule = new Filters()
filtertd.append(filtersmodule.createContent());
}
};
inspectionrequest("GetFuelTypes", '', function (data) {
if ($.isArray(data)) {
window.fuelTypes = data;
}
next();
}, function () {
// TODO: network error
});
}
setEditable();
}
function setPictures() {
$(picturesdiv).empty();
if (_this.template.StaticPictures && _this.template.StaticPictures.length > 0) {
for (var i = 0; i < _this.template.StaticPictures.length; i++) {
var p = _this.template.StaticPictures[i];
var img = $('<img style="width:40px;height:40px;margin-left:5px;"/>').attr('src', p.Url).attr('title', p.Name);
$(picturesdiv).append(img);
}
}
}
function setEditable() {
if (editable) {
namecontrol.prop('disabled', false);
locationenabledcontrol.prop('disabled', false);
needsignaturecontrol.prop('disabled', false);
if (forworkordercontrol)
forworkordercontrol.prop('disabled', false);
displaycommittimecontrol.prop('disabled', false);
displaycommitbycontrol.prop('disabled', false);
displayinspectiontitlecontrol.prop('disabled', false);
layoutcontrol.prop('disabled', false);
notescontrol.prop('disabled', false);
picturesadd.show();
}
else {
namecontrol.prop('disabled', true);
locationenabledcontrol.prop('disabled', true);
needsignaturecontrol.prop('disabled', true);
if (forworkordercontrol)
forworkordercontrol.prop('disabled', true);
displaycommittimecontrol.prop('disabled', true);
displaycommitbycontrol.prop('disabled', true);
displayinspectiontitlecontrol.prop('disabled', true);
layoutcontrol.prop('disabled', true);
notescontrol.prop('disabled', true);
picturesadd.hide();
}
}
function setDisabled() {
namecontrol.prop('disabled', true);
locationenabledcontrol.prop('disabled', true);
needsignaturecontrol.prop('disabled', true);
if (forworkordercontrol)
forworkordercontrol.prop('disabled', true);
displaycommittimecontrol.prop('disabled', true);
displaycommitbycontrol.prop('disabled', true);
displayinspectiontitlecontrol.prop('disabled', true);
layoutcontrol.prop('disabled', true);
notescontrol.prop('disabled', true);
otheremailcontrol.prop('disabled', true);
if (IsForesight)
lockedcontrol.prop('disabled', true);
}
function CheckEmail(mail) {
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (mail.length == 0)
return true;
return filter.test(mail);
}
function getSubTypeName(type) {
var typename = "";
if (type === "0")
typename = GetTextByKey("P_IPT_ST_TRANSACTIONDATE", "Transaction Date");
if (type === "1")
typename = GetTextByKey("P_IPT_ST_TICKETRECEIPTNUMBER", "Ticket/Receipt Number");
if (type === "2")
typename = GetTextByKey("P_IPT_ST_DRIVERNAME", "Driver Name");
else if (type === "3")
typename = GetTextByKey("P_IPT_ST_RETAILERNAME", "Retailer Name");
else if (type === "4")
typename = GetTextByKey("P_IPT_ST_RETAILERADDRESS", "Retailer Address");
else if (type === "5")
typename = GetTextByKey("P_IPT_ST_CITY", "City");
else if (type === "6")
typename = GetTextByKey("P_IPT_ST_STATE", "State");
else if (type === "7")
typename = GetTextByKey("P_IPT_ST_ZIP", "Zip");
else if (type === "8")
typename = GetTextByKey("P_IPT_ST_ODOMETER", "Odometer");
else if (type === "9")
typename = GetTextByKey("P_IPT_ST_FUELTYPE", "Fuel Type");
else if (type === "10")
typename = GetTextByKey("P_IPT_ST_QUANTITY", "Quantity");
else if (type === "11")
typename = GetTextByKey("P_IPT_ST_UOMCOST", "Unit Cost");
else if (type === "12")
typename = GetTextByKey("P_IPT_ST_TOTALCOST", "Total Cost");
else if (type === "13")
typename = GetTextByKey("P_IPT_ST_BRANDNAME", "Brand Name");
else if (type === "14")
typename = GetTextByKey("P_IPT_ST_NOTES", "Notes");
else if (type === "15")
typename = GetTextByKey("P_IPT_ST_PICTURE", "Picture");
else if (type === "16")
typename = GetTextByKey("P_IPT_ST_DISTRIBUTEDBY", "Distributed By");
return typename;
}
function onSave(exit, publish) {
var item = {
'Name': namecontrol.val(),
'LocationEnabled': locationenabledcontrol.prop('checked'),
'NeedSignature': needsignaturecontrol.prop('checked'),
'ReportLayoutId': layoutcontrol.val(),
'DisplayCommitTime': displaycommittimecontrol.prop('checked'),
'DisplayCommitBy': displaycommitbycontrol.prop('checked'),
'DisplayInspectionTitle': displayinspectiontitlecontrol.prop('checked'),
'Notes': notescontrol.val()
};
if (forworkordercontrol)
item.ForWorkOrder = forworkordercontrol.prop('checked');
if (teamintelligence)
item.Target = 1;
var alerttitle;
if (_this.template.Id) {
item.Id = _this.template.Id;
item.Editable = _this.template.Editable;
item.IssueId = _this.template.IssueId;
alerttitle = GetTextByKey("P_IPT_EDITTEMPLATE", "Edit Template");
} else {
item.Id = -1;
item.Editable = true;
alerttitle = GetTextByKey("P_IPT_ADDTEMPLATE", "Add Template");
}
if (IsForesight)
item.Editable = !lockedcontrol.prop('checked');
if (publish === 1)
item.Status = 1;
else if (_this.template && _this.template.Status == 1)
item.Status = 1;
else
item.Status = 0;
if (!item.Name || item.Name.length == 0) {
showAlert(GetTextByKey("P_IPT_NAMENOTBEEMPTY", 'Name cannot be empty.'), alerttitle);
return;
}
//email
var emailaddress = [];
var otheremailaddressstr = otheremailcontrol.val();
if (otheremailaddressstr !== "")
emailaddress = otheremailaddressstr.split(';');
item.Emails = "";
for (var i = 0; i < emailaddress.length; i++) {
var email = $.trim(emailaddress[i]);
if (!CheckEmail(email)) {
showAlert(GetTextByKey('P_IPT_OTHEREMAILADDRESSISINVALID', 'The other email address {0} is invalid.').replace('{0}', emailaddress[i]), alerttitle);
return;
}
if (item.Emails === "")
item.Emails = email;
else
item.Emails = item.Emails + ";" + email;
}
item.Emails = otheremailaddressstr;
item.EmailList = [];
for (var i = 0; i < grid_contactdt.source.length; i++) {
var ct = grid_contactdt.source[i].Values;
if (ct.Selected)
item.EmailList.push(ct);
}
if (pages) {
item.Pages = pages.getPagesValue();
if (!item.Pages)
return;
var subtypes = [];
for (var i = 0; i < item.Pages.length; i++) {
var page = item.Pages[i];
for (var j = 0; j < page.Sections.length; j++) {
var section = page.Sections[j];
for (var k = 0; k < section.Questions.length; k++) {
var question = section.Questions[k];
if (question.QuestionType == "15" && question.SubType !== "15") {
var type = question.SubType;
if (subtypes.indexOf(type) >= 0) {
var typename = getSubTypeName(type);
showAlert(GetTextByKey("P_IPT_ONLYONEQUESTIONCANBEINCLUDEDINTHETEMPLATE", "Only one {0} question can be included in the template.").replace('{0}', typename), GetTextByKey("P_IPT_SAVETEMPLATE", 'Save Template'));
return;
}
else
subtypes.push(type);
}
if (question.QuestionType == "17" && question.IsRequired == true && (!question.TextToCompare || question.TextToCompare.length == 0)) {
showAlert(GetTextByKey("P_IPT_TEXTTPCOMPARENOTBEEMPTY", "Text to compare cannot be empty."), GetTextByKey("P_IPT_SAVETEMPLATE", 'Save Template'));
return;
}
}
}
}
}
item.Filters = [];
if (!teamintelligence && filtersmodule) {
item.Filters = filtersmodule.getFiltersValue();
}
item.StaticPictures = _this.template.StaticPictures;
var param = JSON.stringify(item);
var p = JSON.stringify([teamintelligence, htmlencode(param)]);
inspectionrequest("SaveTemplate", p, function (data) {
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_IPT_SAVETEMPLATE", 'Save Template'));
} else {
if (!_this.template.Id) {
_this.template.Id = data[0];
}
if (exit == 0) {
showAlert(GetTextByKey("P_IPT_SAVSUCCESSFULLY", 'Saved successfully.'), GetTextByKey("P_IPT_SAVETEMPLATE", 'Save Template'));
_this.datasaved = true;
}
if (exit == 1) {
_this.gsmodule.refresh();
showRightPopup(false);
}
}
}, function (err) {
showAlert(GetTextByKey("P_IPT_FAILEDTOSAVETEMPLATE", 'Failed to save Template.'), GetTextByKey("P_IPT_SAVETEMPLATE", 'Save Template'));
});
}
content.append(createHeader());
content.append(createTemplateContent());
if (this.template.Id)
getTemplateInfo(this.template.Id);
else {
getReportLayouts();
GetInspectEmailList();
updateContent();
}
if (templatereadonly)
setDisabled();
return content;
}
return s;
});

View File

@ -0,0 +1,317 @@
define(['common'], function (Common) {
/************filters module***************/
var addfilterctrl = null;
var fsm = function (filters) {
this.filters = filters || [];
this.holder = null;
this.filterModules = [];
};
fsm.prototype.description = "Template filters module";
fsm.prototype.version = "1.0.0.0";
fsm.prototype.createContent = function () {
var _this = this;
this.holder = $('<div></div>');
if (!templatereadonly && editable) {
var btnAddfilter = $('<span class="sbutton iconadd">' + GetTextByKey("P_IPT_ADD", "Add") + '</span>').click(function () {
if (!addfilterctrl)
addfilterctrl = new addfilter();
addfilterctrl.beginEdit(null, function (f) {
_this.showFilter(f);
});
});
this.holder.append($('<div style="margin-top:4px;"></div>').append(btnAddfilter));
}
if (this.filters) {
for (var i = 0; i < _this.filters.length; i++) {
this.showFilter(_this.filters[i]);
}
}
return this.holder;
}
fsm.prototype.getFiltersValue = function () {
var fs = [];
for (var i = 0; i < this.filterModules.length; i++) {
fs.push(this.filterModules[i].getFilterValue());
}
return fs;
}
fsm.prototype.showFilter = function (filter) {
var _this = this;
var temp = new fm(filter);
temp.ondelete = function (f) {
_this.filters.splice(_this.filters.indexOf(f.filter), 1);
_this.filterModules.splice(_this.filterModules.indexOf(f), 1);
}
_this.filterModules.push(temp);
this.holder.append(temp.createContent());
}
/************end filters module***************/
/************filter module***************/
var fm = function (filter) {
this.filter = filter;
this.holder = null;
this.txtvin = null;
this.txtmake = null;
this.txtmodel = null;
this.txttype = null;
this.ondelete = null;
};
fm.prototype.description = "Template filter module";
fm.prototype.version = "1.0.0.0";
fm.prototype.createContent = function () {
var _this = this;
var tb = $('<table style="border:1px solid #a8a8a8;margin-top:2px; width:810px;line-height:30px;table-layout:fixed;white-space:nowrap;"></table>');
_this.holder = tb;
var tr = $('<tr></tr>');
tb.append(tr);
tr.append($('<td style="width:90px;text-align:right;">' + GetTextByKey("P_IPT_VINSN_COLON", "VIN/SN:") + '</td>'));
this.txtvin = $('<td style="width:160px;padding-left:5px;overflow:hidden;"></td>');
tr.append(this.txtvin);
tr.append($('<td style="width:95px;text-align:right;">' + GetTextByKey("P_IPT_MAKE_COLON", "Make:") + '</td>'));
this.txtmake = $('<td style="width:120px;padding-left:5px;overflow:hidden;"></td>');
tr.append(this.txtmake);
tr.append($('<td style="width:100px;text-align:right;">' + GetTextByKey("P_IPT_MODEL_COLON", "Model:") + '</td>'));
this.txtmodel = $('<td style="width:120px;padding-left:5px;overflow:hidden;"></td>');
tr.append(this.txtmodel);
tr.append($('<td style="width:115px;text-align:right;">' + GetTextByKey("P_IPT_ASSETTYPE_COLON", "Asset Type:") + '</td>'));
this.txttype = $('<td style="width:120px;padding-left:5px;overflow:hidden;"></td>');
tr.append(this.txttype);
var btnedit = $('<em class="spanbtn iconedit"></em>').click(function () {
_this.editFilter();
}).attr('title', GetTextByKey("P_IPT_EDIT", 'Edit'));
if (!templatereadonly && editable) {
var btndelete = $('<em class="spanbtn icondelete"></em>').click(function () {
_this.holder.remove();
if (_this.ondelete)
_this.ondelete(_this);
}).attr('title', GetTextByKey("P_IPT_DELETE", 'Delete'));
tr.append($('<td style="width:55px;"></td>').append(btnedit).append(btndelete));
}
tr.append($('<td></td>'));
this.updateFilterContent();
return tb;
}
fm.prototype.updateFilterContent = function () {
var flt = this.filter;
if (flt) {
this.txtvin.text(flt.VIN);
this.txtmake.text(flt.MakeName);
this.txtmodel.text(flt.ModelName);
this.txttype.text(flt.TypeName);
}
}
fm.prototype.getFilterValue = function () {
return this.filter;
}
fm.prototype.editFilter = function () {
var _this = this;
if (!addfilterctrl)
addfilterctrl = new addfilter();
addfilterctrl.beginEdit(_this.filter, function (f) {
_this.filter = f;
_this.updateFilterContent();
});
}
/************end filter module***************/
/************addfilter module***************/
var addfilter = function () {
this.filter = null;
this.dialog = null;
this.onok = null;
var txtVIN = null;
var selMake = null;
var selModel = null;
var selType = null;
var _this = this;
this.beginEdit = function (filter, onok) {
this.filter = filter;
this.onok = onok;
if (this.filter) {
txtVIN.val(this.filter.VIN);
selMake.val(this.filter.AssetMake);
selModel.val(this.filter.AssetModel);
selType.val(this.filter.AssetType);
}
else {
txtVIN.val('');
selMake.val('-1');
selModel.val('-1');
selType.val('-1');
}
showAssetModels();
if (this.dialog) {
var title = _this.filter ? GetTextByKey("P_IPT_EDITFILTER", 'Edit Filter') : GetTextByKey("P_IPT_ADDFILTER", 'Add Filter');
this.dialog.find('.title').text(title);
this.dialog.showDialogfixed();
}
}
this.createContent = function () {
var tb = $('<table></table>');
var tr = $('<tr></tr>');
tb.append(tr);
tr.append('<td class="label">' + GetTextByKey("P_IPT_VINSN_COLON", "VIN/SN:") + '</td>');
txtVIN = $('<input type="text" class="form-control" maxlength="50" autocomplete="off"/>');
tr.append($('<td></td>').append(txtVIN));
tr = $('<tr></tr>');
tb.append(tr);
tr.append('<td class="label">' + GetTextByKey("P_IPT_MAKE_COLON", "Make:") + '</td>');
selMake = $('<select class="form-control" style="width:204px;height:22px;"></select>');
tr.append($('<td></td>').append(selMake));
selMake.change(function () {
showAssetModels();
});
tr = $('<tr></tr>');
tb.append(tr);
tr.append('<td class="label">' + GetTextByKey("P_IPT_MODEL_COLON", "Model:") + '</td>');
selModel = $('<select class="form-control" style="width:204px;height:22px;"></select>');
tr.append($('<td></td>').append(selModel));
tr = $('<tr></tr>');
tb.append(tr);
tr.append('<td class="label">' + GetTextByKey("P_IPT_ASSETTYPE_COLON", "Asset Type:") + '</td>');
selType = $('<select class="form-control" style="width:204px;height:22px;"></select>');
tr.append($('<td></td>').append(selType));
getAssetMakes();
getAssetModels();
getAssetTypes();
function OnSave() {
var item = {
'VIN': $.trim(txtVIN.val()),
'AssetMake': selMake.val(),
'MakeName': selMake.find("option:selected").text(),
'AssetModel': selModel.val(),
'ModelName': selModel.find("option:selected").text(),
'AssetType': selType.val(),
'TypeName': selType.find("option:selected").text()
};
if (!item.AssetMake || item.AssetMake == '')
item.AssetMake = '-1';
if (!item.AssetModel || item.AssetModel == '')
item.AssetModel = '-1';
if (!item.AssetType || item.AssetType == '')
item.AssetType = '-1';
if (_this.onok)
_this.onok(item);
_this.dialog.hideDialog();
}
this.dialog = Common.createDialog('', tb, OnSave, false);
}
this.createContent();
var makesdata = undefined;
var modelsdata = undefined;
var typesdata = undefined;
function getAssetMakes() {
inspectionrequest("GetAssetMakes", "", function (data) {
if (data && data.length > 0) {
makesdata = data;
showAssetMakes();
}
}, function (err) {
});
}
function getAssetModels() {
var ps = [-1, ""];
inspectionrequest("GetAssetModels", JSON.stringify(ps), function (data) {
if (data && data.length > 0) {
modelsdata = data;
showAssetModels();
}
}, function (err) {
});
}
function getAssetTypes() {
inspectionrequest("GetAssetTypes", "", function (data) {
if (data && data.length > 0) {
typesdata = data;
showAssetTypes();
}
}, function (err) {
});
}
function showAssetMakes() {
selMake.append('<option value="-1">*</option>');
if (makesdata && makesdata.length > 0) {
for (var i = 0; i < makesdata.length; i++) {
var item = makesdata[i];
selMake.append('<option value="' + item.ID + '">' + item.Name + '</option>');
}
if (_this.filter) {
selMake.val(_this.filter.AssetMake);
showAssetModels();
}
}
}
function showAssetModels() {
selModel.empty();
var makeid = selMake.val();
selModel.append('<option value="-1">*</option>');
if (!makeid || makeid == "-1")
selModel.prop('disabled', true);
else
selModel.prop('disabled', false);
if (modelsdata && modelsdata.length > 0 && makeid != "-1") {
for (var i = 0; i < modelsdata.length; i++) {
var item = modelsdata[i];
if (item.MakeID == parseInt(makeid)) {
selModel.append('<option value="' + item.ID + '">' + item.Name + '</option>');
}
}
if (_this.filter)
selModel.val(_this.filter.AssetModel);
}
}
function showAssetTypes() {
selType.append('<option value="-1">*</option>');
if (typesdata && typesdata.length > 0) {
for (var i = 0; i < typesdata.length; i++) {
var item = typesdata[i];
selType.append('<option value="' + item.Key + '">' + item.Value + '</option>');
}
if (_this.filter)
selType.val(_this.filter.AssetType);
}
}
};
/************end addfilter module***************/
return fsm;
});

View File

@ -0,0 +1,165 @@
define(['common'], function (Common) {
var dialogSection = null;
var ls = function () {
};
ls.prototype.getDialogSection = function () {
if (!dialogSection)
dialogSection = new $sectionselector();
return dialogSection;
}
var $sectionselector = function () {
this.title = GetTextByKey("P_IPT_SELECTSECTION", 'Select Section');
this.companyId = null;
this.exceptSource = null;
this.onOK = null;
this.onDialogClosed = null;
};
(function () {
var __proto = $sectionselector.prototype;
function initGrid(parent) {
var grid = new GridView(parent);
var columns = [];
columns.push({
// checkbox
name: 'check',
key: 'Selected',
width: 30,
align: 'center',
sortable: false,
allcheck: true,
type: 3
});
columns.push({
key: 'Name',
caption: GetTextByKey("P_IPT_NAME", 'Name'),
width: 200
},
{
key: 'DisplayText',
caption: GetTextByKey("P_IPT_DISPLAYTEXT", 'DisplayText'),
width: 320
});
//grid.canMultiSelect = true;
grid.columns = columns;
grid.init();
this.gridctrl = grid;
}
function createDialog() {
var dialog = $('<div class="dialog" style="display: none; width: 602px; height: 380px">');
var title = $('<div class="dialog-title"></div>').appendTo(dialog);
title.append($('<span class="title"></span>').text(this.title));
title.append('<em class="dialog-close"></em>');
var content = $('<div class="dialog-content"></div>').appendTo(dialog);
this.listdiv = $('<div style="width: 580px; height: 290px;margin-bottom:5px;"></div>').appendTo(content);
var dialogFunction = $('<div class="dialog-func"></div>').appendTo(dialog);
$('<input type="button" value="' + GetTextByKey("P_IPT_CANCEL", "Cancel") + '" class="dialog-close" />').appendTo(dialogFunction);
$('<input type="button" value="' + GetTextByKey("P_IPT_COPY", "Copy") + '" />').click(onCopyClick.bind(this)).appendTo(dialogFunction);
$('<input type="button" value="' + GetTextByKey("P_IPT_ADDASLINK", "Add as Link") + '" />').click(onLinkClick.bind(this)).appendTo(dialogFunction);
$('<div class="clear"></div>').appendTo(dialogFunction);
$('<div class="maskbg" style="display: none"><div class="loading_icon icon c-spin"></div></div>').appendTo(dialog);
// init
initGrid.call(this, this.listdiv);
$(document.body).append(dialog);
var mask = $('<div class="maskbg"></div>');
dialog.data('mask', mask);
dialog.before(mask);
var _this = this;
dialog.dialog(function () {
if (_this.onDialogClosed)
_this.onDialogClosed();
if (dialog.data('mask'))
dialog.data('mask').hide();
});
return dialog;
}
__proto.showSelector = function () {
if (!this.dialog) {
this.dialog = createDialog.call(this);
}
if (this.dialog.data('mask'))
this.dialog.data('mask').show();
this.dialog.showDialog(false);
this.gridctrl.setData([]);
onSearch.call(this);
};
function onKeyPress(e) {
if (e.keyCode === 13) {
onSearch.call(this);
}
};
function excepted(id, source) {
for (var i = 0; i < source.length; i++) {
if (source[i] === id) {
return true;
}
}
return false;
}
function onSearch() {
var maskbg = this.dialog.find('.maskbg');
maskbg.show();
var excepts = this.exceptSource;
var gridctrl = this.gridctrl;
var title = this.title;
var companyId = this.companyId || '';
inspectionrequest("GetGlobalSections", teamintelligence, function (data) {
if (typeof data === 'string') {
showAlert(GetTextByKey("P_IPT_FAILEDTOGETTHESECTIONS", 'Failed to get the sections: ') + data, title);
maskbg.hide();
return;
}
var items = [];
for (var i = 0; i < data.length; i++) {
var it = data[i];
if (excepts == null || !excepted(it.Id, excepts)) {
items.push({ Values: it });
}
}
gridctrl.setData(items);
maskbg.hide();
}, function (err) {
showAlert(GetTextByKey("P_IPT_FAILEDTOGETTHESECTIONS1",'Failed to get the sections.'), title);
maskbg.hide();
});
}
function onCopyClick() {
//var index = this.gridctrl.selectedIndex;
this.onOK && this.onOK(this.gridctrl.source, true);
if (this.dialog.data('mask'))
this.dialog.data('mask').hide();
this.dialog.hideDialog();
}
function onLinkClick() {
//var index = this.gridctrl.selectedIndex;
this.onOK && this.onOK(this.gridctrl.source, false);
if (this.dialog.data('mask'))
this.dialog.data('mask').hide();
this.dialog.hideDialog();
}
})();
return ls;
});

View File

@ -0,0 +1,313 @@
define(['modules/sections/section', 'modules/sections/addsection', 'common', 'modules/templates/linksection'], function (Section, AddSection, Common, LinkSection) {
var p = function (page, pagesmodule) {
this.page = page || {};
this.pagesmodule = pagesmodule;
this.namecontrol = undefined;
this.displaytextcontrol = undefined;
this.notescontrol = undefined;
this.onNameChanged = undefined;
this.datacontent = null;
this.sectionmodules = [];
};
p.prototype.description = "Page";
p.prototype.version = "1.0.0.0";
p.prototype.createContent = function () {
var _this = this;
var content = $('<div></div>');
function createPageContent() {
var div_main = $('<div class="content_main"></div>');
var div_content = $('<div class="edit-content"></div>');
div_main.append(div_content);
var tb = $('<table></table>');
div_content.append(tb);
var tr = $('<tr></tr>');
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_ADDITIONALTEXTS", "Additional Texts") + '"/>');
addiText.click(function () {
Common.createMultiTextDialog(_this.namecontrol);
});
tr.append($('<td style="white-space:nowrap;"></td>').append(_this.namecontrol).append(addiText));
_this.namecontrol.change(function () {
if (_this.onNameChanged)
_this.onNameChanged($.trim(_this.namecontrol.val()))
})
tb.append(tr);
tr.append('<td class="label" style="width:154px;">' + GetTextByKey("P_IPT_NOTES_COLON", "Notes:") + '</td>');
_this.notescontrol = $('<textarea id="dialog_notes" class="inputbox form-control" maxlength="500" autocomplete="off" style="width: 540px; margin-top:6px;height:55px;"></textarea>');
tr.append($('<td rowspan="2"></td>').append(_this.notescontrol));
tr = $('<tr></tr>');
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_ADDITIONALTEXTS", "Additional Texts") + '"/>');
addiText.click(function () {
Common.createMultiTextDialog(_this.displaytextcontrol);
});
tr.append($('<td style="white-space:nowrap;"></td>').append(_this.displaytextcontrol).append(addiText));
var sectioncontent = createSectionContent();
div_main.append(sectioncontent);
return div_main;
}
function createSectionContent() {
var content = $('<div style="min-width:1820px;"></div>');
function createSectionHeader() {
var header = $('<div></div>');
//header.append($('<div class="page_title"></div>').text(gs.title));
var func = $('<div class="function_title"></div>');
var iconAdd = $('<span class="sbutton iconadd">' + GetTextByKey("P_IPT_ADD", "Add") + '</span>').click(function () {
//var s = new AddSection();
//s.onsave = function (section) {
// _this.page.Sections.push(section);
// updateContent(true);
//}
//$('#right_popup1').empty().append(s.createContent()).show();
var section = {};
_this.page.Sections.push(section);
addSectionModule(section);
});
func.append(iconAdd);
var iconRefresh = $('<span class="sbutton iconlink">' + GetTextByKey("P_ADDGLOBALSECTION", "Add Global Section") + '</span>').click(function () {
addGlobalSection();
});
func.append(iconRefresh);
header.append(func)
return header;
}
if (!templatereadonly && editable)
content.append(createSectionHeader());
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: 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: 100px; text-align: center">' + GetTextByKey("P_IPT_CANCOMMENT", "Can Comment") + '</div>');
dataheader.append('<div class="question-cell" style="width: 100px; text-align: center">' + GetTextByKey("P_IPT_ISIMPORTANT", "Is Important") + '</div>');
dataheader.append('<div class="question-cell" style="width: 140px">' + GetTextByKey("P_IPT_CUSTOMERVISIBLE", "Customer Visible") + '</div>');
dataheader.append('<div class="question-cell" style="width: 140px">' + GetTextByKey("P_IPT_SEVERITYLEVEL", "Severity Level") + '</div>');
dataheader.append('<div style="flex-grow: 1" style="width: 160px">' + GetTextByKey("P_IPT_ST_NOTES", "Notes") + '</div>');
dataheader.append('<div class="question-cell" style="width: 90px;padding-right:20px;"></div>');
content.append(dataheader);
_this.datacontent = $('<div></div>');
content.append(_this.datacontent);
return content;
}
function updateContent(sectiononly) {
if (!sectiononly) {
_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);
}
if (_this.page.Sections) {
_this.sectionmodules = [];
_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]);
}
} else
_this.page.Sections = [];
}
function addSectionModule(s) {
var sectionmodule = new Section(s, null, _this);
sectionmodule.oncopy = function (section) {
section = JSON.parse(JSON.stringify(section));
section.Id = "";
if (!section.IsLink && section.Questions) {
for (var j = 0; j < section.Questions.length; j++) {
section.Questions[j].Id = "";
}
}
_this.page.Sections.push(section);
addSectionModule(section);
};
sectionmodule.ondelete = function (sm) {
_this.page.Sections.splice(_this.page.Sections.indexOf(sm.section), 1);
_this.sectionmodules.splice(_this.sectionmodules.indexOf(sm), 1);
}
_this.sectionmodules.push(sectionmodule);
_this.datacontent.append(sectionmodule.createContent());
}
function setDisabled() {
_this.namecontrol.prop('disabled', true);
_this.displaytextcontrol.prop('disabled', true);
_this.notescontrol.prop('disabled', true);
content.find(".iconmultitext").hide();
content.find(".iconimage").hide();
}
function addGlobalSection() {//<2F><><EFBFBD><EFBFBD>Global Section
var dialogSection = new LinkSection().getDialogSection();
dialogSection.onDialogClosed = function () {
}
dialogSection.onOK = function (sections, iscopy) {
if (!iscopy) {
var linkedSectionIds = [];
if (_this.pagesmodule && _this.pagesmodule.pages) {
for (var i = 0; i < _this.pagesmodule.pages.length; i++) {
var page = _this.pagesmodule.pages[i];
if (page.Sections) {
for (var j = 0; j < page.Sections.length; j++) {
var s = page.Sections[j];
if (s.IsLink)
linkedSectionIds.push(s.ReferenceId);
}
}
}
}
if (sections && sections.length > 0) {
for (var i = 0; i < sections.length; i++) {
var it = sections[i].Values;
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;
}
}
}
}
onAddGlobalSection(sections, iscopy);
}
//var sections = [];
//for (var i = 0; i < _this.page.Sections.length; i++) {
// if (_this.page.Sections[i].IsLink)
// sections.push(_this.page.Sections[i].ReferenceId);
//}
//dialogSection.exceptSource = sections;
dialogSection.showSelector();
}
function onAddGlobalSection(sections, iscopy) {
if (sections && sections.length > 0) {
var sids = [];
for (var i = 0; i < sections.length; i++) {
var it = sections[i].Values;
if (it.Selected)
sids.push(it.Id);
}
var p = JSON.stringify([teamintelligence, JSON.stringify(sids)]);
inspectionrequest("GetGlobalSectionsByID", p, function (data) {
if (typeof data === 'string')
return;
for (var i = 0; i < data.length; i++) {
var section = data[i];
if (iscopy) {//copy secton<6F><6E>reference its questions
if (section.Questions) {
for (var j = 0; j < section.Questions.length; j++) {
var q = section.Questions[j];
q.Id = '';
//q.ReferenceId = q.Id;
//q.IsLink = true;
}
}
}
else {//reference section
section.ReferenceId = section.Id;
section.IsLink = true;
}
section.Id = '';
_this.page.Sections.push(section);
addSectionModule(section);
}
//updateContent(true);
}, function (err) {
});
}
}
content.append(createPageContent());
updateContent();
if (templatereadonly || !editable)
setDisabled();
return content;
}
p.prototype.getPageValue = function (noalert, nocheck) {
var page = this.page;
page.Name = this.namecontrol.val();
page.DisplayText = this.displaytextcontrol.val();
page.Notes = this.notescontrol.val();
var texts = this.namecontrol.data("texts");
if (texts) {
page.LocalNames = texts;
}
texts = this.displaytextcontrol.data("texts");
if (texts) {
page.LocalDisplayTexts = texts;
}
if (!nocheck) {
var alerttitle = GetTextByKey("P_IPT_PAGE", 'Page');
if (!noalert && (!page.Name || page.Name.length == 0)) {
showAlert(GetTextByKey("P_IPT_PAGENAMENOTBEEMPTY", 'Page Name cannot be empty.'), alerttitle);
return false;
}
if (!noalert && (!page.DisplayText || page.DisplayText.length == 0)) {
showAlert(GetTextByKey("P_IPT_DISPLAYTEXTNOTBEEMPTY", 'Display Text cannot be empty.'), alerttitle);
return false;
}
}
page.Sections = [];
if (this.sectionmodules.length > 0) {
for (var i = 0; i < this.sectionmodules.length; i++) {
var s = this.sectionmodules[i].getSectionValue(noalert, nocheck);
if (!s) return false;
page.Sections.push(s);
}
}
return page;
}
p.prototype.dragOutSection = function (sm) {//called when end drag
var index = this.page.Sections.indexOf(sm.section)
if (index >= 0) {
this.page.Sections.splice(index, 1);
this.sectionmodules.splice(index, 1);
}
};
p.prototype.dragInSection = function (target, sm, after) {//called when end drag
if (!this.page.Sections)
this.page.Sections = [];
if (this.page.Sections.length == 0) {
this.page.Sections.push(sm.section);
this.sectionmodules.push(sm);
return;
}
var tindex = 0;
if (target) {
tindex = this.page.Sections.indexOf(target);
if (after)
tindex = tindex + 1;
}
if (tindex >= 0) {
this.page.Sections.splice(tindex, 0, sm.section);
this.sectionmodules.splice(tindex, 0, sm);
}
};
return p;
});

View File

@ -0,0 +1,164 @@
define(['modules/templates/page'], function (Page) {
var q = function (pages) {
this.pages = pages || [];
this.pageModules = [];
};
q.prototype.description = "Pages Module";
q.prototype.version = "1.0.0.0";
q.prototype.createContent = function () {
var _this = this;
var pagescontent = $('<div></div>');
var ul = $('<ul class="tab_header" style="padding-top: 5px;"></ul>');
pagescontent.append(ul);
var addli = $('<li data-disabled="1" data-href="add"></li>');
ul.append(addli);
addli.append($('<span class="spanbtn iconadd"></span>'));
addli.append($('<span>' + GetTextByKey("P_IPT_ADD", "Add") + '</span>'));
addli.click(function () {
addTab(null, true);
});
if (!templatereadonly && editable)
addli.show();
else
addli.hide();
ul.append($('<li style="clear: both;"></li>'));
var tabIndex = 0;
for (var i = 0; i < this.pages.length; i++) {
var p = this.pages[i];
addTab(p, false);
}
pagescontent.tab();//tab()<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>addli<6C><69>click<63>¼<EFBFBD>
function addTab(p, newadd) {
if (!p) {
p = {};
_this.pages.push(p);
}
var tabName = 'tab_' + tabIndex++;
var pm = new Page(p, _this);
_this.pageModules.push(pm);
var pagecontent = pm.createContent().attr('data-page', tabName);
var li = $('<li></li>').attr('data-href', tabName);
if (tabIndex == 1)
li.addClass('selected');
li.append($('<span></span>').text(p.Name || GetTextByKey("P_IPT_UNNAMED", 'Unnamed')));
if (!templatereadonly && editable) {
li.css('padding-right', 6);
var btncopy = $('<span class="spanbtn iconcopy" style="margin-left:10px;padding-left:3px;padding-right:4px;"></span>');
btncopy.click(function () {
var item = copyPage(pm.getPageValue(true, true));
_this.pages.push(item);
addTab(item, true);
return false;
}).attr('title', GetTextByKey("P_IPT_COPYPAGE", 'Copy Page'));
li.append(btncopy);
var btndelete = $('<span class="spanbtn icondelete" style="padding-left:3px;"></span>');
btndelete.click(function () {
showConfirm(GetTextByKey("P_IPT_AREYOUSUREYOUWANTTOREMOVETHISPAGE", 'Are you sure you want to remove this page?'), GetTextByKey("P_IPT_REMOVEPAGE", 'Remove Page'), function () {
var next = li.next();
if (next.is(addli))
next = li.prev();
next.click();
li.remove();
pagescontent.children('div[data-page="' + tabName + '"]').remove();
_this.pages.splice(_this.pages.indexOf(p), 1);
_this.pageModules.splice(_this.pageModules.indexOf(pm), 1);
});
}).attr('title', GetTextByKey("P_IPT_DELETEPAGE", 'Delete Page'));
li.append(btndelete);
pm.onNameChanged = function (name) {
if (name && name != '')
li.children(":first").text(name);
else
li.children(":first").text(GetTextByKey("P_IPT_UNNAMED", 'Unnamed'));
}
}
else
addli.hide();
binddrag(li, p);
addli.before(li);
if (newadd) {
pagescontent.tab();
li.click();
}
pagescontent.append(pagecontent);
}
var draggingtab = null;
var draggingpage = null;
function binddrag(li, p) {
li.attr('draggable', true);
li.bind('dragstart', function (e) {
draggingtab = $(this);
draggingpage = p;
});
li.bind('dragend', function (e) {
draggingtab = null;
draggingpage = null;
});
li.bind('dragover', function (e) {
e.originalEvent.preventDefault()
});
li.bind('drop', function (e) {
var t = $(this);
if (t.is(draggingtab))
return;
var t = $(this);
var after = e.originalEvent.clientX > t.offset().left + t.width() / 2;
if (after) {
t.after(draggingtab);
_this.pages.splice(_this.pages.indexOf(draggingpage), 1);
_this.pages.splice(_this.pages.indexOf(p) + 1, 0, draggingpage);
}
else {
t.before(draggingtab);
_this.pages.splice(_this.pages.indexOf(draggingpage), 1);
_this.pages.splice(_this.pages.indexOf(p), 0, draggingpage);
}
});
}
return pagescontent;
};
q.prototype.getPagesValue = function () {
for (var i = 0; i < this.pageModules.length; i++) {
var p = this.pageModules[i].getPageValue();//getPageValueֱ<65><D6B1><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>
if (!p) return false;
}
return this.pages;
}
function copyPage(p) {
var p = JSON.parse(JSON.stringify(p));
p.Id = "";
if (p.Sections) {
for (var i = p.Sections.length - 1; i >= 0; i--) {
var s = p.Sections[i];
if (s.IsLink)
p.Sections.splice(i, 1);
}
for (var i = 0; i < p.Sections.length; i++) {
var s = p.Sections[i];
s.Id = "";
if (s.Questions) {
for (var j = 0; j < s.Questions.length; j++) {
var q = s.Questions[j];
q.Id = "";
}
}
}
}
return p;
}
return q;
});

View File

@ -0,0 +1,295 @@
define(['common', 'modules/templates/templatepicture'], function (Common, TemplatePicture) {
var fsm = function (istemplate, pageele, onok) {
this.pageele = pageele || {};
this.holder = null;
this.dialog = null;
this.istemplate = istemplate;
this.onok = onok;
this.title = GetTextByKey("P_IPT_PICTURES", "Picture");
};
fsm.prototype.description = GetTextByKey("P_IPT_PICTURES", "Picture");
fsm.prototype.version = "1.0.0.0";
fsm.prototype.createContent = function () {
var _this = this;
var input = null;
var nopictr = null;
var tabindex = 0;
if (sectiontype === 0) {
if (!_this.pageele.IssueId || _this.pageele.IssueId == "")
editable = true;
else
editable = false;
}
var content = $('<div style="max-height: 200px;overflow-y: auto;"></div>');
var tb = $('<table style="max-height:300px;line-height:30px;"></table>');
function createPictureContent() {
if (_this.pageele && _this.pageele.StaticPictures && _this.pageele.StaticPictures.length > 0) {
for (var i = 0; i < _this.pageele.StaticPictures.length; i++) {
var p = _this.pageele.StaticPictures[i];
if (!p.Id)
p.Id = $.newGuid();
addpicturerow(p);
}
}
//else {
// addnopicrow();
//}
return tb;
}
function createAddButton() {
if (!templatereadonly && editable) {
var addpicdiv = $('<div style="line-height: 30px;"></div>');
var addpicicon = $('<span class="sbutton iconadd">' + GetTextByKey("P_IPT_ADDPICTURE", "Add Picture") + '</span>').click(function () {
browsePicture();
});
addpicdiv.append(addpicicon);
if (!_this.istemplate && sectiontype == 1) {
var addtemppicicon = $('<span class="sbutton iconadd">' + GetTextByKey("P_IPT_ADDREFERENCE", "Add Reference") + '</span>').click(function () {
var dialogTemplatePicture = new TemplatePicture().getDialogPicture();
dialogTemplatePicture.onDialogClosed = function () {
}
dialogTemplatePicture.onOK = function (pics, iscopy) {
onTemplatePictures(pics, iscopy);
}
dialogTemplatePicture.showSelector();
});
}
addpicdiv.append(addtemppicicon);
content.append(addpicdiv);
}
}
function onTemplatePictures(pics, iscopy) {
if (pics && pics.length > 0) {
var sids = [];
for (var i = 0; i < pics.length; i++) {
var it = pics[i].Values;
if (it.Selected) {
var p = {};
p.Id = $.newGuid();
p.ReferenceId = it.Id;
p.Name = it.Name;
p.DataType = it.DataType;
p.ContentId = it.ContentId;
p.Url = it.Url;
addpicturerow(p);
}
}
}
}
function addnopicrow() {
nopictr = $('<tr style="height:30px;"></tr>');
var td = $('<td style="padding:5px;padding-left:10px;">' + GetTextByKey("P_IPT_NOPICTURE", "No Picture") + '</td>');
nopictr.append(td);
tb.append(nopictr);
}
function addpicturerow(p) {
if (nopictr) {
nopictr.remove();
nopictr = null;
}
var tr = $('<tr class="pic"></tr>');
tb.append(tr);
if (!templatereadonly && editable)
createdragtd(tr);
createlinktd(tr, p);
var td = $('<td style="width:50px;"></td>');
var img = $('<img style="width:30px;height:30px;float:right;margin-right:10px;"/>').attr('src', p.Url);
td.append(img);
tr.append(td);
input = $('<input type="text" class="form-control" style="width:220px" maxlength="100" autocomplete="off"/>').attr("tabindex", ++tabindex);
if (templatereadonly || p.ReferenceId || !editable)
input.prop('disabled', true);
input.val(p.Name);
tr.data("pic", p);
tr.append($('<td></td>').append(input));
td = $('<td></td>');
if (!templatereadonly && !IsReferenced(p.Id) && editable) {
var del = $('<span class="spanbtn icondelete"></span>').click(tr, function (e) {
showConfirm(GetTextByKey("P_IPT_DELETEFILECONFIRM", 'Are you sure you want to delete this file?'), GetTextByKey("P_IPT_DELETEFILE", 'Delete File'), function () {
var p = e.data.data("pic");
e.data.remove();
//var p = JSON.stringify([teamintelligence, p.ContentId]);
//inspectionrequest("DeleteStaticPicture", htmlencode(p), function (data) {
//}, function (err) {
//});
});
});
td.append(del)
}
tr.append(td);
tb.append(tr);
}
var draggingpicobj
function createdragtd(tr) {
var td = $('<td style="width:32px;"></td>');
var drag = $('<div class="question-icon" style="width:30px;"><em class="spanbtn iconmove rowdrag" style="font-size:14px;padding:0;"></em></div>');
td.append(drag);
tr.append(td);
drag.attr('draggable', true);
tr.bind('dragstart', function (e) {
//var data = e.originalEvent.dataTransfer;
draggingpicobj = tr;
});
tr.bind('dragend', function (e) {
draggingpicobj = null;
});
tr.bind('dragover', function (e) {
e.originalEvent.preventDefault()
});
tr.bind('drop', function (e) {
var t = $(this);
if (!draggingpicobj || t.is(draggingpicobj))
return;
var after = e.originalEvent.clientY > t.offset().top + t.height() / 2;
if (after)
t.after(draggingpicobj);
else
t.before(draggingpicobj);
//draggingobj.pagemodule.dragOutSection(draggingobj);
//_this.pagemodule.dragInSection(_this.section, draggingobj, after);
});
}
function createlinktd(tr, pic) {
var td = $('<td style="width:32px;"></td>');
if (pic.ReferenceId) {
var link = $('<div class="question-icon" style="width:30px;"><em class="spanbtn iconlink" style="cursor:default;margin:0;padding:0;font-size:10px;"></em></div>');
td.append(link);
}
else {
td.text(" ");
}
tr.append(td);
}
function IsReferenced(picid) {//check if template picture can be deleted
if (!_this.istemplate)
return false;
if (currenttemplate && currenttemplate.Pages && currenttemplate.Pages.length > 0) {
for (var i = 0; i < currenttemplate.Pages.length; i++) {
var page = currenttemplate.Pages[i];
for (var j = 0; j < page.Sections.length; j++) {
var section = page.Sections[j];
if (section.StaticPictures) {
for (var m = 0; m < section.StaticPictures.length; m++) {
var p = section.StaticPictures[m];
if (p.ReferenceId == picid)
return true;
}
}
for (var k = 0; k < section.Questions.length; k++) {
var question = section.Questions[k];
if (question.StaticPictures) {
for (var n = 0; n < question.StaticPictures.length; n++) {
var p = question.StaticPictures[n];
if (p.ReferenceId == picid)
return true;
}
}
}
}
}
}
return false;
}
function browsePicture() {
var file = $('<input type="file" style="display: none;" accept="image/png,image/jpg,image/jpeg" />');
file.change(function () {
var files = this.files;
var file = files[0];
if (file.size == 0) {
alert(GetTextByKey("P_IPT_FILETIPS", "File size is 0kb, uploading failed."));
return false;
}
if (file.size > 1024 * 1024 * 2) {
alert(GetTextByKey("P_IPT_FILETIPS1", "File is too large. Maximum size is 2MB."));
return false;
}
SavePicture(file);
}).click();
}
function SavePicture(file) {
var formData = new FormData();
formData.append("pic", file);
formData.append("MethodName", "UploadStaticPicture");
formData.append("ClientData", teamintelligence);
$.ajax({
url: 'Inspection.aspx',
type: 'POST',
dataType: 'json',
processData: false,
contentType: false,
data: formData,
async: true,
success: function (data) {
if (data) {
var p = {};
p.Id = $.newGuid();
p.ContentId = data.Item1;
p.Url = data.Item2;
p.Name = file.name;
p.DataType = file.name.substring(file.name.lastIndexOf("."));
addpicturerow(p);
}
},
error: function (err) {
}
});
}
function OnSave() {
if (!templatereadonly && editable) {
var pics = [];
tb.find("tr.pic").each(function () {
var tr = $(this);
var p = tr.data("pic");
p.Name = tr.find("input").val();
pics.push(p);
})
//for (var i in inputs) {
// var input = inputs[i];
// var p = input.data("pic");
// p.Name = input.val();
// pics.push(p);
//}
_this.pageele.StaticPictures = pics;
_this.dialog.hideDialog();
if (_this.onok)
_this.onok();
}
}
content.append(createAddButton());
content.append(createPictureContent());
_this.dialog = Common.createDialog(GetTextByKey("P_IPT_PICTURE", "Picture"), content, OnSave, true);
_this.dialog.showDialogfixed();
}
return fsm;
});

View File

@ -0,0 +1,140 @@
define(['modules/templates/addtemplate', 'common'], function (AddTemplate, Common) {
var q = function (tp, template, index) {
this.template = template;
this.templatemodule = tp;
this.index = index
};
q.prototype.description = "Template Module";
q.prototype.version = "1.0.0.0";
var newnamecontrol = undefined;
var dialog = null;
q.prototype.createContent = function () {
var holder = $('<div class="question-holder"></div>');
if (this.index % 2 == 1)
holder.addClass('holder-even');
holder.append('<div class="question-icon template-packages" style="width:30px;padding-left:10px; "><em class="fa icon-menu icon-packages"></em></div>');
holder.append('<div class="question-cell template-name" style="width:390px;padding-left:10px;"><span></span></div>');
//holder.append('<div class="question-cell template-display" style="width: 280px;"><span></span></div>');
holder.append('<div class="question-cell template-notes" style="width:400px;"></div>');
holder.append('<div class="question-cell template-createdby" style="width:200px;"><span></span></div>');
var funcs = $('<div class="question-cell template-func" style="width:110px;padding-right:20px;"></div>');
holder.append(funcs);
var _this = this;
holder.find('.template-name span').click(function () {
var aq = new AddTemplate(_this.templatemodule, _this.template);
$('#right_popup').empty().append(aq.createContent());
showRightPopup(true);
});
if (!templatereadonly) {
funcs.append($('<em class="spanbtn iconedit"></em>').click(function () {
var aq = new AddTemplate(_this.templatemodule, _this.template);
$('#right_popup').empty().append(aq.createContent());
showRightPopup(true);
}).attr('title', GetTextByKey("P_IPT_EDITTEMPLATE", 'Edit Template')));
if (templatestatus == 0) {
funcs.append($('<em class="spanbtn iconshare"></em>').click(function () {
_this.publish();
}).attr('title', GetTextByKey("P_IPT_PUBLISHTEMPLATE", 'Publish Template')));
}
funcs.append($('<em class="spanbtn icondelete"></em>').click(function () {
_this.delete();
}).attr('title', GetTextByKey("P_IPT_DELETETEMPLATE", 'Delete Template')));
if (!_this.template.IssueId || _this.template.IssueId == "") {
funcs.append($('<em class="spanbtn iconcopy"></em>').click(function () {
_this.openSaveAs();
}).attr('title', GetTextByKey("P_IPT_SAVEAS", 'Save As')));
}
}
this.holder = holder;
if (this.template != null) {
this.updateContent(this.template);
}
return holder;
};
q.prototype.updateContent = function (template) {
if (this.template != template) {
this.template = template;
}
if (!template.IssueId || template.IssueId == "")
this.holder.find('.template-packages em').hide();
else
this.holder.find('.template-packages em').show();
this.holder.find('.template-name span').text(template.Name);
this.holder.find('.template-name span').attr('title', template.Name);
this.holder.find('.template-display span').text(template.DisplayText);
this.holder.find('.template-display span').attr('title', template.DisplayText);
this.holder.children('.template-notes').html(replaceHtmlText(template.Notes));
this.holder.children('.template-notes').attr('title', replaceHtmlText(template.Notes));
this.holder.find('.template-createdby span').text(template.IssueName);
this.holder.find('.template-createdby span').attr('title', template.IssueName);
};
q.prototype.delete = function () {
var _this = this;
showConfirm(GetTextByKey("P_IPT_AREYOUSUREYOUWANTTODELETETHISTEMPLATE", 'Are you sure you want to delete this template?'), GetTextByKey("P_IPT_DELETETEMPLATE", 'Delete Template'), function () {
var p = JSON.stringify([teamintelligence, htmlencode(_this.template.Id)]);
inspectionrequest("DeleteTemplate", p, function (data) {
if (data !== 'OK')
showAlert(data, GetTextByKey("P_IPT_DELETETEMPLATE", 'Delete Template'));
else if (_this.templatemodule && typeof _this.templatemodule.refresh === "function")
_this.templatemodule.refresh();
}, function (err) {
showAlert(GetTextByKey("P_IPT_FAILEDTODELETETEMPLATE", 'Failed to delete template.'), GetTextByKey("P_IPT_DELETETEMPLATE", 'Delete Template'));
});
});
};
q.prototype.publish = function () {
var _this = this;
showConfirm(GetTextByKey("P_IPT_AREYOUSUREYOUWANTTOPUBLISHTHISTEMPLATE", 'Are you sure you want to publish the template?'), GetTextByKey("P_IPT_PUBLISHTEMPLATE", 'Publish Template'), function () {
var p = JSON.stringify([teamintelligence, htmlencode(_this.template.Id)]);
inspectionrequest("PublishTemplate", p, function (data) {
if (data !== 'OK')
showAlert(data, GetTextByKey("P_IPT_PUBLISHTEMPLATE", 'Publish Template'));
else if (_this.templatemodule && typeof _this.templatemodule.refresh === "function")
_this.templatemodule.refresh();
}, function (err) {
showAlert(GetTextByKey("P_IPT_FAILEDTOPUBLISHTEMPLATE", 'Failed to publish template.'), GetTextByKey("P_IPT_PUBLISHTEMPLATE", 'Publish Template'));
});
});
};
q.prototype.openSaveAs = function () {
var _this = this;
var tb = $('<table style="line-height:40px;"></table>');
var tr = $('<tr></tr>');
tb.append(tr);
tr.append('<td class="label" style="vertical-align:middle;">' + GetTextByKey("P_IPT_TEMPLATENAME_COLON", "Template Name:") + '<span class="redasterisk">*</span></td>');
newnamecontrol = $('<input type="text" maxlength="100"/>');
tr.append($('<td></td>').append(newnamecontrol));
dialog = Common.createDialog(GetTextByKey("P_IPT_SAVEAS", 'Save As'), tb, function () {
_this.onSaveAs();
});
dialog.showDialog();
};
q.prototype.onSaveAs = function () {
var _this = this;
var name = newnamecontrol.val();
if (!name || name.length == 0) {
showAlert(GetTextByKey("P_IPT_TEMPLATENAMENOTBEEMPTY", 'Template name cannot be empty.'), GetTextByKey("P_IPT_SAVEAS", 'Save As'));
return;
}
name = htmlencode(name);
var p = JSON.stringify([teamintelligence, _this.template.Id, name]);
inspectionrequest("TemplateSaveAs", htmlencode(p), function (data) {
if (data !== 'OK')
showAlert(data, GetTextByKey("P_IPT_SAVEAS", 'Save As'));
else if (_this.templatemodule && typeof _this.templatemodule.refresh === "function")
_this.templatemodule.refresh();
dialog.hideDialog();
}, function (err) {
showAlert(GetTextByKey("P_IPT_FAILEDTOSAVEAS", 'Failed to save as.'), GetTextByKey("P_IPT_SAVEAS", 'Save As'));
});
};
return q;
});

View File

@ -0,0 +1,128 @@
define(['common'], function (Common) {
var dialogPicture = null;
var ls = function () {
};
ls.prototype.getDialogPicture = function () {
if (!dialogPicture)
dialogPicture = new $pictureselector();
return dialogPicture;
}
var $pictureselector = function () {
this.title = GetTextByKey("P_IPT_SELECTPICTURE", 'Select Picture');
this.companyId = null;
this.exceptSource = null;
this.onOK = null;
this.onDialogClosed = null;
};
(function () {
var __proto = $pictureselector.prototype;
function initGrid(parent) {
var grid = new GridView(parent);
var columns = [];
columns.push({
// checkbox
name: 'check',
key: 'Selected',
width: 30,
align: 'center',
sortable: false,
allcheck: true,
type: 3
});
columns.push({
key: 'Name',
caption: GetTextByKey("P_IPT_NAME", 'Name'),
width: 200
});
//grid.canMultiSelect = true;
grid.columns = columns;
grid.init();
this.gridctrl = grid;
}
function createDialog() {
var dialog = $('<div class="dialog" style="display: none; width: 602px; height: 380px;z-index:1;">');
var title = $('<div class="dialog-title"></div>').appendTo(dialog);
title.append($('<span class="title"></span>').text(this.title));
title.append('<em class="dialog-close"></em>');
var content = $('<div class="dialog-content"></div>').appendTo(dialog);
this.listdiv = $('<div style="width: 580px; height: 290px;margin-bottom:5px;"></div>').appendTo(content);
var dialogFunction = $('<div class="dialog-func"></div>').appendTo(dialog);
$('<input type="button" value="' + GetTextByKey("P_IPT_CANCEL", "Cancel") + '" class="dialog-close" />').appendTo(dialogFunction);
//$('<input type="button" value="' + GetTextByKey("P_IPT_COPY", "Copy") + '" />').click(onCopyClick.bind(this)).appendTo(dialogFunction);
$('<input type="button" value="' + GetTextByKey("P_IPT_ADDASLINK", "Add as Link") + '" />').click(onLinkClick.bind(this)).appendTo(dialogFunction);
$('<div class="clear"></div>').appendTo(dialogFunction);
$('<div class="maskbg" style="display: none;z-index:1;"><div class="loading_icon icon c-spin"></div></div>').appendTo(dialog);
// init
initGrid.call(this, this.listdiv);
$(document.body).append(dialog);
var mask = $('<div class="maskbg"></div>');
dialog.data('mask', mask);
dialog.before(mask);
var _this = this;
dialog.dialog(function () {
if (_this.onDialogClosed)
_this.onDialogClosed();
if (dialog.data('mask'))
dialog.data('mask').hide();
});
return dialog;
}
__proto.showSelector = function () {
if (!this.dialog) {
this.dialog = createDialog.call(this);
}
if (this.dialog.data('mask'))
this.dialog.data('mask').show();
this.dialog.showDialog(false);
this.gridctrl.setData([]);
showTemplatePictures.call(this);
};
function showTemplatePictures() {
//currenttemplate is defined in Inspection.aspx, it is a global variable
if (currenttemplate && currenttemplate.StaticPictures && currenttemplate.StaticPictures.length > 0) {
var items = [];
for (var i = 0; i < currenttemplate.StaticPictures.length; i++) {
var it = currenttemplate.StaticPictures[i];
it.Selected = false;
items.push({ Values: it });
}
this.gridctrl.setData(items);
}
}
function onCopyClick() {
//var index = this.gridctrl.selectedIndex;
this.onOK && this.onOK(this.gridctrl.source, true);
if (this.dialog.data('mask'))
this.dialog.data('mask').hide();
this.dialog.hideDialog();
}
function onLinkClick() {
//var index = this.gridctrl.selectedIndex;
this.onOK && this.onOK(this.gridctrl.source, false);
if (this.dialog.data('mask'))
this.dialog.data('mask').hide();
this.dialog.hideDialog();
}
})();
return ls;
});