Commit 42c4ccd30c25853038f9ffd467636483a1ac2c18
1 parent
3d95b0a6
Exists in
master
and in
52 other branches
#9660 - Done
Showing
5 changed files
with
282 additions
and
41 deletions
Show diff stats
js/app/views/CatalogUI.js
... | ... | @@ -504,12 +504,10 @@ Ext.define('amdaUI.CatalogUI', { |
504 | 504 | dateFormat: 'Y-m-d\\TH:i:s.u', |
505 | 505 | convert: function (value, rec) { |
506 | 506 | if (!Ext.isDate(value)) { |
507 | - var valueString = new String(value); | |
508 | - return new Date(valueString.replace(/\-/g, '\/').replace(/[T|Z]/g, ' ')); | |
507 | + return new Date(value); | |
509 | 508 | } |
510 | 509 | return value; |
511 | 510 | } |
512 | - | |
513 | 511 | }); |
514 | 512 | column = Ext.apply({}, column, { |
515 | 513 | xtype: 'datecolumn', |
... | ... | @@ -520,7 +518,18 @@ Ext.define('amdaUI.CatalogUI', { |
520 | 518 | hideTrigger: true, |
521 | 519 | format: 'Y-m-d\\TH:i:s.u' |
522 | 520 | }, |
523 | - filter: {type: 'date', dateFormat: 'Y-m-d'} | |
521 | + filter: {type: 'date', dateFormat: 'Y-m-d'}, | |
522 | + renderer: function (value) { | |
523 | + if (value != null) { | |
524 | + if (Ext.isDate(value)) { | |
525 | + return Ext.Date.format(value, 'Y-m-d\\TH:i:s.u'); | |
526 | + } else { | |
527 | + return Ext.Date.format(new Date(value), 'Y-m-d\\TH:i:s.u'); | |
528 | + } | |
529 | + } else { | |
530 | + return value; | |
531 | + } | |
532 | + } | |
524 | 533 | }); |
525 | 534 | break; |
526 | 535 | case 2: //string |
... | ... | @@ -566,13 +575,6 @@ Ext.define('amdaUI.CatalogUI', { |
566 | 575 | fieldsConfig.push(field); |
567 | 576 | columnsConfig.push(column); |
568 | 577 | }); |
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);*/ | |
576 | 578 | var store = Ext.create('Ext.data.Store', { |
577 | 579 | fields: fieldsConfig, |
578 | 580 | autoDestroy: false, |
... | ... | @@ -849,6 +851,154 @@ Ext.define('amdaUI.CatalogUI', { |
849 | 851 | } |
850 | 852 | } |
851 | 853 | }, |
854 | + | |
855 | + columnForm: function(isNew, self, me , columnInfo = null){ | |
856 | + | |
857 | + | |
858 | + // Different avaible types | |
859 | + var types = Ext.create('Ext.data.Store', { | |
860 | + fields: ['type', 'name'], | |
861 | + data : [ | |
862 | + {"type":2, "name":"String"}, | |
863 | + {"type":3, "name":"Integer"}, | |
864 | + {"type":0, "name":"Float"}, | |
865 | + {"type":1,"name":"TIme"} | |
866 | + ] | |
867 | + }); | |
868 | + | |
869 | + // Window for the creation of the new Column | |
870 | + var window = Ext.create('Ext.window.Window', { | |
871 | + title: (isNew) ? 'New Column' : 'Edit Column', | |
872 | + width: 275, | |
873 | + height: 155, | |
874 | + closable:false, | |
875 | + modal:true, | |
876 | + resizable: false, | |
877 | + items: [ | |
878 | + { | |
879 | + xtype: 'form', | |
880 | + layout: 'form', | |
881 | + id: 'simpleForm', | |
882 | + frame: true, | |
883 | + bodyPadding: '5 5 0', | |
884 | + fieldDefaults: { | |
885 | + msgTarget: 'side', | |
886 | + labelWidth: 85 | |
887 | + }, | |
888 | + items: [{ | |
889 | + // Name | |
890 | + xtype:'textfield', | |
891 | + fieldLabel: 'Column Name', | |
892 | + name: 'nameColumn', | |
893 | + value: (isNew) ? null : columnInfo.name, | |
894 | + allowBlank: false, | |
895 | + tooltip: 'Enter the name of the column you want to create' | |
896 | + },{ | |
897 | + // Type | |
898 | + xtype: 'combobox', | |
899 | + fieldLabel: 'Data Type', | |
900 | + name:'typeColumn', | |
901 | + store:types, | |
902 | + allowBlank: false, | |
903 | + value : (isNew) ? null : columnInfo.type, | |
904 | + queryMode: 'local', | |
905 | + displayField: 'name', | |
906 | + valueField: 'type', | |
907 | + editable: false, | |
908 | + tooltip: 'Enter the type of data you want to put in this column' | |
909 | + }, | |
910 | + { | |
911 | + // Size | |
912 | + xtype:'numberfield', | |
913 | + fieldLabel: 'Size', | |
914 | + name: 'sizeColumn', | |
915 | + value: (isNew) ? 1 : columnInfo.size, | |
916 | + maxValue: 3, | |
917 | + minValue: 1, | |
918 | + allowBlank: false, | |
919 | + tooltip: 'For exemple: 1 for scalar type or 3 for a vector' | |
920 | + }], | |
921 | + | |
922 | + buttons: [{ | |
923 | + text: 'Save', | |
924 | + handler: function() { | |
925 | + // If the form is correctly filled, we continue | |
926 | + if(this.up('form').getForm().isValid()){ | |
927 | + if(isNew){ | |
928 | + var newColumnPrefix='added_param_id_'; | |
929 | + var nbAddedColumn= 0; | |
930 | + Ext.each(self.TTGrid.headerCt.getGridColumns(), function(column){ | |
931 | + if(column.dataIndex.substr(0, 15) == newColumnPrefix){ | |
932 | + nbAddedColumn++; | |
933 | + } | |
934 | + }); | |
935 | + | |
936 | + AmdaAction.addColumn(newColumnPrefix+nbAddedColumn, | |
937 | + this.up('form').getForm().findField('nameColumn').getValue(), | |
938 | + this.up('form').getForm().findField('typeColumn').getValue(), | |
939 | + this.up('form').getForm().findField('sizeColumn').getValue(), | |
940 | + function(result, e){ | |
941 | + if(result){ | |
942 | + me.toReconfigure = true; | |
943 | + me.onAfterInit(result); | |
944 | + window.close(); | |
945 | + } | |
946 | + }); | |
947 | + } | |
948 | + else{ | |
949 | + var newName = null; | |
950 | + var newType = null; | |
951 | + var newSize = null; | |
952 | + | |
953 | + // Check if there is modifications | |
954 | + if(this.up('form').getForm().findField('nameColumn').getValue() != columnInfo.name){ | |
955 | + newName = this.up('form').getForm().findField('nameColumn').getValue(); | |
956 | + } | |
957 | + if(this.up('form').getForm().findField('typeColumn').getValue() != columnInfo.type){ | |
958 | + newType = this.up('form').getForm().findField('typeColumn').getValue(); | |
959 | + } | |
960 | + if(this.up('form').getForm().findField('sizeColumn').getValue() != columnInfo.size){ | |
961 | + newSize = this.up('form').getForm().findField('sizeColumn').getValue(); | |
962 | + } | |
963 | + | |
964 | + if(newName != null || newType != null || newSize != null) | |
965 | + { | |
966 | + AmdaAction.editColumn(columnInfo.id, newName, newType, newSize, function(result, e){ | |
967 | + if(result){ | |
968 | + me.toReconfigure = true; | |
969 | + me.onAfterInit(result); | |
970 | + window.close(); | |
971 | + } | |
972 | + }); | |
973 | + | |
974 | + } | |
975 | + else{ | |
976 | + window.close(); | |
977 | + } | |
978 | + } | |
979 | + } | |
980 | + }, | |
981 | + }, | |
982 | + { | |
983 | + // to reset the form | |
984 | + text: 'Reset', | |
985 | + handler: function() { | |
986 | + this.up('form').getForm().reset(); | |
987 | + } | |
988 | + }, | |
989 | + { | |
990 | + // To quit the window | |
991 | + text: 'Cancel', | |
992 | + handler: function() { | |
993 | + window.close(); | |
994 | + } | |
995 | + }] | |
996 | + } | |
997 | + ] | |
998 | + }).show(); | |
999 | + | |
1000 | + }, | |
1001 | + | |
852 | 1002 | init: function (config) |
853 | 1003 | { |
854 | 1004 | var me = this; |
... | ... | @@ -936,7 +1086,7 @@ Ext.define('amdaUI.CatalogUI', { |
936 | 1086 | |
937 | 1087 | ] |
938 | 1088 | }; |
939 | - | |
1089 | + const self = this; | |
940 | 1090 | this.TTGrid = Ext.create('Ext.grid.Panel', { |
941 | 1091 | height: 530, |
942 | 1092 | features: [filters], |
... | ... | @@ -967,16 +1117,22 @@ Ext.define('amdaUI.CatalogUI', { |
967 | 1117 | listeners: { |
968 | 1118 | afterrender: function ( ) { |
969 | 1119 | this.TTGrid.headerCt.resizer.tracker.gridBugFix = true; |
970 | - | |
971 | 1120 | // Adding "Delete Column" in the menu |
972 | 1121 | var menu = this.TTGrid.headerCt.getMenu(); |
973 | 1122 | menu.on('beforeshow',function(){ |
1123 | + var deleteName='delete_column'; | |
1124 | + var editName= 'edit_column'; | |
974 | 1125 | var isDeleteinMenu = false; |
975 | - // Is there already the item in the menu | |
1126 | + var isEditInMenu = false; | |
1127 | + // Is there already the delete or edit item in the menu | |
976 | 1128 | Ext.each(menu.items.items, function(items){ |
977 | - if(items.name == 'delete_column'){ | |
1129 | + if(items.name == deleteName){ | |
978 | 1130 | isDeleteinMenu = true; |
979 | 1131 | } |
1132 | + if(items.name == editName){ | |
1133 | + isEditInMenu = true; | |
1134 | + } | |
1135 | + | |
980 | 1136 | }); |
981 | 1137 | // Computing the number of parameters in the catalog |
982 | 1138 | var nbParamColumns=0; |
... | ... | @@ -985,27 +1141,47 @@ Ext.define('amdaUI.CatalogUI', { |
985 | 1141 | nbParamColumns++ |
986 | 1142 | } |
987 | 1143 | }); |
1144 | + | |
1145 | + // Adding the "Edit Column" if conditions satisfied | |
1146 | + if(!isEditInMenu){ | |
1147 | + menu.add({ | |
1148 | + text: 'Edit Column', | |
1149 | + iconCls: 'icon-parameters', | |
1150 | + name: editName, | |
1151 | + handler: function(item,e) { | |
1152 | + AmdaAction.getCatColumnInfo(menu.activeHeader.dataIndex,function(result, e){ | |
1153 | + if(result){ | |
1154 | + me.columnForm(false, self,me, result); | |
1155 | + } | |
1156 | + }); | |
1157 | + } | |
1158 | + }); | |
1159 | + } | |
1160 | + | |
988 | 1161 | // Adding the "Delete Column" if conditions satisfied |
989 | - if(!isDeleteinMenu && menu.activeHeader.paramColumn && nbParamColumns > 1){ | |
990 | - menu.add([{ | |
1162 | + if(!isDeleteinMenu){ | |
1163 | + menu.add({ | |
991 | 1164 | text: 'Delete Column', |
992 | - name:'delete_column', | |
1165 | + iconCls: 'icon-delete', | |
1166 | + disabled:false, | |
1167 | + name: deleteName, | |
993 | 1168 | handler: function(item,e) { |
994 | 1169 | AmdaAction.deleteColumn(menu.activeHeader.dataIndex,function(result, e){ |
995 | 1170 | me.toReconfigure = true; |
996 | 1171 | me.onAfterInit(result); |
997 | 1172 | }); |
998 | 1173 | } |
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 | 1174 | }); |
1008 | 1175 | } |
1176 | + | |
1177 | + Ext.each(menu.items.items, function(item){ | |
1178 | + if(item.name == deleteName){ | |
1179 | + item.setDisabled(!menu.activeHeader.paramColumn || nbParamColumns <= 1); | |
1180 | + } | |
1181 | + if(item.name == editName){ | |
1182 | + item.setDisabled(!menu.activeHeader.paramColumn); | |
1183 | + } | |
1184 | + }); | |
1009 | 1185 | }, this); |
1010 | 1186 | }, |
1011 | 1187 | scope: this |
... | ... | @@ -1069,19 +1245,9 @@ Ext.define('amdaUI.CatalogUI', { |
1069 | 1245 | itemId: 'column_add', |
1070 | 1246 | scope: this, |
1071 | 1247 | 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 | - */} | |
1248 | + | |
1249 | + me.columnForm(true, self,me); | |
1250 | + } | |
1085 | 1251 | }, '->', |
1086 | 1252 | { |
1087 | 1253 | text: 'Clear Filters', | ... | ... |
php/classes/AmdaAction.php
... | ... | @@ -1658,5 +1658,20 @@ class AmdaAction |
1658 | 1658 | |
1659 | 1659 | return $cacheMgr->deleteColumn($id); |
1660 | 1660 | } |
1661 | + | |
1662 | + public function addColumn($id, $name, $type, $size){ | |
1663 | + $cacheMgr = new CatalogCacheMgr(); | |
1664 | + return $cacheMgr->addColumn($id,$name, $type,$size); | |
1665 | + } | |
1666 | + | |
1667 | + public function getCatColumnInfo($id){ | |
1668 | + $cacheMgr = new CatalogCacheMgr(); | |
1669 | + return $cacheMgr->getCatColumnInfo($id); | |
1670 | + } | |
1671 | + | |
1672 | + public function editColumn($id, $name, $type, $size){ | |
1673 | + $cacheMgr = new CatalogCacheMgr(); | |
1674 | + return $cacheMgr->editColumn($id,$name, $type,$size); | |
1675 | + } | |
1661 | 1676 | } |
1662 | 1677 | ?> | ... | ... |
php/classes/CatalogCacheMgr.php
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | class CatalogCacheMgr extends TimeTableCacheMgr |
8 | 8 | { |
9 | 9 | const DEFAULT_PARAM_ID_PREFIX = 'cat_param_id_'; |
10 | + const DEFAULT_NEW_PARAM_ID_PREFIX = 'added_param_id_'; | |
10 | 11 | private $isForVisu = FALSE; |
11 | 12 | |
12 | 13 | function __construct($isForVisu = FALSE) { |
... | ... | @@ -150,5 +151,31 @@ class CatalogCacheMgr extends TimeTableCacheMgr |
150 | 151 | } |
151 | 152 | return array('success' => $result , 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus(),'parameters' => $this->cache->getParametersInfo()); |
152 | 153 | } |
154 | + | |
155 | + public function addColumn($id,$name, $type,$size){ | |
156 | + if (!$this->loadFromFile()) | |
157 | + return array('success' => false, 'message' => 'Cannot load cache file'); | |
158 | + $isNew=true; | |
159 | + $this->cache->addParameter($id,$name, $size, $type, $isNew); | |
160 | + $this->saveToFile(); | |
161 | + return array('success' => true , 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus(),'parameters' => $this->cache->getParametersInfo()); | |
162 | + } | |
163 | + | |
164 | + public function getCatColumnInfo($id){ | |
165 | + if (!$this->loadFromFile()) | |
166 | + return array('success' => false, 'message' => 'Cannot load cache file'); | |
167 | + | |
168 | + return $this->cache->getParameterInfo($id); | |
169 | + } | |
170 | + | |
171 | + public function editColumn($id,$name, $type,$size){ | |
172 | + if (!$this->loadFromFile()) | |
173 | + return array('success' => false, 'message' => 'Cannot load cache file'); | |
174 | + | |
175 | + $this->cache->editParameter($id,$name, $type, $size); | |
176 | + | |
177 | + $this->saveToFile(); | |
178 | + return array('success' => true , 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus(),'parameters' => $this->cache->getParametersInfo()); | |
179 | + } | |
153 | 180 | } |
154 | 181 | ?> | ... | ... |
php/classes/CatalogCacheObject.php
... | ... | @@ -26,7 +26,7 @@ class CatalogCacheObject extends TimeTableCacheObject |
26 | 26 | return $intervalObj; |
27 | 27 | } |
28 | 28 | |
29 | - public function addParameter($id, $name, $size, $type) | |
29 | + public function addParameter($id, $name, $size, $type, $isNew = false) | |
30 | 30 | { |
31 | 31 | $this->parameters[] = array( |
32 | 32 | 'id' => $id, |
... | ... | @@ -34,6 +34,9 @@ class CatalogCacheObject extends TimeTableCacheObject |
34 | 34 | 'size' => $size, |
35 | 35 | 'type' => $type, |
36 | 36 | ); |
37 | + if($isNew){ | |
38 | + $this->isModified = $isNew; | |
39 | + } | |
37 | 40 | } |
38 | 41 | |
39 | 42 | public function deleteParameter($id){ |
... | ... | @@ -48,10 +51,36 @@ class CatalogCacheObject extends TimeTableCacheObject |
48 | 51 | return false; |
49 | 52 | } |
50 | 53 | |
54 | + public function editParameter($id, $name, $type, $size) | |
55 | + { | |
56 | + foreach ($this->parameters as $index=>$param){ | |
57 | + if($id == $param['id']){ | |
58 | + if(isset($name)) | |
59 | + $this->parameters[$index]['name'] = $name; | |
60 | + if(isset($type)) | |
61 | + $this->parameters[$index]['type'] = $type; | |
62 | + if(isset($size)) | |
63 | + $this->parameters[$index]['size'] = $size; | |
64 | + $this->isModified = TRUE; | |
65 | + return true; | |
66 | + } | |
67 | + } | |
68 | + return false; | |
69 | + } | |
70 | + | |
51 | 71 | public function getParametersInfo() { |
52 | 72 | return $this->parameters; |
53 | 73 | } |
54 | 74 | |
75 | + public function getParameterInfo($id){ | |
76 | + foreach ($this->parameters as $index=>$param){ | |
77 | + if($id == $param['id']){ | |
78 | + return $param; | |
79 | + } | |
80 | + } | |
81 | + return false; | |
82 | + } | |
83 | + | |
55 | 84 | public function writeAdditionalHeaderBin($handle) |
56 | 85 | { |
57 | 86 | //Params Number | ... | ... |
php/config.php
... | ... | @@ -198,7 +198,11 @@ $API = array( |
198 | 198 | 'isSharedObjectNameAlreadyUsed' => array('len'=>1), |
199 | 199 | 'getRequestByProcessId' => array('len'=>1), |
200 | 200 | 'parseTemplatedParam' => array('len'=>1), |
201 | - 'deleteColumn' => array('len'=> 1) | |
201 | + // Furkan - New Catalog Options | |
202 | + 'deleteColumn' => array('len'=> 1), | |
203 | + 'addColumn' => array('len' => 4), | |
204 | + 'getCatColumnInfo' => array('len' => 1), | |
205 | + 'editColumn' => array('len' => 4) | |
202 | 206 | ) |
203 | 207 | ) |
204 | 208 | ); | ... | ... |