Commit 709a2d2ef8645dbab36d1cedb2954094137bab4e

Authored by Hacene SI HADJ MOHAND
1 parent 644c0324

il reste auto start et stop

Showing 2 changed files with 72 additions and 11 deletions   Show diff stats
js/app/models/TimeTable.js
... ... @@ -134,7 +134,7 @@ Ext.define('amdaModel.TimeTable', {
134 134 {name: 'fromPlugin', type: 'boolean', defaultValue: false},
135 135 {name: 'created', type: 'date'},
136 136 {name: 'description', type: 'string'},
137   - {name: 'contact', type: 'string'},
  137 + {name: 'contact', type: 'string', defaultValue:sessionID},
138 138 {name: 'surveyStart', type: 'date'},
139 139 {name: 'surveyStop', type: 'date'},
140 140 {name: 'history', type: 'string'},
... ... @@ -181,7 +181,7 @@ Ext.define('amdaModel.TimeTable', {
181 181 }
182 182 values.objName = this.get('objName');
183 183 values.objFormat = this.get('objFormat');
184   - values.folderId = this.get('folderId');
  184 + values.folderId = this.get('folderId');
185 185 values.nbIntervals = this.get('nbIntervals');
186 186 values.cacheToken = this.get('cacheToken');
187 187  
... ...
js/app/views/CatalogUI.js
... ... @@ -22,6 +22,7 @@ Ext.define('amdaUI.CatalogUI', {
22 22 ],
23 23  
24 24 isCatalog: true,
  25 + activeField : null,
25 26 statics: {
26 27 COL_TO_HIDE_DURATION: 'colToHideDuration'
27 28 },
... ... @@ -148,6 +149,30 @@ Ext.define('amdaUI.CatalogUI', {
148 149 return;
149 150 }
150 151 },
  152 + updateSurveyDates : function(ttObj){
  153 + var starts = [];
  154 + var stops= [];
  155 + Ext.Array.each(this.TTGrid.getStore().data.first.value, function (item, index) {
  156 + starts[index] = (item.raw.start);
  157 + stops[index] = (item.raw.stop);
  158 + });
  159 + if(starts.length !== 0 || stops.length !== 0) {
  160 +
  161 + starts.sort();
  162 + stops.sort();
  163 + s = new Date(starts[0]);
  164 + e = new Date(stops[stops.length - 1]);
  165 + if(! ttObj.get('surveyStart') ){
  166 + ttObj.set('surveyStart', this.convertUTCDateToLocalDate(s));
  167 + this.status.isModified = true;
  168 + }
  169 + if(! ttObj.get('surveyStop') ){
  170 + ttObj.set('surveyStop', this.convertUTCDateToLocalDate(e));
  171 + this.status.isModified = true;
  172 + }
  173 + }
  174 + },
  175 +
151 176 createTT: function (catId) {
152 177 var ttObj = Ext.create('amdaModel.TimeTable');
153 178 var timeTabNode = Ext.create('amdaModel.TimeTableNode', {leaf: true});
... ... @@ -157,8 +182,7 @@ Ext.define('amdaUI.CatalogUI', {
157 182 descr = 'Generated by CDPP/Amda Catalog Module \n' + 'From Catalog: ' + this.object.get('name') + '\nOn: ' + date + '\n';
158 183 ttObj.set('description', descr + this.object.get('description'));
159 184 ttObj.set('contact', this.object.get('contact'));
160   - ttObj.set('surveyStart', this.object.get('surveyStart'));
161   - ttObj.set('surveyStop', this.object.get('surveyStop'));
  185 + updateSurveyDates(ttObj);
162 186 timeTabNode.set('object', ttObj);
163 187 var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID);
164 188 var ttRootNode = explorerTree.getRootNode().findChild('id', 'timeTable-treeRootNode', true);
... ... @@ -594,6 +618,7 @@ Ext.define('amdaUI.CatalogUI', {
594 618 loadObject: function () {
595 619 // load object into form
596 620 this.object.set('created', this.convertUTCDateToLocalDate(this.object.get('created')));
  621 + this.updateSurveyDates(this.object);
597 622 this.formPanel.getForm().loadRecord(this.object);
598 623  
599 624 this.status = null;
... ... @@ -645,6 +670,7 @@ Ext.define('amdaUI.CatalogUI', {
645 670 module.createObject(this.object.getJsonValues());
646 671 var obj = module.linkedNode.get('object');
647 672 // synchronisation of objects
  673 + this.updateSurveyDates(obj);
648 674 this.object = obj;
649 675 module.linkedNode.create({notDisplayMsg: notDisplayMsg, callback: function () {
650 676 if (onAfterSave)
... ... @@ -694,8 +720,8 @@ Ext.define('amdaUI.CatalogUI', {
694 720 if (this.TTGrid.getStore().getTotalCount() > 0)
695 721 {
696 722 // update TimeTable object which the content of form
  723 + this.updateSurveyDates(this.object);
697 724 basicForm.updateRecord(this.object);
698   -
699 725 var me = this;
700 726 this.checkIntervalsStatusForSave(function () {
701 727 //Name validation
... ... @@ -767,7 +793,30 @@ Ext.define('amdaUI.CatalogUI', {
767 793 var isDirty = this.formPanel.getForm().isDirty() || (this.status.isModified) || (this.status.nbModified > 0) || (this.status.nbNew > 0);
768 794 return isDirty;
769 795 },
770   -
  796 + onChangeStartField: function(field, newValue, oldValue)
  797 + {
  798 + if (field.isValid() && this.activeField =='surveyStart' ) {
  799 + // launch the update of duration fields
  800 + var form = this.findParentByType('form').getForm();
  801 + var start = form.findField('surveyStart').getValue();
  802 + var stop =form.findField('surveyStop').getValue();
  803 + if ( stop <= start ) {
  804 + field.markInvalid('Start Time must be before Stop Time');
  805 + }
  806 + }
  807 + },
  808 + onChangeStopField: function(field, newValue, oldValue)
  809 + {
  810 + if (field.isValid() && this.activeField =='surveyStop' ) {
  811 + // launch the update of duration fields
  812 + var form = this.findParentByType('form').getForm();
  813 + var start = form.findField('surveyStart').getValue();
  814 + var stop =form.findField('surveyStop').getValue();
  815 + if ( stop <= start ) {
  816 + field.markInvalid('Stop Time must be after Start Time');
  817 + }
  818 + }
  819 + },
771 820 init: function (config)
772 821 {
773 822 this.object = config.object;
... ... @@ -967,22 +1016,34 @@ Ext.define(&#39;amdaUI.CatalogUI&#39;, {
967 1016 items :[{
968 1017 fieldLabel: 'Start Time',
969 1018 name: 'surveyStart',
970   - emptyText: 'YYYY/MM/DDThh:mm:ss',
  1019 + emptyText: 'YYYY/MM/DDThh:mm:ss',
971 1020 format: 'Y-m-d\\TH:i:s',
972   - enforceMaxLength: true,
  1021 + enforceMaxLength: true,
973 1022 maxLength: 19,
974 1023 labelWidth: 60,
975   - labelAlign: 'left'
  1024 + labelAlign: 'left',
  1025 + listeners: {
  1026 + change: this.onChangeStartField,
  1027 + focus: function(field) {
  1028 + this.activeField = 'surveyStart';
  1029 + },
  1030 + }
976 1031 }, {
977 1032 fieldLabel: 'Stop Time',
978 1033 name: 'surveyStop',
979   - emptyText: 'YYYY/MM/DDThh:mm:ss',
  1034 + emptyText: 'YYYY/MM/DDThh:mm:ss',
980 1035 format: 'Y-m-d\\TH:i:s',
981 1036 labelAlign: 'left',
982 1037 enforceMaxLength: true,
983 1038 maxLength: 19,
984 1039 labelWidth: 60,
985   - align: 'left'
  1040 + align: 'left',
  1041 + listeners: {
  1042 + change: this.onChangeStopField,
  1043 + focus: function(field) {
  1044 + this.activeField = 'surveyStop';
  1045 + },
  1046 + }
986 1047 }]
987 1048 },
988 1049 {
... ...