diff --git a/js/app/views/FiltersUI.js b/js/app/views/FiltersUI.js index a2c8d4e..7143bb4 100644 --- a/js/app/views/FiltersUI.js +++ b/js/app/views/FiltersUI.js @@ -9,7 +9,7 @@ ******************************************************************************** * FT Id : Date : Name - Description ******************************************************************************* - * : + * : */ /* @@ -19,41 +19,41 @@ Ext.define('amdaUI.FilterGridPanel', { extend : 'Ext.grid.Panel', alias : 'widget.gridFilter', - + filtersInfoStore : null, filtersListStore : null, - + selectListStore : null, crtFilter : null, - + opStore : null, condStore : null, - + groupingFeature : null, valueColumn : null, - + groupMenu : null, itemMenu : null, - - constructor: function(config) - { + + constructor: function(config) + { this.init(config); this.callParent(arguments); }, - + setFiltersInfoStore: function(infoStore) { this.filtersInfoStore = infoStore; }, - + setFiltersListStore: function(listStore) { this.filtersListStore = listStore; }, - + setConditions : function(record) { - this.editingPlugin.completeEdit(); + this.editingPlugin.completeEdit(); this.crtFilter = record; this.reconfigure(record.conditions()); this.store.groupField = 'type'; @@ -61,59 +61,59 @@ Ext.define('amdaUI.FilterGridPanel', { if (record.conditions().getCount() > 0) this.getSelectionModel().select(record.conditions().getAt(0)); }, - + setConditionType : function(condType,condInfo,reset) { if (!condInfo) return; - + //update current conditions types store this.condStore.removeAll(); - + this.filtersInfoStore.getById(condType).conditions().data.each(function(cond) { this.condStore.add(cond); }, this ); - + //update current operators store this.opStore.removeAll(); - + condInfo.ops().data.each(function(op) { this.opStore.add({id : op.get('id'), name : op.get('name')}); }, this ); - + //update current value field var valueField = this.getValueField(condInfo); - this.editingPlugin.completeEdit(); + this.editingPlugin.completeEdit(); this.editingPlugin.setColumnField(this.columns[3],valueField); - + //get current cell var crtCell; - if (this.getSelectionModel().hasSelection()) { - crtCell = this.getSelectionModel().getSelection()[0]; + if (this.getSelectionModel().hasSelection()) { + crtCell = this.getSelectionModel().getSelection()[0]; } else - return; + return; crtCell.set('condId',condInfo.get('id')); - + if (reset) - { + { //set first operator crtCell.set('opId',this.opStore.getAt(0).get('id')); - + //reset value field switch (valueField.xtype) { - case 'combobox' : + case 'combobox' : crtCell.set('value',valueField.store.getAt(0).get('name')); break; case 'datefield' : - var date = new Date(); + var date = new Date(); crtCell.set('value',date); break; default : @@ -121,7 +121,7 @@ Ext.define('amdaUI.FilterGridPanel', { } } }, - + getValueField : function(condInfo) { //get field type in relation with the condition @@ -130,21 +130,21 @@ Ext.define('amdaUI.FilterGridPanel', { case 'select' : if (!this.filtersListStore.getById(condInfo.get('selectList'))) console.log('Error - Missing select list definition for '+condInfo.get('selectList')); - else { + else { // to avoid an attempt to load remotely association store in combobox - it is already here! var store2 = new Ext.data.Store({model : 'amdaModel.FilterSelectListElt'}); - + this.filtersListStore.getById(condInfo.get('selectList')).elems().each(function(record){ store2.add(record.copy()); - }); - + }); + return { xtype : 'combobox', queryMode: 'local', editable: false, displayField:'name', valueField : 'id', - store : store2 + store : store2 }; } case 'date' : @@ -159,23 +159,23 @@ Ext.define('amdaUI.FilterGridPanel', { }; } - + // console.log('Error - Missing value field definition for '+condInfo.get('type')); return { xtype : 'textfield' }; }, - + createCondition : function(group) { var rec = Ext.create('amdaModel.FilterDefCond',{ type : group, logical : 'and' }); - + return rec; }, - + onAddCondition : function(t) { var crtGroup = t.parentMenu.crtGroup; @@ -187,7 +187,7 @@ Ext.define('amdaUI.FilterGridPanel', { this.store.each(function(cond) { if (cond.get('type') == crtGroup) - maxIndex = (maxIndex < cond.get('index')) ? cond.get('index') : maxIndex; + maxIndex = (maxIndex < cond.get('index')) ? cond.get('index') : maxIndex; },this); rec.set('index',maxIndex+1); this.store.add(rec); @@ -196,7 +196,7 @@ Ext.define('amdaUI.FilterGridPanel', { this.getSelectionModel().select(rec); this.setConditionType(crtGroup,firstCond, true); }, - + onInsertCondition : function(t) { if (this.getSelectionModel().hasSelection()) @@ -218,7 +218,7 @@ Ext.define('amdaUI.FilterGridPanel', { this.setConditionType(crtRec.get('type'),firstCond, true); } }, - + onDeleteCondition : function(t) { if (this.getSelectionModel().hasSelection()) @@ -229,7 +229,7 @@ Ext.define('amdaUI.FilterGridPanel', { this.store.group('type'); }; }, - + onClearGroupConditions : function(t) { var crtGroup = t.parentMenu.crtGroup; @@ -243,17 +243,17 @@ Ext.define('amdaUI.FilterGridPanel', { if (rec.get('index') == -1) return; this.store.remove(rec); - },this); + },this); this.store.group('type'); }, - + onClearAllConditions : function(t) - { + { var recs = this.store.getGroups(); if (!recs) return; Ext.each(recs, function (group) - { + { Ext.each(group.children, function (rec) { if (rec.get('index') == -1) @@ -264,47 +264,47 @@ Ext.define('amdaUI.FilterGridPanel', { this); this.store.group('type'); }, - + onSelectConditionType : function(combo,records,eOpts) { if (!records || (records.length != 1)) return; this.setConditionType(records[0].getFilter().get('id'),records[0],true); }, - + createCellEditingPlugin : function() { var cellPlug = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 2, listeners: { - beforeedit: function(o, el, opt) { + beforeedit: function(o, el, opt) { if ((el.field == 'logical') && (el.record.get('index') <= 0)) return false; return true; } } - }); - + }); + return cellPlug; }, - + createOperatorStore : function() { this.opStore = Ext.create('Ext.data.Store',{model: 'amdaModel.FilterOpInfo'}); return this.opStore; }, - + createFilterCondInfoStore : function() { this.condStore = Ext.create('Ext.data.Store',{model: 'amdaModel.FilterConditionInfo'}); return this.condStore; }, - + createLogicalColumn : function() { return { - header: '', - dataIndex: 'logical', + header: '', + dataIndex: 'logical', flex: 1, allowBlank : false, renderer: function(value,metaData,record,rowIndex,colIndex,store,view) @@ -322,18 +322,18 @@ Ext.define('amdaUI.FilterGridPanel', { } }; }, - + createTypeColumn : function() { - return { - header: 'Type', - dataIndex: 'condId', + return { + header: 'Type', + dataIndex: 'condId', flex: 3, allowBlank : false, renderer: function(value,metaData,record,rowIndex,colIndex,store,view) { var crtType = record.get('type'); - var conditions = this.filtersInfoStore.getById(crtType).conditions(); + var conditions = this.filtersInfoStore.getById(crtType).conditions(); var condition = conditions.getById(record.get('condId')); if (condition) return condition.get('name'); @@ -354,21 +354,21 @@ Ext.define('amdaUI.FilterGridPanel', { 'select': this.onSelectConditionType } } - }; + }; }, - + createOperatorColumn : function() { - return { - header: '', - dataIndex: 'opId', + return { + header: '', + dataIndex: 'opId', flex: 1, allowBlank : false, renderer: function(value,metaData,record,rowIndex,colIndex,store,view) { var crtType = record.get('type'); var conditions = this.filtersInfoStore.getById(crtType).conditions(); - + var condition = conditions.getById(record.get('condId')); if (!condition || !condition.ops().getById(record.get('opId'))) return ''; @@ -383,21 +383,21 @@ Ext.define('amdaUI.FilterGridPanel', { valueField : 'id', store : this.createOperatorStore() } - + }; }, - + createValueColumn : function() { - return { - header: 'Value', - dataIndex: 'value', + return { + header: 'Value', + dataIndex: 'value', flex: 3, renderer: function(value,metaData,record,rowIndex,colIndex,store,view) { var crtType = record.get('type'); var conditions = this.filtersInfoStore.getById(crtType).conditions(); - var condition = conditions.getById(record.get('condId')); + var condition = conditions.getById(record.get('condId')); if (!condition) return value; switch(condition.get('type')) @@ -417,7 +417,7 @@ Ext.define('amdaUI.FilterGridPanel', { } }; }, - + createColumns : function() { return [ @@ -427,11 +427,11 @@ Ext.define('amdaUI.FilterGridPanel', { this.createValueColumn() ]; }, - + createContextMenus : function() { var me = this; - + this.groupMenu = Ext.create('Ext.menu.Menu', { crtGroup : null, items: [{ @@ -454,7 +454,7 @@ Ext.define('amdaUI.FilterGridPanel', { } ] }); - + this.itemMenu = Ext.create('Ext.menu.Menu', { items: [{ text: 'Insert', @@ -468,21 +468,21 @@ Ext.define('amdaUI.FilterGridPanel', { scope : me } ] - }); + }); }, - + createGroupingFeature : function() { var me = this; - + this.groupingFeature = Ext.create('Ext.grid.feature.Grouping',{ enableGroupingMenu: true, enableNoGroups : false, showGroupsText : false, - groupHeaderTpl: Ext.create('Ext.XTemplate', - '{name:this.filter_type} ({rows.length:this.cond_info})', + groupHeaderTpl: Ext.create('Ext.XTemplate', + '{name:this.filter_type} ({rows.length:this.cond_info})', { - cond_info : function(val) + cond_info : function(val) { var nbCond = val < 1 ? 0 : val-1; return (nbCond > 1) ? nbCond+' conditions' : nbCond+' condition'; @@ -497,20 +497,20 @@ Ext.define('amdaUI.FilterGridPanel', { return rec.get('name'); } } - + ) }); }, - - init : function(config) + + init : function(config) { var me = this; - + this.createContextMenus(); - + this.createGroupingFeature(); - - var myConf = + + var myConf = { plugins : [ this.createCellEditingPlugin() @@ -531,12 +531,12 @@ Ext.define('amdaUI.FilterGridPanel', { { if (selections && selections[0]) { - + var condId = selections[0].get('condId'); - + var crtType = selections[0].get('type'); var conditions = this.filtersInfoStore.getById(crtType).conditions(); - + var cond = conditions.getById(condId); if (cond) { @@ -550,13 +550,13 @@ Ext.define('amdaUI.FilterGridPanel', { this.itemMenu.showAt(e.getXY()); }, groupcontextmenu : function(view, node, group, e) - { + { e.stopEvent(); this.groupMenu.crtGroup = group; this.groupMenu.showAt(e.getXY()); }, scope : this - + } }; Ext.apply (this , Ext.apply (arguments, myConf)); @@ -564,7 +564,7 @@ Ext.define('amdaUI.FilterGridPanel', { }); /* - * Filters main interface + * Filters main interface */ Ext.define('amdaUI.FiltersUI', { @@ -575,27 +575,27 @@ Ext.define('amdaUI.FiltersUI', { 'amdaModel.FilterInfo', 'amdaModel.FilterDef' ], - + newFilterName : 'New_Filter_', - + //filters info to build interface filtersInfoStore : null, filtersListStore : null, - - constructor: function(config) { + + constructor: function(config) { this.init(config); this.callParent(arguments); }, - + onSelect : function(combo,records,eOpts) { if (!records || (records.length != 1)) - return; + return; var record = records[0]; this.setFilterName(record.get('name')); this.grid.setConditions(record); }, - + onBeforeSelect: function(combo, record, index) { /*var me = this; @@ -617,12 +617,12 @@ Ext.define('amdaUI.FiltersUI', { }*/ return true; }, - + onAddFilter : function(t) { this.addFilter(null,null); }, - + addFilter : function(name,conds,successfn) { var combo = this.getFilterCombo(); @@ -630,20 +630,20 @@ Ext.define('amdaUI.FiltersUI', { return null; var newRec = Ext.create('amdaModel.FilterDef'); - + if (name != null) newRec.set('name',name); - + newRec.conditions(); - + if (conds != null) Ext.each(conds, function(cond) { newRec.conditions().add(cond); },this); - + combo.store.add(newRec); - + //sync store with the server combo.store.sync({ scope: this, @@ -655,27 +655,27 @@ Ext.define('amdaUI.FiltersUI', { newRec.conditions().removeAll(); newRec.conditions().add(resRec.conditions); combo.select(newRec); - combo.fireEvent('select', combo, [newRec] ); + combo.fireEvent('select', combo, [newRec] ); if (successfn) successfn.call(this,newRec); }}); - + return newRec; }, - + onDeleteFilter : function(t) { var combo = this.getFilterCombo(); if (!combo) return; - + var rec = this.getCrtFilterRecord(); - + if (!rec) return; if (rec.get("id") == "0") Ext.Msg.show( { - title : 'Filter', + title : 'Filter', msg : 'Cannot delete the Default Filter', modal : false, icon : Ext.Msg.ERROR, @@ -691,25 +691,25 @@ Ext.define('amdaUI.FiltersUI', { //fire select event combo.fireEvent('select', combo, [combo.store.getAt(0)]); } - // the same in WS explorer combobox + // the same in WS explorer combobox myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id, true, function (module) { var store = module.filtersStore; - var win = module.getUiContent(); + var win = module.getUiContent(); var comboList = win.dockedItems.getAt(1).items.items[0]; - - var recList = store.getById(rec.get("id")); - store.remove(recList); + + var recList = store.getById(rec.get("id")); + store.remove(recList); if (store.getCount() > 0) - { - comboList.select(store.getAt(0)); + { + comboList.select(store.getAt(0)); //fire select event comboList.fireEvent('select', comboList, [store.getAt(0)]); - } + } }); - + } }, - + onSaveFilter : function(t) { var filters = this.getFilterCombo().getStore().data.items; @@ -725,13 +725,13 @@ Ext.define('amdaUI.FiltersUI', { } var rec = this.getCrtFilterRecord(); - + if (!rec) return; - + this.saveFilter(rec); }, - + onApplyFilter : function(t) { var me = this; @@ -748,27 +748,27 @@ Ext.define('amdaUI.FiltersUI', { ); return; } - + this.requestApplyFilter(rec); }, - + requestApplyFilter : function(rec) { - AmdaAction.setCrtFilterId({id : rec.get('id')}, + AmdaAction.setCrtFilterId({id : rec.get('id')}, function (result, e) { var t = e.getTransaction(); - if (e.status) - { + if (e.status) + { if (result) { myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id, true, function (module) { - module.setCrtFilter(); - }); + module.setCrtFilter(); + }); } else Ext.Msg.show( { - title : 'Filter', + title : 'Filter', msg : 'Cannot apply filter', modal : true, icon : Ext.Msg.ERROR, @@ -779,10 +779,10 @@ Ext.define('amdaUI.FiltersUI', { { // FAILURE Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); - } + } },this); }, - + isDirty : function(filter) { if (filter.dirty) @@ -798,7 +798,7 @@ Ext.define('amdaUI.FiltersUI', { ); return dirty; }, - + getFilterCombo : function() { var comboField = this.query('#filter_combo'); @@ -806,7 +806,7 @@ Ext.define('amdaUI.FiltersUI', { return null; return comboField[0]; }, - + getNameField : function() { var nameField = this.query('#filter_name'); @@ -814,11 +814,11 @@ Ext.define('amdaUI.FiltersUI', { return null; return nameField[0]; }, - + saveFilter : function(rec,successfn) { var me = this; - + var filterName = this.getFilterName(); if (!filterName) return; @@ -842,13 +842,13 @@ Ext.define('amdaUI.FiltersUI', { }); return; } - + var msg; if (rec.get('id') == 0) msg = 'The name of the default filter cannot be modified. Do you want to create a new instance of this filter?'; else msg = 'Filter name has been changed. Do you want to create a new instance of this filter?'; - + Ext.Msg.confirm('Filters', msg, function(btn) { if (btn == 'yes') @@ -861,33 +861,33 @@ Ext.define('amdaUI.FiltersUI', { conds[i] = cond.getJsonValues(); }, this); - + //reload conditions of the current filter amdaModel.FilterDef.load(rec.get('id'), { scope : this, - callback : function(r, operation) + callback : function(r, operation) { //reset modifications on current record rec.conditions().removeAll(); rec.conditions().loadData(r.conditions().data.items); //create the new filter var newRec = this.addFilter(filterName,conds,successfn); - + } - } + } ); return; - } - + } + if (rec.get('id') == 0) { filterName = rec.get('name'); //cannot change default filter name this.setFilterName(filterName); } - + //change the name of the filter - rec.set('name',filterName); + rec.set('name',filterName); //save modifications rec.save({ success: function() { @@ -905,9 +905,9 @@ Ext.define('amdaUI.FiltersUI', { }); }, this - ); + ); }, - + setFilterName : function(n) { var nameField = this.getNameField(); @@ -915,13 +915,13 @@ Ext.define('amdaUI.FiltersUI', { return; nameField.setValue(n); }, - + getFilterName : function() { var nameField = this.getNameField(); return nameField.getValue(); }, - + getCrtFilterRecord : function() { var combo = this.getFilterCombo(); @@ -929,14 +929,14 @@ Ext.define('amdaUI.FiltersUI', { return null; return combo.store.getById(combo.getValue()); }, - + setCrtFilter : function() - { + { AmdaAction.getCrtFilterId(function (result, e) { var t = e.getTransaction(); - if (e.status) - { + if (e.status) + { if (result) { var crtId = result; @@ -960,17 +960,17 @@ Ext.define('amdaUI.FiltersUI', { { // FAILURE Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); - } + } },this); }, - + createFilterStore : function() { return Ext.create('Ext.data.Store', { model: 'amdaModel.FilterDef', autoLoad : true, - listeners : + listeners : { 'load' : function(store, records, successful) { @@ -987,10 +987,10 @@ Ext.define('amdaUI.FiltersUI', { }, scope : this } - + }); }, - + reloadFilter : function() { var combo = this.getFilterCombo(); @@ -998,7 +998,7 @@ Ext.define('amdaUI.FiltersUI', { return; combo.getStore().reload(); }, - + createToolBar : function() { var me = this; @@ -1041,10 +1041,10 @@ Ext.define('amdaUI.FiltersUI', { 'beforeselect' : this.onBeforeSelect } } - + ]; }, - + createInfoPanel : function() { var me = this; @@ -1080,21 +1080,21 @@ Ext.define('amdaUI.FiltersUI', { ] }; }, - + createGridPanel : function() { this.grid = Ext.create('amdaUI.FilterGridPanel',{}); return this.grid; }, - - init : function(config) + + init : function(config) { var me = this; - + var myConf = { layout: 'border', tbar : this.createToolBar(), - items: [ + items: [ { xtype : 'panel', region: 'center', @@ -1107,10 +1107,10 @@ Ext.define('amdaUI.FiltersUI', { items : [ this.createInfoPanel(), this.createGridPanel() - ] + ] }, { - xtype: 'panel', + xtype: 'panel', region: 'south', title: 'Information', collapsible: true, @@ -1121,12 +1121,12 @@ Ext.define('amdaUI.FiltersUI', { loader: { autoLoad: true, url: helpDir+'filterHOWTO' - } + } } ] }; Ext.apply (me , Ext.apply (arguments, myConf)); - + this.filtersInfoStore = Ext.create('Ext.data.Store',{model: 'amdaModel.FilterInfo'}); this.filtersListStore = Ext.create('Ext.data.Store',{model: 'amdaModel.FilterSelectList'}); @@ -1138,7 +1138,7 @@ Ext.define('amdaUI.FiltersUI', { this.filtersListStore.load({ scope : me, callback: function(records, operation, success) - { + { me.grid.setFiltersListStore(this.filtersListStore); } }); -- libgit2 0.21.2