Created
April 3, 2019 08:05
-
-
Save icodebetter/f351f2780714964aee66794b655b972d to your computer and use it in GitHub Desktop.
wsForm Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iwb.ui.buildRESTForm = function (getForm, callAttributes, _page_tab_id) { | |
var extDef = getForm.render(); | |
var extraItems = | |
!getForm.renderTip || getForm.renderTip != 3 | |
? extDef.items | |
: extDef.items[0].items; | |
var realAction = 1 * extDef.baseParams.a; | |
var btn = []; | |
if (!getForm.viewMode && extDef.url) { | |
var sv_btn_visible = extDef.baseParams.sv_btn_visible || 1; | |
if (sv_btn_visible * 1 == 1) { | |
var saveBtn = { | |
text: getForm.labelAction || "Action",// + ' | |
// '+getForm.name, | |
id: "sb_" + getForm.id, | |
iconAlign: "top", | |
scale: "medium", | |
// style: {margin: "0px 5px 0px 5px"}, | |
iconCls: "ikaydet", | |
handler: function (a, b, c) { | |
var r = null; | |
// manuel validation | |
var bm = false; | |
if (extDef.componentWillPost || bm) { | |
if (getForm._cfg.formPanel.getForm().isValid()) { | |
var vals = getForm._cfg.formPanel.getForm().getValues(); | |
if (extDef.componentWillPost) { | |
r = extDef.componentWillPost(vals); | |
if (!r) return; | |
} | |
} else { | |
getForm._cfg.formPanel.getForm().findInvalid(); | |
return; | |
} | |
} | |
if (!getForm._cfg.formPanel.getForm().isValid()) { | |
getForm._cfg.formPanel.getForm().findInvalid(); | |
return null; | |
} | |
getForm._cfg.dontClose = 0; | |
getForm._cfg.extraParams = {}; | |
if (typeof r == "object" && r != null) getForm._cfg.extraParams = r; | |
formSubmit(getForm._cfg); | |
} | |
}; | |
btn.push(saveBtn); | |
} | |
// post & continue | |
if (getForm.contFlag && 1 * getForm.contFlag == 1 && realAction == 2) { | |
btn.push({ | |
text: "Action&Continue".toUpperCase(), | |
id: "cc_" + getForm.id, | |
iconAlign: "top", | |
scale: "medium", | |
iconCls: "isave_cont", | |
handler: function (a, b, c) { | |
if ( | |
!getForm._cfg.formPanel.getForm().isDirty() && | |
!confirm("${attention_you_save_without_change_are_you_sure}") | |
) | |
return; | |
var r = null; | |
if (extDef.componentWillPost) { | |
if (getForm._cfg.formPanel.getForm().isValid()) { | |
r = extDef.componentWillPost( | |
getForm._cfg.formPanel.getForm().getValues() | |
); | |
if (!r) return; | |
} else { | |
getForm._cfg.formPanel.getForm().findInvalid(); | |
return; | |
} | |
} | |
if (!getForm._cfg.formPanel.getForm().isValid()) { | |
getForm._cfg.formPanel.getForm().findInvalid(); | |
return null; | |
} | |
if (!getForm._cfg.callback) | |
getForm._cfg.callback = function (js, conf) { | |
if (js.success) Ext.infoMsg.msg("info", "${operation_completed}"); | |
}; | |
getForm._cfg.dontClose = 1; | |
getForm._cfg.extraParams = {}; | |
if (typeof r == "object" && r != null) getForm._cfg.extraParams = r; | |
form_extra_processes(); | |
formSubmit(getForm._cfg); | |
} | |
}); | |
} | |
} | |
// close | |
if (_app.show_close_button) btn.push({ | |
tooltip: "Close", | |
id: "cl_" + getForm.id, | |
iconAlign: "top", | |
scale: "medium", | |
iconCls: "ikapat", | |
handler: function (a, b, c) { | |
function closeMe() { | |
if (!callAttributes.modalWindowFlag) mainPanel.getActiveTab().destroy(); | |
else mainPanel.closeModalWindow(); | |
} | |
if ( | |
!getForm.viewMode && | |
1 * _app.form_cancel_dirty_control && | |
getForm._cfg.formPanel.getForm().isDirty() | |
) | |
Ext.infoMsg.confirm( | |
"There are changed fields. Do you still want to close?", | |
() => { | |
closeMe(); | |
} | |
); | |
else closeMe(); | |
} | |
}); | |
if (getForm.extraButtons && getForm.extraButtons.length > 0) { | |
btn.push("-"); | |
btn.push(getForm.extraButtons); | |
} | |
btn.push("->"); | |
btn.push({ | |
tooltip: "Templates", | |
id: "ttemp_" + getForm.id, | |
iconAlign: "top", | |
scale: "medium", | |
// style: {margin: "0px 5px 0px 5px"}, | |
iconCls: "ibookmark", | |
handler: function (a, b, c) { | |
if (!getForm._loaded) { | |
getForm._loaded = true; | |
promisRequest({ | |
url: "ajaxQueryData?_qid=483", | |
params: { | |
xform_id: getForm.formId | |
}, | |
successCallback: function (j) { | |
if (j.success && j.data.length > 0) { | |
while (a.menu.items.items.length > 2) a.menu.remove(2); | |
a.menu.add("-"); | |
var pf = true; | |
for (var q = 0; q < j.data.length; q++) { | |
if (j.data[q].public_flag && pf) { | |
if (q > 0) a.menu.add("-"); | |
pf = false; | |
} | |
a.menu.add({ | |
text: j.data[q].dsc, | |
_id: j.data[q].form_value_id, | |
handler: function (a, b, c) { | |
promisRequest({ | |
url: "ajaxQueryData?_qid=503", | |
params: { | |
xform_value_id: a._id | |
}, | |
successCallback: function (j2) { | |
if (j2.success && j2.data.length > 0) { | |
var f2 = getForm._cfg.formPanel.getForm(); | |
var j3 = {}; | |
for (var q2 = 0; q2 < j2.data.length; q2++) { | |
j3[j2.data[q2].dsc] = j2.data[q2].val; | |
} | |
f2.setValues(j3); | |
} | |
} | |
}); | |
} | |
}); | |
} | |
} | |
} | |
}); | |
} | |
}, | |
menu: { | |
items: [ | |
{ | |
text: "Save these values", | |
iconCls: "icon-ekle", | |
handler: function (a, b, c) { | |
var p = prompt("Template Name", ""); | |
if (p) { | |
var params = getForm._cfg.formPanel.getForm().getValues(); | |
params._dsc = p; | |
promisRequest({ | |
url: "ajaxBookmarkForm?_fid=" + getForm.formId, | |
params: params, | |
successCallback: function () { | |
getForm._loaded = false; | |
Ext.infoMsg.alert("success", "saved"); | |
} | |
}); | |
} | |
} | |
}, | |
{ | |
text: "Edit Templates", | |
iconCls: "icon-duzenle", | |
handler: function (a, b, c) { | |
mainPanel.loadTab({ | |
attributes: { | |
_title_: getForm.name, | |
modalWindow: true, | |
href: "showPage?_tid=259&_gid1=491", | |
_pk: { | |
tform_value_id: "form_value_id" | |
}, | |
baseParams: { | |
xform_id: getForm.formId | |
} | |
} | |
}); | |
} | |
} | |
] | |
} | |
}); | |
if (_scd.customizationId == 0) { | |
// btn.push("-"); | |
var menuItems = []; | |
if (_scd.administratorFlag) { | |
menuItems.push({ | |
text: "Field Settings", | |
handler: function (a, b, c) { | |
mainPanel.loadTab({ | |
attributes: { | |
_title_: getForm.name, | |
_width_: 600, | |
modalWindow: true, | |
href: | |
"showPage?_tid=543&_gid1=439&_fid2=997&a=1&tform_id=" + | |
getForm.formId, | |
_pk1: { | |
tform_cell_id: "form_cell_id" | |
}, | |
baseParams: { | |
xform_id: getForm.formId | |
} | |
} | |
}); | |
} | |
}); | |
if ( | |
(_app.mail_flag && 1 * _app.mail_flag) || | |
(_app.sms_flag && 1 * _app.sms_flag) | |
) | |
menuItems.push({ | |
text: | |
"SMS/E-MAIL Settings" + | |
(getForm.smsMailTemplateCnt | |
? " (" + getForm.smsMailTemplateCnt + ")" | |
: ""), | |
handler: function (a, b, c) { | |
mainPanel.loadTab({ | |
attributes: { | |
_title_: getForm.name, | |
modalWindow: true, | |
href: "showPage?_tid=259&_gid1=1294", | |
_pk: { | |
tform_sms_mail_id: "form_sms_mail_id" | |
}, | |
baseParams: { | |
xform_id: getForm.formId, | |
xtable_id: getForm.crudTableId || "" | |
} | |
} | |
}); | |
} | |
}); | |
if (_app.form_conversion_flag && 1 * _app.form_conversion_flag) | |
menuItems.push({ | |
text: | |
"Conversions" + | |
(getForm.conversionCnt ? " (" + getForm.conversionCnt + ")" : ""), | |
handler: function (a, b, c) { | |
mainPanel.loadTab({ | |
attributes: { | |
_title_: getForm.name, | |
modalWindow: true, | |
href: "showPage?_tid=259&_gid1=1344", | |
_pk: { | |
tconversion_id: "conversion_id" | |
}, | |
baseParams: { | |
xsrc_form_id: getForm.formId, | |
xtable_id: getForm.crudTableId || "" | |
} | |
} | |
}); | |
} | |
}); | |
} | |
if (_scd.administratorFlag) { | |
menuItems.push("-", { | |
text: "Form Hints", | |
handler: function (a, b, c) { | |
mainPanel.loadTab({ | |
attributes: { | |
_title_: getForm.name, | |
modalWindow: true, | |
href: "showPage?_tid=259&_gid1=1700", | |
_pk: { | |
tform_hint_id: "form_hint_id" | |
}, | |
baseParams: { | |
xform_id: getForm.formId | |
} | |
} | |
}); | |
} | |
}); | |
} | |
btn.push({ | |
tooltip: "Settings", | |
id: "fs_" + getForm.id, | |
iconAlign: "top", | |
scale: "medium", | |
// style: {margin: "0px 5px 0px 5px"}, | |
iconCls: "isettings", | |
menu: { | |
items: menuItems | |
} | |
}); | |
} | |
var iconCls = getForm.a == 1 ? "icon-edit" : "icon-new"; | |
var o = { | |
autoScroll: true, | |
border: false, | |
tbar: btn, | |
// bodyStyle: "padding:3px;", | |
iconCls: callAttributes.iconCls || iconCls, | |
_title_: callAttributes.title || "Form: " + getForm.name, | |
_width_: getForm.defaultWidth, | |
_height_: getForm.defaultHeight | |
}; | |
if (!callAttributes.modalWindowFlag) { | |
o = Ext.apply({ closable: true, title: getForm.name }, o); | |
} | |
if (getForm.hmsgs) { | |
var hints = getForm.hmsgs; | |
for (var qs = hints.length - 1; qs >= 0; qs--) { | |
var icn = ""; | |
switch (hints[qs].tip * 1) { | |
case 1: | |
icn = "information"; | |
break; | |
case 2: | |
icn = "warning"; | |
break; | |
case 3: | |
icn = "error"; | |
break; | |
} | |
var lbl = new Ext.form.Label({ | |
hideLabel: true, | |
html: hints[qs].text, | |
cls: icn | |
}); | |
extDef.items.unshift({ | |
xtype: "fieldset", | |
title: "", | |
cls: "xform-hint", | |
labelWidth: 0, | |
bodyStyle: | |
"padding:none !important;background-color:" + hints[qs].color + ";", | |
items: [lbl] | |
}); | |
} | |
} | |
if (_app.form_msgs_visible_on_form * 1 == 1 && getForm.msgs) { | |
var lbl = new Ext.form.Label({ | |
hideLabel: true, | |
html: getForm.msgs.join("<br>"), | |
cls: "information" | |
}); | |
extDef.items.unshift({ | |
xtype: "fieldset", | |
cls: "xform-hint", | |
title: "", | |
labelWidth: 0, | |
// bodyStyle: 'background-color:#FFF8C6;', | |
items: [lbl] | |
}); | |
} | |
var p = new Ext.FormPanel(Ext.apply(o, extDef)); | |
if (!getForm._cfg) getForm._cfg = {}; | |
getForm._cfg.formPanel = p; | |
getForm._cfg._callAttributes = callAttributes; | |
if (_app.form_msgs_visible_on_form * 1 != 1 && getForm.msgs) | |
Ext.infoMsg.msg("info", getForm.msgs.join("<br>"), 3); | |
if ( | |
_app.live_sync_record && | |
1 * _app.live_sync_record != 0 && | |
extDef.baseParams[".t"] | |
) { | |
p._l = { | |
pk: 1 * getForm.a == 1 ? getForm.crudTableId + "-" + pk : false | |
}; | |
} | |
return p; | |
}; | |
return iwb.ui.buildRESTForm(getForm, callAttributes, _page_tab_id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment