Commit 3d95b0a6b5beadff905be6d32de7e576a317869c
1 parent
560766be
Exists in
master
and in
53 other branches
Adding the Delete Column item in the catalog grid menu
Showing
5 changed files
with
105 additions
and
4 deletions
Show diff stats
js/app/views/CatalogUI.js
... | ... | @@ -483,7 +483,8 @@ Ext.define('amdaUI.CatalogUI', { |
483 | 483 | sortable: true, |
484 | 484 | dataIndex: obj.id, |
485 | 485 | menuDisabled: false, |
486 | - minWidth: 50 | |
486 | + minWidth: 50, | |
487 | + paramColumn: true | |
487 | 488 | }; |
488 | 489 | switch (obj.type) { |
489 | 490 | case 0: //double |
... | ... | @@ -565,7 +566,13 @@ Ext.define('amdaUI.CatalogUI', { |
565 | 566 | fieldsConfig.push(field); |
566 | 567 | columnsConfig.push(column); |
567 | 568 | }); |
568 | - | |
569 | + /*var addColumn = Ext.create('Ext.button.Button',{ | |
570 | + xtype: 'gridcolumn', | |
571 | + text:'bonjour', | |
572 | + editor: 'textfield', | |
573 | + filter: {type: 'string'} | |
574 | + }); | |
575 | + columnsConfig.push(addColumn);*/ | |
569 | 576 | var store = Ext.create('Ext.data.Store', { |
570 | 577 | fields: fieldsConfig, |
571 | 578 | autoDestroy: false, |
... | ... | @@ -844,6 +851,7 @@ Ext.define('amdaUI.CatalogUI', { |
844 | 851 | }, |
845 | 852 | init: function (config) |
846 | 853 | { |
854 | + var me = this; | |
847 | 855 | this.object = config.object; |
848 | 856 | this.fieldName = new Ext.form.field.Text({ |
849 | 857 | fieldLabel: 'Name', |
... | ... | @@ -957,8 +965,48 @@ Ext.define('amdaUI.CatalogUI', { |
957 | 965 | // selType: 'cellmodel', |
958 | 966 | plugins: [cellEditing, {ptype: 'bufferedrenderer'}], |
959 | 967 | listeners: { |
960 | - afterrender: function () { | |
968 | + afterrender: function ( ) { | |
961 | 969 | this.TTGrid.headerCt.resizer.tracker.gridBugFix = true; |
970 | + | |
971 | + // Adding "Delete Column" in the menu | |
972 | + var menu = this.TTGrid.headerCt.getMenu(); | |
973 | + menu.on('beforeshow',function(){ | |
974 | + var isDeleteinMenu = false; | |
975 | + // Is there already the item in the menu | |
976 | + Ext.each(menu.items.items, function(items){ | |
977 | + if(items.name == 'delete_column'){ | |
978 | + isDeleteinMenu = true; | |
979 | + } | |
980 | + }); | |
981 | + // Computing the number of parameters in the catalog | |
982 | + var nbParamColumns=0; | |
983 | + Ext.each(this.TTGrid.headerCt.getGridColumns(), function(column){ | |
984 | + if(column.paramColumn){ | |
985 | + nbParamColumns++ | |
986 | + } | |
987 | + }); | |
988 | + // Adding the "Delete Column" if conditions satisfied | |
989 | + if(!isDeleteinMenu && menu.activeHeader.paramColumn && nbParamColumns > 1){ | |
990 | + menu.add([{ | |
991 | + text: 'Delete Column', | |
992 | + name:'delete_column', | |
993 | + handler: function(item,e) { | |
994 | + AmdaAction.deleteColumn(menu.activeHeader.dataIndex,function(result, e){ | |
995 | + me.toReconfigure = true; | |
996 | + me.onAfterInit(result); | |
997 | + }); | |
998 | + } | |
999 | + }]); | |
1000 | + } | |
1001 | + // If there is already the item but only 1 parameter left => not allowed the delete | |
1002 | + else if (isDeleteinMenu && nbParamColumns == 1){ | |
1003 | + Ext.each(menu.items.items, function(items){ | |
1004 | + if(items.name == 'delete_column'){ | |
1005 | + items.setDisabled(true); | |
1006 | + } | |
1007 | + }); | |
1008 | + } | |
1009 | + }, this); | |
962 | 1010 | }, |
963 | 1011 | scope: this |
964 | 1012 | }, |
... | ... | @@ -966,6 +1014,7 @@ Ext.define('amdaUI.CatalogUI', { |
966 | 1014 | xtype: 'toolbar', |
967 | 1015 | items: [{ |
968 | 1016 | iconCls: 'icon-add', |
1017 | + text:'New line', | |
969 | 1018 | scope: this, |
970 | 1019 | handler: function () { |
971 | 1020 | cellEditing.cancelEdit(); |
... | ... | @@ -992,9 +1041,11 @@ Ext.define('amdaUI.CatalogUI', { |
992 | 1041 | } |
993 | 1042 | }, this); |
994 | 1043 | } |
995 | - }, { | |
1044 | + }, | |
1045 | + { | |
996 | 1046 | iconCls: 'icon-delete', |
997 | 1047 | disabled: true, |
1048 | + text:'Delete Line', | |
998 | 1049 | itemId: 'delete', |
999 | 1050 | scope: this, |
1000 | 1051 | handler: function () { |
... | ... | @@ -1011,6 +1062,26 @@ Ext.define('amdaUI.CatalogUI', { |
1011 | 1062 | }, this); |
1012 | 1063 | } |
1013 | 1064 | } |
1065 | + }, | |
1066 | + '-',{ | |
1067 | + iconCls: 'icon-add', | |
1068 | + text:'New Column(s)', | |
1069 | + itemId: 'column_add', | |
1070 | + scope: this, | |
1071 | + handler: function () { | |
1072 | + /*var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0]; | |
1073 | + if (selection) | |
1074 | + { | |
1075 | + var rowId = selection.get('cacheId'); | |
1076 | + this.TTGrid.getSelectionModel().deselectAll(); | |
1077 | + AmdaAction.removeTTCacheIntervalFromId(rowId, this.isCatalog, function (result, e) { | |
1078 | + this.status = result.status; | |
1079 | + if (!this.TTGrid.getStore().loading) { | |
1080 | + this.TTGrid.getStore().reload(); | |
1081 | + } | |
1082 | + }, this); | |
1083 | + } | |
1084 | + */} | |
1014 | 1085 | }, '->', |
1015 | 1086 | { |
1016 | 1087 | text: 'Clear Filters', |
... | ... |
php/classes/AmdaAction.php
... | ... | @@ -1652,5 +1652,11 @@ class AmdaAction |
1652 | 1652 | ); |
1653 | 1653 | return $this->executeRequest($args, FunctionTypeEnumClass::PARAMINFO); |
1654 | 1654 | } |
1655 | + | |
1656 | + public function deleteColumn($id){ | |
1657 | + $cacheMgr = new CatalogCacheMgr(); | |
1658 | + | |
1659 | + return $cacheMgr->deleteColumn($id); | |
1660 | + } | |
1655 | 1661 | } |
1656 | 1662 | ?> |
... | ... |
php/classes/CatalogCacheMgr.php
... | ... | @@ -139,5 +139,16 @@ class CatalogCacheMgr extends TimeTableCacheMgr |
139 | 139 | |
140 | 140 | return $result + array('parameters' => $parameters_chart); |
141 | 141 | } |
142 | + | |
143 | + public function deleteColumn($id){ | |
144 | + if (!$this->loadFromFile()) | |
145 | + return array('success' => false, 'message' => 'Cannot load cache file'); | |
146 | + | |
147 | + $result = $this->cache->deleteParameter($id); | |
148 | + if ($result){ | |
149 | + $this->saveToFile(); | |
150 | + } | |
151 | + return array('success' => $result , 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus(),'parameters' => $this->cache->getParametersInfo()); | |
152 | + } | |
142 | 153 | } |
143 | 154 | ?> |
... | ... |
php/classes/CatalogCacheObject.php
... | ... | @@ -36,6 +36,18 @@ class CatalogCacheObject extends TimeTableCacheObject |
36 | 36 | ); |
37 | 37 | } |
38 | 38 | |
39 | + public function deleteParameter($id){ | |
40 | + foreach($this->parameters as $index=>$param){ | |
41 | + if($id == $param['id']){ | |
42 | + unset($this->parameters[$index]); | |
43 | + $this->parameters = array_values($this->parameters); | |
44 | + $this->isModified = TRUE; | |
45 | + return true; | |
46 | + } | |
47 | + } | |
48 | + return false; | |
49 | + } | |
50 | + | |
39 | 51 | public function getParametersInfo() { |
40 | 52 | return $this->parameters; |
41 | 53 | } |
... | ... |
php/config.php