Commit 5535e93a8085cb23d259dbdff566bcf4e572d5bb
1 parent
a1c7bb89
Exists in
master
and in
48 other branches
Filter(#10688)/Sort(#10751) promblems solved on catalogs
Showing
4 changed files
with
111 additions
and
113 deletions
Show diff stats
js/app/models/InteractiveNode.js
... | ... | @@ -190,7 +190,7 @@ Ext.define('amdaModel.InteractiveNode', { |
190 | 190 | |
191 | 191 | var scope = opt.scope ? opt.scope : this; |
192 | 192 | if (opt.callback) |
193 | - opt.callback.call(scope,'update'); | |
193 | + opt.callback.call(scope,'update',res); | |
194 | 194 | if(opt.notDisplayMsg || opt.callback ){ |
195 | 195 | //do nothing |
196 | 196 | }else{ |
... | ... | @@ -337,7 +337,7 @@ Ext.define('amdaModel.InteractiveNode', { |
337 | 337 | if (opt) { |
338 | 338 | var scope = opt.scope ? opt.scope : this; |
339 | 339 | if (opt.callback) |
340 | - opt.callback.call(scope,'create'); | |
340 | + opt.callback.call(scope,'create',res); | |
341 | 341 | } |
342 | 342 | }, this); |
343 | 343 | } |
... | ... |
js/app/views/CatalogUI.js
... | ... | @@ -149,62 +149,18 @@ Ext.define('amdaUI.CatalogUI', { |
149 | 149 | return; |
150 | 150 | } |
151 | 151 | }, |
152 | - updateSurveyDates : function(ttObj){ | |
153 | - var starts = []; | |
154 | - var stops= []; | |
152 | + updateSurveyDates : function(res){ | |
155 | 153 | if (this.TTGrid.getStore().getTotalCount() <= 0) |
156 | 154 | return; |
157 | - reqObj = { | |
158 | - 'typeTT': 'catalog', | |
159 | - } | |
160 | - AmdaAction.readCacheIntervals(reqObj, function(result, e) | |
161 | - { | |
162 | - if (!result) { | |
163 | - myDesktopApp.errorMsg(e.message); | |
164 | - Ext.defer(function () { | |
165 | - Ext.Msg.toFront() | |
166 | - }, 10); | |
167 | - | |
168 | - return; | |
169 | - } else if (!result.success) | |
170 | - { | |
171 | - if (result.message) | |
172 | - myDesktopApp.errorMsg(result.message); | |
173 | - else | |
174 | - myDesktopApp.errorMsg('Unknown error during catalog survey dates update'); | |
175 | - | |
176 | - Ext.defer(function () { | |
177 | - Ext.Msg.toFront() | |
178 | - }, 10); | |
179 | - | |
180 | - return; | |
181 | - } | |
182 | - Ext.Array.each(result.intervals, function (item, index) { | |
183 | - starts[index] = new Date(item.start); | |
184 | - stops[index] = new Date(item.stop); | |
185 | - }); | |
186 | - if(starts.length !== 0 || stops.length !== 0) { | |
187 | - | |
188 | - starts.sort(function(a,b){return a.getTime() - b.getTime()}); | |
189 | - stops.sort(function(a,b){return a.getTime() - b.getTime()}); | |
190 | - | |
191 | 155 | |
192 | - s = starts[0]; | |
193 | - e = stops[stops.length - 1]; | |
194 | - | |
195 | - s = Ext.Date.format(s, 'Y-m-d\\TH:i:s.u'); | |
196 | - e = Ext.Date.format(e, 'Y-m-d\\TH:i:s.u'); | |
197 | - | |
198 | - if(! ttObj.get('surveyStart') ){ | |
199 | - ttObj.set('surveyStart', s); | |
200 | - this.status.isModified = true; | |
201 | - } | |
202 | - if(! ttObj.get('surveyStop') ){ | |
203 | - ttObj.set('surveyStop', e); | |
204 | - this.status.isModified = true; | |
205 | - } | |
206 | - } | |
207 | - }); | |
156 | + if(! this.object.get('surveyStart') ){ | |
157 | + this.object.set('surveyStart', res['minStart']); | |
158 | + this.status.isModified = true; | |
159 | + } | |
160 | + if(! this.object.get('surveyStop') ){ | |
161 | + this.object.set('surveyStop', res['maxStop']); | |
162 | + this.status.isModified = true; | |
163 | + } | |
208 | 164 | }, |
209 | 165 | |
210 | 166 | createTT: function (catId) { |
... | ... | @@ -216,7 +172,6 @@ Ext.define('amdaUI.CatalogUI', { |
216 | 172 | descr = 'Generated by CDPP/Amda Catalog Module \n' + 'From Catalog: ' + this.object.get('name') + '\nOn: ' + date + '\n'; |
217 | 173 | ttObj.set('description', descr + this.object.get('description')); |
218 | 174 | ttObj.set('contact', this.object.get('contact')); |
219 | - //this.updateSurveyDates(ttObj); | |
220 | 175 | timeTabNode.set('object', ttObj); |
221 | 176 | var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); |
222 | 177 | var ttRootNode = explorerTree.getRootNode().findChild('id', 'timeTable-treeRootNode', true); |
... | ... | @@ -689,6 +644,40 @@ Ext.define('amdaUI.CatalogUI', { |
689 | 644 | }, |
690 | 645 | |
691 | 646 | checkIntervalsStatusForSave: function (onStatusOk) { |
647 | + if (this.status == null) | |
648 | + return; | |
649 | + | |
650 | + if (this.status.nbValid <= 0) | |
651 | + { | |
652 | + myDesktopApp.errorMsg('Your catalog is invalid, <br>you must have at least one valid interval'); | |
653 | + return; | |
654 | + } | |
655 | + | |
656 | + var msg = ''; | |
657 | + if (this.status.nbInvalid > 0) | |
658 | + msg += 'There are some invalid intervals. Only valid intervals will be saved!<br/>'; | |
659 | + if (this.status.nbFiltered > 0) | |
660 | + msg += 'There are some filtered intervals. Filtered intervals will not be saved!<br/>'; | |
661 | + if (msg != '') | |
662 | + { | |
663 | + msg += 'Do you want to continue?'; | |
664 | + Ext.Msg.show({ | |
665 | + title: 'Warning!', | |
666 | + msg: msg, | |
667 | + buttons: Ext.Msg.OKCANCEL, | |
668 | + fn: function (btnId) { | |
669 | + if (btnId === 'cancel') { | |
670 | + // cancel the save action | |
671 | + } else { | |
672 | + onStatusOk(); | |
673 | + } | |
674 | + }, | |
675 | + scope: this, | |
676 | + icon: Ext.Msg.WARNING | |
677 | + }); | |
678 | + return; | |
679 | + } | |
680 | + | |
692 | 681 | onStatusOk(); |
693 | 682 | }, |
694 | 683 | |
... | ... | @@ -700,7 +689,6 @@ Ext.define('amdaUI.CatalogUI', { |
700 | 689 | var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); |
701 | 690 | // store / columns are the same - not needed to reconfigure grid |
702 | 691 | this.toReconfigure = false; |
703 | - this.updateSurveyDates(this.object); | |
704 | 692 | |
705 | 693 | // if save shared catalog |
706 | 694 | if (module.contextNode && (module.contextNode.get('id') == 'sharedcatalog-treeRootNode')) |
... | ... | @@ -711,13 +699,14 @@ Ext.define('amdaUI.CatalogUI', { |
711 | 699 | var obj = module.linkedNode.get('object'); |
712 | 700 | // synchronisation of objects |
713 | 701 | this.object = obj; |
714 | - module.linkedNode.create({notDisplayMsg: notDisplayMsg, callback: function () { | |
715 | - if (onAfterSave) | |
702 | + module.linkedNode.create({notDisplayMsg: notDisplayMsg, callback: function (type,res) { | |
703 | + this.updateSurveyDates(res); | |
704 | + if (onAfterSave) | |
716 | 705 | onAfterSave(); |
717 | 706 | }, scope: this}); |
718 | 707 | } |
719 | 708 | // if the name has been modified this is a creation |
720 | - else if (this.fclose() || this.status && (this.status.nbFiltered > 0)) { | |
709 | + else if (this.fclose() || this.status) { | |
721 | 710 | if (this.object.isModified('name') || this.object.get('fromPlugin')) { |
722 | 711 | // if object already has an id : it's a 'rename' of an existing |
723 | 712 | if (this.object.get('id')) { |
... | ... | @@ -737,16 +726,18 @@ Ext.define('amdaUI.CatalogUI', { |
737 | 726 | module.linkedNode.toRename = true; |
738 | 727 | } |
739 | 728 | module.linkedNode.create({callback: function () { |
740 | - module.linkedNode.update({notDisplayMsg: notDisplayMsg, callback: function () { | |
741 | - if (onAfterSave) | |
742 | - onAfterSave(); | |
729 | + module.linkedNode.update({notDisplayMsg: notDisplayMsg, callback: function (type,res) { | |
730 | + this.updateSurveyDates(res); | |
731 | + if (onAfterSave) | |
732 | + onAfterSave(); | |
743 | 733 | }, scope: this}, "", notDisplayMsg); |
744 | 734 | }, scope: this}); |
745 | 735 | } else { |
746 | 736 | //update |
747 | - module.linkedNode.update({notDisplayMsg: notDisplayMsg, callback: function () { | |
748 | - if (onAfterSave) | |
749 | - onAfterSave(); | |
737 | + module.linkedNode.update({notDisplayMsg: notDisplayMsg, callback: function (type,res) { | |
738 | + this.updateSurveyDates(res); | |
739 | + if (onAfterSave) | |
740 | + onAfterSave(); | |
750 | 741 | }, scope: this}); |
751 | 742 | } |
752 | 743 | } |
... | ... | @@ -755,58 +746,52 @@ Ext.define('amdaUI.CatalogUI', { |
755 | 746 | if (this.updateObject()) |
756 | 747 | { |
757 | 748 | var basicForm = this.formPanel.getForm(); |
758 | - // if there's at least one record in the store of TTGrid | |
759 | - if (this.TTGrid.getStore().getTotalCount() > 0) | |
760 | - { | |
761 | 749 | // update TimeTable object which the content of form |
762 | 750 | |
763 | - basicForm.updateRecord(this.object); | |
764 | - var me = this; | |
765 | - this.checkIntervalsStatusForSave(function () { | |
766 | - //Name validation | |
767 | - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); | |
768 | - | |
769 | - if (!module) | |
751 | + basicForm.updateRecord(this.object); | |
752 | + var me = this; | |
753 | + this.checkIntervalsStatusForSave(function () { | |
754 | + //Name validation | |
755 | + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); | |
756 | + | |
757 | + if (!module) | |
758 | + return; | |
759 | + module.linkedNode.isValidName(me.fieldName.getValue(), function (res) | |
760 | + { | |
761 | + if (!res) { | |
762 | + me.fieldName.validFlag = 'Error during object validation'; | |
763 | + myDesktopApp.errorMsg(me.fieldName.validFlag); | |
764 | + me.fieldName.validate(); | |
770 | 765 | return; |
771 | - module.linkedNode.isValidName(me.fieldName.getValue(), function (res) | |
772 | - { | |
773 | - if (!res) { | |
774 | - me.fieldName.validFlag = 'Error during object validation'; | |
775 | - myDesktopApp.errorMsg(me.fieldName.validFlag); | |
776 | - me.fieldName.validate(); | |
777 | - return; | |
778 | - } | |
766 | + } | |
779 | 767 | |
780 | - if (!res.valid) { | |
781 | - if (res.error) { | |
782 | - if (res.error.search('subtree') != -1) { | |
783 | - Ext.MessageBox.show({title: 'Warning', | |
784 | - msg: res.error + '<br/>Do you want to overwrite it?', | |
785 | - width: 300, | |
786 | - buttons: Ext.MessageBox.OKCANCEL, | |
787 | - fn: me.overwriteProcess, | |
788 | - icon: Ext.MessageBox.WARNING, | |
789 | - scope: me | |
790 | - }); | |
791 | - me.fieldName.validFlag = true; | |
792 | - } else | |
793 | - me.fieldName.validFlag = res.error; | |
794 | - } else { | |
795 | - me.fieldName.validFlag = 'Invalid object name'; | |
796 | - myDesktopApp.errorMsg(me.fieldName.validFlag); | |
797 | - } | |
798 | - me.fieldName.validate(); | |
799 | - return; | |
768 | + if (!res.valid) { | |
769 | + if (res.error) { | |
770 | + if (res.error.search('subtree') != -1) { | |
771 | + Ext.MessageBox.show({title: 'Warning', | |
772 | + msg: res.error + '<br/>Do you want to overwrite it?', | |
773 | + width: 300, | |
774 | + buttons: Ext.MessageBox.OKCANCEL, | |
775 | + fn: me.overwriteProcess, | |
776 | + icon: Ext.MessageBox.WARNING, | |
777 | + scope: me | |
778 | + }); | |
779 | + me.fieldName.validFlag = true; | |
780 | + } else | |
781 | + me.fieldName.validFlag = res.error; | |
782 | + } else { | |
783 | + me.fieldName.validFlag = 'Invalid object name'; | |
784 | + myDesktopApp.errorMsg(me.fieldName.validFlag); | |
800 | 785 | } |
801 | - | |
802 | - me.fieldName.validFlag = true; | |
803 | 786 | me.fieldName.validate(); |
804 | - me.saveProcess(false, onAfterSave, notDisplayMsg); | |
805 | - }); | |
787 | + return; | |
788 | + } | |
789 | + | |
790 | + me.fieldName.validFlag = true; | |
791 | + me.fieldName.validate(); | |
792 | + me.saveProcess(false, onAfterSave, notDisplayMsg); | |
806 | 793 | }); |
807 | - } else { | |
808 | - Ext.Msg.alert('No intervals', 'Your catalog is invalid, <br>you must have at least one interval'); | |
809 | - } | |
794 | + }); | |
810 | 795 | } |
811 | 796 | }, |
812 | 797 | |
... | ... |
php/classes/CatalogMgr.php
... | ... | @@ -92,6 +92,8 @@ class CatalogMgr extends TimeTableMgr |
92 | 92 | else |
93 | 93 | return array('error' => 'Unknown error during intervals save'); |
94 | 94 | } |
95 | + $result['minStart'] = TimeUtils::stamp2iso($resultSaveInt['minStart']); | |
96 | + $result['maxStop'] = TimeUtils::stamp2iso($resultSaveInt['maxStop']); | |
95 | 97 | } |
96 | 98 | return $result; |
97 | 99 | } |
... | ... |
php/classes/TimeTableMgr.php
... | ... | @@ -148,7 +148,7 @@ class TimeTableMgr extends AmdaObjectMgr |
148 | 148 | if ($tmpFileExist) { |
149 | 149 | unlink($ttFilePath . ".tmp"); |
150 | 150 | } |
151 | - return ['id' => $p->id, 'info' => $result['info']]; | |
151 | + return $result; | |
152 | 152 | } catch (Exception $exception) { |
153 | 153 | //Restore TT file |
154 | 154 | if ($tmpFileExist) { |
... | ... | @@ -524,9 +524,19 @@ class TimeTableMgr extends AmdaObjectMgr |
524 | 524 | $objToGet->removeChild($toRemove); |
525 | 525 | unset($toRemove); |
526 | 526 | } |
527 | + $minStart =0; | |
528 | + $maxStop=0; | |
527 | 529 | |
528 | 530 | //add new intervals |
529 | 531 | foreach ($intervals as $interval) { |
532 | + $startTime = TimeUtils::iso2stamp($interval['start']); | |
533 | + $stopTime = TimeUtils::iso2stamp($interval['stop']); | |
534 | + if ($minStart == 0) | |
535 | + $minStart = $startTime; | |
536 | + elseif ($startTime < $minStart ) | |
537 | + $minStart = $startTime; | |
538 | + if ($stopTime > $maxStop ) | |
539 | + $maxStop = $stopTime; | |
530 | 540 | $newInterval = $this->createIntervalElement($interval, $options); |
531 | 541 | $this->objectDom->documentElement->appendChild($newInterval); |
532 | 542 | } |
... | ... | @@ -538,7 +548,8 @@ class TimeTableMgr extends AmdaObjectMgr |
538 | 548 | |
539 | 549 | unset($this->objectDom); |
540 | 550 | |
541 | - return ['success' => true, 'action' => $action, 'nbIntervals' => count($intervals)]; | |
551 | + return ['success' => true, 'action' => $action, 'nbIntervals' => count($intervals), | |
552 | + 'minStart' => $minStart, 'maxStop' => $maxStop]; | |
542 | 553 | } |
543 | 554 | |
544 | 555 | /** |
... | ... |