Notes
Notes - notes.io |
var adminCollectionconfigureinvoiceparamPanel = 'cmscollectionsconfigureinvoiceparametersinvoiceparametersTabPanel';
var configureinvoiceparametersTabPanel;
var selectedconfigureInvoiceParametersTypeId;
var addconfigureInvoiceParametersType = 'Add';
var editconfigureInvoiceParametersType = 'Update';
var deleteconfigureInvoiceParametersType = 'Delete';
var storeValueCount = 0;
cms.collections.invoice.parameters.grid = null;
//==================================== Actions Grid fields ===========================
cms.collections.invoice.parameters.fieldsArray = [];
cms.collections.invoice.parameters.headerArray = [];
var accountLanguages = cms.common.init.getLanguagesMappedToAccount();
var temp = accountLanguages.rows
cms.collections.invoice.parameters.accountLanguages = temp;
var winWidth = 0.25 + (cms.collections.invoice.parameters.accountLanguages.length * 0.1);
cms.collections.invoice.parameters.dataTypeId = '20802';
var layoutList = dms.common.getLayoutsList(cms.collections.invoice.parameters.dataTypeId,true);
var fields = dms.common.getFields(1, cms.collections.invoice.parameters.dataTypeId);
console.log(fields);
var extraFields = [];
var headerArray = layoutList[1].split(",");
var gridConfig = {
singleSelect: false,
};
var headerMap = {};
for (var j = 0; j < headerArray.length; j++) {
for (var i = 0; i < fields.length; i++) {
var iArray = fields[i];
if (headerArray[j] == iArray[0]) {
headerMap[iArray[0]] = iArray[1];
}
}
}
winWidth += (3 * cms.collections.invoice.parameters.accountLanguages.length / 100);
Ext.each(cms.collections.invoice.parameters.accountLanguages, function(item) {
var language = item.split('::');
languageCode = language[2];
languageName = language[1];
temp = ['langVsTagCateogryName.' + languageCode, languageName + ' Display Name', 'string']
cms.collections.invoice.parameters.fieldsArray.push(temp);
cms.collections.invoice.parameters.headerArray.push('langVsTagCateogryName.' + languageCode);
});
for (var j = 0; j < cms.collections.invoice.parameters.headerArray.length; j++) {
for (var i = 0; i < cms.collections.invoice.parameters.fieldsArray.length; i++) {
var iArray = cms.collections.invoice.parameters.fieldsArray[i];
if (cms.collections.invoice.parameters.headerArray[j] == iArray[0]) {
headerMap[iArray[0]] = iArray[1];
}
}
}
console.log(headerMap);
console.log(cms.collections.invoice.parameters.headerArray);
console.log(cms.collections.invoice.parameters.fieldsArray);
for(let x in headerMap)
{
cms.collections.invoice.parameters.headerArray.push(headerMap[x]);
}
console.log(cms.collections.invoice.parameters.headerArray);
cms.collections.invoice.parameters.fieldsArray = cms.collections.invoice.parameters.fieldsArray.concat(fields);
console.log(cms.collections.invoice.parameters.fieldsArray);
var invoiceParamTabPanel;
cms.collections.invoice.parameters.invoiceparametersTabPanel = function(attributes) {
var gridConfig = {
singleSelect: false
};
cms.collections.invoice.parameters.store = dms.common.createStore('Count ', resolveCMSPath('getLanguageSpecificTagDetails.do'), cms.collections.invoice.parameters.fieldsArray, null, null, null, true, true, null, true);
// ============================= Invoice Parameters Grid =======================================
var buttonsArrayEmpty = [];
/* var headerMap = {};
for (var i = 0; i < cms.collections.invoice.parameters.fieldsArray.length; i++) {
var iArray = cms.collections.invoice.parameters.fieldsArray[i];
headerMap[iArray[0]] = iArray[1];
}*/
cms.collections.invoice.parameters.grid = dms.grid.component.createGridComponent('Count ', 'uniqueId',
cms.collections.invoice.parameters.store, cms.collections.invoice.parameters.fieldsArray,
cms.collections.invoice.parameters.headerArray, buttonsArrayEmpty, '{}', null);
//================================ On Select =====================================
cms.collections.invoice.parameters.grid.getSelectionModel().on('select', function() {
var length = cms.collections.invoice.parameters.grid.getSelectionModel().getCount();
if (length > 1) {
// Ext.ComponentQuery.query("#addInvoiceParamBtn")[0].disable();
Ext.ComponentQuery.query("#editInvoiceParamButton")[0].disable();
}
});
//================================ On DeSelect =====================================
cms.collections.invoice.parameters.grid.getSelectionModel().on('deselect', function() {
var length = cms.collections.invoice.parameters.grid.getSelectionModel().getCount();
if (length = 1) {
// Ext.ComponentQuery.query("#addInvoiceParamBtn")[0].enable();
Ext.ComponentQuery.query("#editInvoiceParamButton")[0].enable();
}
});
//================================ Panel Buttons =====================================
cms.collections.invoice.parameters.grid.getView().autoFill = true;
invoiceParamTabPanel = new Ext.TabPanel({
itemId: adminCollectioninvoiceparamPanel + '-panel',
autoid: 'cmsAdminInvoiceParamTabPanel',
activeTab: 0,
bodyCssClass: true,
border: false,
items: [{
title: common.i18n.getDisplayValue('CLS_ADMN_INV_PRM_CNFG', 'parameter Values'),
layout: 'fit',
tbar: [{
text: 'Add',
tooltip: 'Add',
iconCls: 'addDelete',
itemId: 'addInvoiceParamBtn',
autoid: 'cmsAddInvoiceParamBtn',
// actionIdentifier: dms.admin.tree.administrationDataTypeId + ":" + attributes.menuId + ":addDeleteTags",
handler: function() {
var getData = cms.collections.invoice.parameters.grid.getSelectionModel().getSelection();
cms.collections.invoice.parameters.addorDeleteInvoiceParameter(getData);
}
},
{
text: 'Update',
tooltip: 'Update',
iconCls: 'editded',
itemId: 'editInvoiceParamButton',
autoid: 'cmsEditInvoiceParamButton',
// actionIdentifier: dms.admin.tree.administrationDataTypeId + ":" + attributes.menuId + ":updateIPTags",
handler: function() {
var getData = cms.collections.invoice.parameters.grid.getSelectionModel().getSelection();
cms.collections.invoice.parameters.updateInvoiceParameter(getData);
}
},
{
text: 'Delete',
tooltip: 'Delete',
iconCls: 'deleteded',
itemId: 'deleteInvoiceParamButton',
autoid: 'cmsDeleteInvoiceParamButton',
// actionIdentifier: dms.admin.tree.administrationDataTypeId + ":" + attributes.menuId + ":deleteIPTags",
handler: function() {
var getData = cms.collections.invoice.parameters.grid.getSelectionModel().getSelection();
cms.collections.invoice.parameters.deleteInvoiceParameter(getData);
}
}
],
items: [cms.collections.invoice.parameters.grid]
}]
});
return invoiceParamTabPanel;
};
//------------------------------------Add---------------------------------------
cms.collections.invoice.parameters.addorDeleteInvoiceParameter= function(getData){
cms.collections.invoice.parameters.configItems = new Array();
var items = new Array();
storeValueCount =0;
var winTitle = "Configure values to drop-down editable fields";
var tagCategoryTypeStore = dms.common.getDropDownStore('tagCategory', collections.common.invoiceParametersConfigDataTypeID,'tagCategory');
tagCategoryTypeStore.load();
cms.collections.invoice.parameters.tagCategoryCombo = new Ext.form.field.ComboBox({
fieldLabel : 'Choose Editable DropDown Field'+'<span style="color:red;" ext:qtip="This field is required"> *</span>',
typeAhead: true,
triggerAction: 'all',
lazyRender:true,
queryMode: 'local',
store: tagCategoryTypeStore,
typeAhead : false,
editable:false,
valueField: 'value',
displayField: 'displayName',
style: "width:450px !important",
labelStyle : "font-weight:bold !important; width:150px !important;",
allowBlank : false,
listeners: {
afterrender: function () {
cms.collections.invoice.parameters.addTagCategoryDetailsListener(getData);
}
}
});
var vboxIV = {
height: 80,
itemId: 'addCategoryTypeComboVboxId',
id:'addCategoryTypeComboVboxId',
layout: 'hbox',
cls: 'expand-panel',
layoutConfig: {
align: 'stretch'
},
border:false,
items: [cms.collections.invoice.parameters.tagCategoryCombo]
};
var para = new Ext.form.TextField({
itemId : 'pa',
fieldLabel : 'Parameter name'+'<span style="color:red;" ext:qtip="This field is required"> *</span>',
maxLength : 250,
allowBlank : true,
style: "width:450px !important",
labelStyle : "font-weight:bold !important; width:150px !important;",
allowBlank : false,
}
);
var desc = new Ext.form.TextField({
itemId : 'dsc',
fieldLabel : 'Description',
maxLength : 250,
allowBlank : true,
style: "width:450px !important",
labelStyle : "font-weight:bold !important; width:150px !important;",
});
cms.collections.invoice.parameters.configItems.push(vboxIV);
cms.collections.invoice.parameters.configItems.push(para);
cms.collections.invoice.parameters.configItems.push(desc);
var languageTitle = new Ext.form.DisplayField({
fieldLabel : 'Language',
itemId : 'languageTitle',
frame : false,
cls: 'text-wrapper',
border : false,
labelStyle : "font-weight:bold !important;"
});
var enterValueTitle = new Ext.form.DisplayField({
fieldLabel : 'Enter Value'+'<span style="color:red;" ext:qtip="This field is required"> *</span>',
itemId : 'enterValueTitle',
frame : false,
cls: 'text-wrapper',
border : false,
labelStyle : "font-weight:bold !important;"
});
// var tagValueTitle = new Ext.form.DisplayField({
// fieldLabel : 'Values'+'<span style="color:red;" ext:qtip="This field is required"> *</span>',
// itemId : 'tagValueTitle',
// frame : false,
// cls: 'text-wrapper',
// border : false,
// labelStyle : "font-weight:bold !important;"
// });
var allTitleComponents = {
// height: 20,
itemId: 'allTitleComponents',
layout: 'vbox',
cls: 'expand-panel',
layoutConfig: {
align: 'stretch'
},
border:false,
items: [languageTitle,enterValueTitle]
};
items.push({items: [allTitleComponents]});
var pageNumber = 0;
Ext.each(cms.collections.invoice.parameters.accountLanguages, function(item){
var language = item.split('::');
pageNumber = language[0];
var languageDisplayField = new Ext.form.DisplayField({
//fieldLabel : name,
itemId : 'languageDisplayField'+pageNumber,
frame : false,
cls: 'text-wrapper',
border : false,
value : language[1],
style : 'font-weight:bold !important;',
labelStyle : "font-weight:bold !important;",
fieldStyle : "font-weight:bold !important;"
});
var enterValValue = new Ext.form.TextField({
width : '150px',
itemId : 'enterValValue'+pageNumber,
id : 'enterValValue-'+pageNumber,
maxLength : 250,
allowBlank : true
});
var tagValueStore = Ext.create('Ext.data.Store', {});
tagValueStore.setConfig('tagCount',0);
var tagValues = new Ext.form.field.Tag({
xtype: 'superboxselect',
name: 'tagValues',
width : '150px',
itemId : 'tagValues'+pageNumber,
id : 'tagValues-'+pageNumber,
displayField : 'displayName',
displayFieldTpl: '{displayName} ',
store : tagValueStore,
valueField : 'value',
backEndValue : '',
resizable: true,
forceSelection : true,
mode : 'remote',
overflow:'auto',
anchor:'100%',
hideTrigger:true,
tabIndex :-1,
selectOnFocus:false,
readOnly : pageNumber=='-1'?false:true,
allowBlank : pageNumber=='-1'?false:true,
listeners :{
beforedeselect : function(combo, record, index, eOpts){
Ext.each(cms.collections.invoice.parameters.accountLanguages, function(item){
var language = item.split('::');
var pageNumber = language[0];
if(pageNumber != '-1') {
var tagValuesComp = Ext.getCmp('tagValues-' +pageNumber);
var tagStoreItems = tagValuesComp.getStore().getData().items;
for(var item in tagStoreItems) {
if(record.data.value == tagStoreItems[item].data.value) {
var indexVal = tagValuesComp.getValue().indexOf(tagStoreItems[item].data.value);
if(indexVal != -1) {
tagValuesComp.getValue().splice(indexVal,1);
tagValuesComp.setValue(tagValuesComp.getValue().join(','));
}
tagValuesComp.fireEvent('select',tagValuesComp);
break;
}
}
}
});
}
}
});
var Page = Ext.create('Ext.panel.Panel', {
itemId: 'InvoiceParameterConfigPage'+pageNumber,
layout: 'anchor',
border:false,
defaults: {
anchor:'95%',
width: '200px'
},
items: [languageDisplayField,enterValValue]
});
items.push({items: [Page]});
});
// var addTagValuesButton = new Ext.button.Button({
// width : '100px',
// text : '+ Add',
// itemId : 'addTagValuesButton',
// handler : function() {
// cms.collections.invoice.parameters.addTagsToTagField();
// }
// });
// var addButtonPanel = Ext.create('Ext.panel.Panel', {
// itemId: 'addbuttonpanel',
// layout: 'anchor',
// border:false,
// defaults: {
// anchor:'95%',
// width: '200px'
// },
// items: [addTagValuesButton]
// });
// items.push({items: [addButtonPanel]});
var addInvoiceParameterConfig = {
// height: 20,
itemId: 'InvoiceParameterConfigHboxId'+pageNumber,
layout: 'hbox',
cls: 'expand-panel',
layoutConfig: {
align: 'stretch'
},
border:false,
items: items
};
cms.collections.invoice.parameters.configItems.push(addInvoiceParameterConfig);
var configPanel = new Ext.form.FormPanel({
standardSubmit: true,
frame: true,
monitorValid: true,
scrollable:true,
animCollapse: false,
bodyStyle: 'background-color:#fff;padding: 10px;margin-left: 5px;',
buttonAlign: 'center',
layout:'anchor',
cls: 'cls-window-invoiceParametersConfig',
autoScroll:true,
items:cms.collections.invoice.parameters.configItems,
buttons: [{
text: common.i18n.getDisplayValue('COMMON_MSG_SUBMIT','Submit'),
tooltip:common.i18n.getDisplayValue('COMMON_MSG_SUBMIT','Submit'),
cls: 'hrc-btn-primary',
itemId: 'AddInvoiceParameterConfigSaveButton',
formBind: true,
// var parameter = Ext.ComponentQuery.query('#pa')[0].getValue();
// var description = Ext.ComponentQuery.query('#dsc')[0].getValue();
handler: function () {
console.log(cms.collections.invoice.parameters.accountLanguages);
Ext.each(cms.collections.invoice.parameters.accountLanguages, function(item){
console.log(item);
})
}
},
{
text: common.i18n.getDisplayValue('COMMON_MSG_CANCEL','Cancel'),
cls: 'hrc-btn-tertiary hrc-btn-float-right',
handler: function () {
cms.collections.invoice.parameters.addorDeleteConfigWin.destroy();
}
}
],
keys: [
{ key: [Ext.event.Event.ENTER],
handler: function() {
// this.setDisabled(true);
// cms.collections.home.saveInvoiceParameters(idSuffix,editPanel,editableFields,selectedData,grid);
}
}
]
});
cms.collections.invoice.parameters.addorDeleteConfigWin = new Ext.Window( {
title : winTitle,
autoid:'cmsInvoiceParametersConfigWindow',
width : screen.width*winWidth,
//height : hboxIV.height + 120,
height:screen.height*.55,
minWidth:screen.width*.40,
minHeight:screen.height*0.4,
maxWidth:screen.width*0.90,
maxHeight:screen.height*0.75,
modal : true,
constrain : true,
layout : 'fit',
autoDestroy : false,
items : [configPanel],
listeners:{
afterrender:function(){
Ext.defer(function(){
window.scrollTo(this.x,this.y);
this.body.dom.scrollTop=0;
},100,this);
}
}
});
cms.collections.invoice.parameters.addorDeleteConfigWin.show();
};
cms.collections.invoice.parameters.addTagCategoryDetailsListener = function(getData){
cms.collections.invoice.parameters.tagCategoryCombo.getStore().load({
callback: function(records,options,success) {
if(success == true) {
if(null != getData && getData.length == 1 && getData[0].data.langVsTagCateogryName.en != null) {
for(var i in records){
var rec = records[i];
if(rec.data.displayName == getData[0].data.langVsTagCateogryName.en){
cms.collections.invoice.parameters.tagCategoryCombo.setValue(rec.data.value);
break;
}
}
}
}
}
});
cms.collections.invoice.parameters.tagCategoryCombo.on('change', function(combo,value) {
cms.collections.invoice.parameters.prepareFeedTagData(combo.getRawValue());
});
};
cms.collections.invoice.parameters.prepareFeedTagData = function(value){
var getData;
var data=cms.collections.invoice.parameters.grid.getStore().data.items;
for(var i in data) {
if(data[i].data.langVsTagCateogryName.en == value){
getData = data[i];
break;
}
}
if(null != getData) {
var i = 0, j = 0;
Ext.each(cms.collections.invoice.parameters.accountLanguages, function(item){
i = storeValueCount;
var language = item.split('::');
var languageId = language[0];
var languageCode = language[2];
var setTag = Ext.getCmp('tagValues-' +languageId);
setTag.clearValue();
for(var code in getData.data.langVsTagValue) {
if(languageCode === code) {
var selecteValues = [];
var valList = getData.data.langVsTagValue[code].split(',');
for(var val in valList) {
setTag.store.insert(setTag.store.tagCount+val,{value:i, displayName:valList[val]});
selecteValues.push(i);
i++;
}
setTag.setValue(selecteValues.join(','));
setTag.fireEvent('select',setTag);
setTag.store.setConfig('tagCount',setTag.store.tagCount+i);
}
}
if(i>j){
j = i;
}
});
storeValueCount = storeValueCount +j;
}
}
//=============================== Update Invoice Parameters ======================================
cms.collections.invoice.parameters.updateInvoiceParameter = function(getData){
storeValueCount =0;
cms.collections.invoice.parameters.configItems = new Array();
var items = new Array();
var storeValueCount =0;
var winTitle = "Configure values to drop-down editable fields";
var tagCategoryStore = dms.common.getDropDownStore('tagCategory', collections.common.invoiceParametersConfigDataTypeID,'tagCategory');
tagCategoryStore.load();
cms.collections.invoice.parameters.updatetagCategoryCombo = new Ext.form.field.ComboBox({
fieldLabel : 'Choose Editable DropDown Field'+'<span style="color:red;" ext:qtip="This field is required"> *</span>',
typeAhead: true,
triggerAction: 'all',
lazyRender:true,
queryMode: 'local',
store: tagCategoryStore,
typeAhead : false,
editable:false,
valueField: 'value',
displayField: 'displayName',
style: "width:450px !important",
labelStyle : "font-weight:bold !important; width:150px !important;",
allowBlank : false,
listeners :{
afterrender: function () {
cms.collections.invoice.parameters.updatetagCategoryCombo.getStore().reload({
callback: function(records,options,success) {
if(success == true) {
if(null != getData && getData.length == 1 && getData[0].data.langVsTagCateogryName.en != null) {
for(var i in records){
var rec = records[i];
if(rec.data.displayName == getData[0].data.langVsTagCateogryName.en){
cms.collections.invoice.parameters.updatetagCategoryCombo.setValue(rec.data.value);
break;
}
}
}
}
}
});
cms.collections.invoice.parameters.updatetagCategoryCombo.on('change', function(combo,value) {
cms.collections.invoice.parameters.prepareCMSTagStore(value);
});
}
}
});
var vboxIV = {
height: 80,
itemId: 'updateCategoryTypeComboVboxId',
layout: 'hbox',
cls: 'expand-panel',
layoutConfig: {
align: 'stretch'
},
border:false,
items: [cms.collections.invoice.parameters.updatetagCategoryCombo]
};
cms.collections.invoice.parameters.configItems.push(vboxIV);
var languageTitle = new Ext.form.DisplayField({
fieldLabel : 'Language',
itemId : 'languageTitle',
frame : false,
cls: 'text-wrapper',
border : false,
// value : 'Language',
labelStyle : "font-weight:bold !important;"
});
var chooseValueTitle = new Ext.form.DisplayField({
fieldLabel : 'Choose Value'+'<span style="color:red;" ext:qtip="This field is required"> *</span>',
itemId : 'chooseValueTitle',
frame : false,
cls: 'text-wrapper',
border : false,
// value : 'EnterValue',
labelStyle : "font-weight:bold !important;"
});
var newValueTitle = new Ext.form.DisplayField({
fieldLabel : 'New Value'+'<span style="color:red;" ext:qtip="This field is required"> *</span>',
itemId : 'newValueTitle',
frame : false,
cls: 'text-wrapper',
border : false,
// value : 'Values',
labelStyle : "font-weight:bold !important;"
});
var allTitleComponents = {
// height: 20,
itemId: 'allTitleComponents',
layout: 'vbox',
cls: 'expand-panel',
layoutConfig: {
align: 'stretch'
},
border:false,
defaults: {
width : '205px',
flex: 1,
border:false
},
items: [languageTitle,chooseValueTitle,newValueTitle]
};
items.push({items: [allTitleComponents]});
var pageNumber = 0;
Ext.each(cms.collections.invoice.parameters.accountLanguages, function(item){
var language = item.split('::');
pageNumber = language[0];
var languageDisplayField = new Ext.form.DisplayField({
//fieldLabel : name,
itemId : 'languageDisplayField'+pageNumber,
frame : false,
cls: 'text-wrapper',
border : false,
value : language[1],
fieldStyle : "font-weight:bold !important;"
});
if(pageNumber=='-1') {
var fields = new Array('pkCmsTagId' , 'name');
var cmsTagCombo;
cms.collections.invoice.parameters.cmsTagStore = dms.common.createStore('pkCmsTagId', resolveCMSPath('getCmsTagByCategoryId.do'),fields,null,null,null,null,true,null,true);
cms.collections.invoice.parameters.cmsTagLangStore = Ext.create('Ext.data.Store', {});
cmsTagCombo = new Ext.form.field.ComboBox({
// fieldLabel : 'Choose Editable DropDown Field'+'<span style="color:red;" ext:qtip="This field is required"> * </span>',
itemId : 'cmsTagCombo-'+pageNumber,
id : 'cmsTagCombo-'+pageNumber,
name : 'cmsTagCombo'+pageNumber,
typeAhead: true,
minChars : 1,
width : '150px',
lazyRender:true,
queryMode: 'local',
store: cms.collections.invoice.parameters.cmsTagStore,
typeAhead : false,
editable:false,
queryMode : 'remote',
singleSelect : true,
plugins: ['remotetolocalcombo'],
valueField: pageNumber=='-1'?'pkCmsTagId':'pkCmsTagLang',
displayField: 'name',
hideTrigger:pageNumber=='-1'?false:true,
labelStyle : "font-weight:bold;",
listeners :{
change : function(field,record,v){
cms.collections.invoice.parameters.prepareCMSTagLangStore(record);
}
}
});
} else {
cmsTagCombo = new Ext.form.TextField({
width : '150px',
itemId : 'cmsTagCombo-'+pageNumber,
id : 'cmsTagCombo-'+pageNumber,
maxLength : 250,
readOnly : true,
tabIndex: -1
});
}
var newTagValue = new Ext.form.TextField({
width : '150px',
itemId : 'newTagValue-'+pageNumber,
id : 'newTagValue-'+pageNumber,
maxLength : 250,
allowBlank :pageNumber=='-1'?false:true
});
var Page = Ext.create('Ext.panel.Panel', {
itemId: 'InvoiceParameterConfigPage'+pageNumber,
layout: 'anchor',
border:false,
defaults: {
anchor:'95%',
width: '200px'
},
items: [languageDisplayField,cmsTagCombo,newTagValue]
});
items.push({items: [Page]});
});
var addInvoiceParameterConfig = {
// height: 20,
itemId: 'InvoiceParameterConfigHboxId'+pageNumber,
layout: 'hbox',
cls: 'expand-panel',
layoutConfig: {
align: 'stretch'
},
border:false,
items: items
};
cms.collections.invoice.parameters.configItems.push(addInvoiceParameterConfig);
var configPanel = new Ext.form.FormPanel({
standardSubmit: true,
frame: true,
monitorValid: true,
scrollable:true,
animCollapse: false,
bodyStyle: 'background-color:#fff;padding: 10px;margin-left: 5px;',
buttonAlign: 'center',
cls: 'cls-window-invoiceParametersConfig',
layout:'anchor',
autoScroll:true,
items: cms.collections.invoice.parameters.configItems,
listeners: {
},
buttons: [{
text: common.i18n.getDisplayValue('COMMON_MSG_SUBMIT','Submit'),
tooltip:common.i18n.getDisplayValue('COMMON_MSG_SUBMIT','Submit'),
cls: 'hrc-btn-primary',
itemId: 'InvoiceParameterConfigSaveButton',
id: 'InvoiceParameterConfigSaveButton',
formBind: true,
handler: function () {
this.setDisabled(true);
var isBreak = cms.collections.invoice.parameters.checkForDuplicateTags();
if(isBreak){
return;
}
var query = {};
var URL = resolveCMSPath('updateInvoiceParametersTags.do');
Ext.each(cms.collections.invoice.parameters.accountLanguages, function(item){
var language = item.split('::');
pageNumber = language[0];
var newTag = Ext.getCmp('newTagValue-' +pageNumber).getRawValue();
if(newTag != undefined && newTag != '')
query[language[0]] = newTag;
});
query = dms.common.formNestedMap(query);
if(Ext.encode(query)== '{}'){
// cms.collections.home.addorEditCustomerWin.destroy();
} else {
Ext.Ajax.request({
url: URL,
method: 'POST',
params: {
tagId : Ext.getCmp('cmsTagCombo--1').getValue(),
query: Ext.encode(query)
},
success : function(response, opts) {
var responseTxt = Ext.decode(response.responseText);
var message = responseTxt.msg;
var success = responseTxt.success;
if(success && message.trim()=='success'){
cms.collections.invoice.parameters.grid.getStore().reload({
callback : function(r, options,success) {
Ext.example.msg('', common.i18n.getDisplayValue('ADM_CLS_IP_SUCCS_MSG','Changes saved successfully'));
if (success != true) {
Ext.Msg.alert(common.i18n.getDisplayValue('COMMON_MSG_INFO','Info'),common.i18n.getDisplayValue('ADM_CLS_IP_FAIL_MSG','Failed to save the changes'));
return;
}
}
});
cms.collections.invoice.parameters.updateConfigWin.destroy();
}else if (success && message.trim()) {
this.setDisabled(false);
Ext.Msg.alert(common.i18n.getDisplayValue('COMMON_MSG_WARNING','Warning'), message.trim());
}
else {
this.setDisabled(false);
Ext.example.msg(common.i18n.getDisplayValue('COMMON_MSG_ERROR','ERROR'),common.i18n.getDisplayValue('CLS_WL_OI_UPT_FAIL','Failed to update invoice(s)'));
}
}
});
}
}
},
{
text: common.i18n.getDisplayValue('COMMON_MSG_CANCEL','Cancel'),
cls: 'hrc-btn-tertiary hrc-btn-float-right',
handler: function () {
cms.collections.invoice.parameters.updateConfigWin.destroy();
}
}
],
keys: [
{ key: [Ext.event.Event.ENTER],
handler: function() {
// this.setDisabled(true);
// cms.collections.home.saveInvoiceParameters(idSuffix,editPanel,editableFields,selectedData,grid);
}
}
]
});
cms.collections.invoice.parameters.updateConfigWin = new Ext.Window( {
title : winTitle,
autoid:'updatecmsInvoiceParametersConfigWindow',
width : screen.width*winWidth,
// width : screen.height*.70,
//height : hboxIV.height + 120,
height:screen.height*.55,
minWidth:screen.width*.40,
minHeight:screen.height*0.3,
maxWidth:screen.width*0.90,
maxHeight:screen.height*0.75,
modal : true,
constrain : true,
layout : 'fit',
autoDestroy : false,
items : [configPanel],
listeners:{
afterrender:function(){
Ext.defer(function(){
window.scrollTo(this.x,this.y);
this.body.dom.scrollTop=0;
},100,this);
}
}
});
cms.collections.invoice.parameters.updateConfigWin.show();
};
cms.collections.invoice.parameters.addTagsToTagField = function(){
var isBreak = false;
var getData;
var comboValue = cms.collections.invoice.parameters.tagCategoryCombo.getRawValue();
var data=cms.collections.invoice.parameters.grid.getStore().data.items;
for(var i in data) {
if(data[i].data.langVsTagCateogryName.en == comboValue){
getData = data[i];
break;
}
}
Ext.each(cms.collections.invoice.parameters.accountLanguages, function(item){
var language = item.split('::');
var languageId = language[0];
var languageCode = language[2];
var tagValue = Ext.getCmp('enterValValue-'+languageId).getRawValue();
if(tagValue == undefined || tagValue == null || tagValue == '') {
Ext.Msg.alert(common.i18n.getDisplayValue('COMMON_MSG_INFO','Info'),common.i18n.getDisplayValue('ADM_CLS_IP_MAND_TAG','All the languages are mandatory'));
return;
}
var langVar = 'langVsTagValue.'+languageCode;
if(getData.data[langVar] != null && getData.data[langVar] != '') {
var tagRawValue = getData.data[langVar].split(',');
for(var i in tagRawValue) {
if(tagRawValue[i].trim().toUpperCase() == tagValue.trim().toUpperCase()){
Ext.Msg.alert(common.i18n.getDisplayValue('COMMON_MSG_WARNING','Warning'),'Found duplicate tag value '+tagValue);
isBreak = true;
break;
}
}
}
});
if(isBreak) {
return;
}
storeValueCount = storeValueCount+1;
Ext.each(cms.collections.invoice.parameters.accountLanguages, function(item){
var language = item.split('::');
var languageId = language[0];
var tagCombo = Ext.getCmp('tagValues-'+languageId);
var tagValue = Ext.getCmp('enterValValue-'+languageId).getRawValue();
if(tagValue != undefined && tagValue != '') {
tagCombo.store.insert(storeValueCount,{value:storeValueCount, displayName:tagValue});
var preTagValues = tagCombo.getValue();
preTagValues.push(storeValueCount);
tagCombo.setValue(preTagValues);
tagCombo.fireEvent("select", tagCombo);
}
Ext.getCmp('enterValValue-'+languageId).setValue("");
});
};
cms.collections.invoice.parameters.checkForDuplicateTags = function(){
var getData;
var comboValue = cms.collections.invoice.parameters.updatetagCategoryCombo.getRawValue();
var data=cms.collections.invoice.parameters.grid.getStore().data.items;
for(var i in data) {
if(data[i].data.langVsTagCateogryName.en == comboValue){
getData = data[i];
break;
}
}
var isBreak = false;
Ext.each(cms.collections.invoice.parameters.accountLanguages, function(item){
var language = item.split('::');
pageNumber = language[0];
var languageCode = language[2];
var newTag = Ext.getCmp('newTagValue-' +pageNumber).getRawValue();
var oldTag = Ext.getCmp('cmsTagCombo-' +pageNumber).getRawValue();
var langVar = 'langVsTagValue.'+languageCode;
if(getData.data[langVar] != null && getData.data[langVar] != '') {
var tagRawValue = getData.data[langVar].split(',');
for(var i in tagRawValue) {
if(tagRawValue[i].trim().toUpperCase() == newTag.trim().toUpperCase() && newTag.trim().toUpperCase() != oldTag.trim().toUpperCase()){
Ext.Msg.alert(common.i18n.getDisplayValue('COMMON_MSG_WARNING','Warning'),'Found duplicate tag value '+newTag);
Ext.getCmp('InvoiceParameterConfigSaveButton').setDisabled(false);
isBreak = true;
break;
}
}
}
});
return isBreak;
};
cms.collections.invoice.parameters.prepareCMSTagStore = function(categoryId) {
var cmsTagCombo = Ext.getCmp('cmsTagCombo--1');
if(cmsTagCombo != null) {
cmsTagCombo.setValue();
cmsTagCombo.getStore().proxy.setExtraParam('tagCategoryId',categoryId);
cmsTagCombo.getStore().load();
}
};
cms.collections.invoice.parameters.prepareCMSTagLangStore = function(tagId) {
Ext.each(cms.collections.invoice.parameters.accountLanguages, function(item){
//clearing up the language fields
var language = item.split('::');
var languageId = language[0];
if(languageId !== '-1')
Ext.getCmp('cmsTagCombo-'+languageId).setValue();
});
if(tagId != null) {
var cmsTagData = Ext.getCmp('cmsTagCombo--1').getStore().getData().items;
var tagLangData = [];
if(cmsTagData != null) {
for(var i = 0; i < cmsTagData.length; i++) {
if(cmsTagData[i].data.pkCmsTagId == tagId) {
tagLangData = cmsTagData[i].data.cmsTagLang;
break;
}
}
for(var j = 0; j < tagLangData.length; j++) {
if(tagLangData[j].fkLanguageId != '-1') {
var tagLangCmp = Ext.getCmp('cmsTagCombo-'+tagLangData[j].fkLanguageId);
if(tagLangCmp != undefined) {
tagLangCmp.setValue(tagLangData[j].name);
}
}
}
}
}
};
// ---------------------------------------------- Delete Window ----------------------------//
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team