Commit 02e89fbe8c0ba131de2993b31c9b93ff12d26326

Authored by Hacene SI HADJ MOHAND
1 parent 2190f380

rm_6903 ok

js/app/models/InteractiveNode.js
... ... @@ -199,7 +199,7 @@ Ext.define('amdaModel.InteractiveNode', {
199 199 opt.callback.call(scope,'update');
200 200 }
201 201  
202   - Ext.Msg.alert('Complete', 'Object '+this.get('object').get('name')+' has been modified');
  202 + Ext.Msg.alert('Complete', 'Object '+this.get('object').get('name')+' has been modified', this);
203 203 // fix the modifications for object
204 204 this.get('object').commit();
205 205  
... ...
js/app/views/CatalogUI.js
... ... @@ -116,8 +116,31 @@ Ext.define('amdaUI.CatalogUI', {
116 116 this.object.set('nbIntervals',this.TTGrid.getStore().getTotalCount());
117 117 this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals'));
118 118 },
119   - generateTT : function(catId){
120   - var catObj = Ext.create('amdaModel.TimeTable');
  119 + generateTT : function(){
  120 + console.log(this);
  121 + if(this.fclose()){
  122 + Ext.Msg.confirm('Generate TT', 'Current Catalog has been modified.\nDo you want to include these changes in the generated Time Table ?' ,
  123 + function (btn, text){
  124 + if (btn == 'yes'){
  125 + // mark this.closed as true before the call to close() as that will fire the beforeclose event again
  126 + if(this.object.get('id') ==""){
  127 + // case of creation of catalog
  128 + this.saveCatalog(true);
  129 + }else{
  130 + // casse existing catalog
  131 + this.saveProcess(false,true);
  132 + }
  133 + return
  134 + //win.close();
  135 + }
  136 + }, this);
  137 +
  138 + }else{
  139 + this.createTT(this.object.get('id'));
  140 + }
  141 + },
  142 + createTT : function(catId){
  143 + var catObj = Ext.create('amdaModel.TimeTable');
121 144 var timeTabNode = Ext.create('amdaModel.TimeTableNode',{leaf : true});
122 145 catObj.set('relatedCatalogId', catId)
123 146 creatDate=new Date(this.object.get('created'));
... ... @@ -133,9 +156,6 @@ Ext.define('amdaUI.CatalogUI', {
133 156 // edit newNode into Parameter Module with node as contextNode
134 157 timeTabNode.editInModule();
135 158 });
136   -
137   -
138   -
139 159 },
140 160 onAfterInit: function(result, e)
141 161 {
... ... @@ -473,7 +493,7 @@ Ext.define('amdaUI.CatalogUI', {
473 493 /*
474 494 * save method called by Save button
475 495 */
476   - saveProcess : function(toRename)
  496 + saveProcess : function(toRename, onAfterSave)
477 497 {
478 498 var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
479 499 // store / columns are the same - not needed to reconfigure grid
... ... @@ -488,7 +508,7 @@ Ext.define('amdaUI.CatalogUI', {
488 508 var obj = module.linkedNode.get('object');
489 509 // synchronisation of objects
490 510 this.object = obj;
491   - module.linkedNode.create();
  511 + module.linkedNode.create({callback : function() {if (onAfterSave) this.createTT(this.object.get('id'));}, scope : this});
492 512 }
493 513 // if the name has been modified this is a creation
494 514 else if (this.fclose()) {
... ... @@ -509,13 +529,73 @@ Ext.define('amdaUI.CatalogUI', {
509 529 this.object = obj;
510 530 if (toRename) module.linkedNode.toRename = true;
511 531 }
512   - module.linkedNode.create({callback : function() {module.linkedNode.update();}, scope : this});
  532 + module.linkedNode.create({callback : function() {module.linkedNode.update({callback : function() {if (onAfterSave) this.createTT(this.object.get('id'));}, scope : this});}, scope : this});
513 533 } else {
514 534 //update
515   - module.linkedNode.update();
  535 + module.linkedNode.update({callback : function() {if (onAfterSave) this.createTT(this.object.get('id'));}, scope : this});
516 536 }
517 537 }
518 538 },
  539 + saveCatalog : function (onAfterSave){
  540 + if (this.updateObject())
  541 + {
  542 + var basicForm = this.formPanel.getForm();
  543 + // if there's at least one record in the store of TTGrid
  544 + if (this.TTGrid.getStore().getTotalCount() > 0)
  545 + {
  546 + // update TimeTable object which the content of form
  547 + basicForm.updateRecord(this.object);
  548 +
  549 + var me = this;
  550 + this.checkIntervalsStatusForSave(function () {
  551 + //Name validation
  552 + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
  553 +
  554 + if (!module) return;
  555 + module.linkedNode.isValidName(me.fieldName.getValue(), function (res)
  556 + {
  557 + if (!res) {
  558 + me.fieldName.validFlag = 'Error during object validation';
  559 + myDesktopApp.errorMsg(me.fieldName.validFlag);
  560 + me.fieldName.validate();
  561 + return;
  562 + }
  563 +
  564 + if (!res.valid) {
  565 + if (res.error) {
  566 + if (res.error.search('subtree') != -1) {
  567 + Ext.MessageBox.show({title:'Warning',
  568 + msg: res.error+'<br/>Do you want to overwrite it?',
  569 + width: 300,
  570 + buttons: Ext.MessageBox.OKCANCEL,
  571 + fn : me.overwriteProcess,
  572 + icon: Ext.MessageBox.WARNING,
  573 + scope : me
  574 + });
  575 + me.fieldName.validFlag = true;
  576 + }
  577 + else
  578 + me.fieldName.validFlag = res.error;
  579 + }
  580 + else {
  581 + me.fieldName.validFlag = 'Invalid object name';
  582 + myDesktopApp.errorMsg(me.fieldName.validFlag);
  583 + }
  584 + me.fieldName.validate();
  585 + return;
  586 + }
  587 +
  588 + me.fieldName.validFlag = true;
  589 + me.fieldName.validate();
  590 + me.saveProcess(false, onAfterSave);
  591 + });
  592 + });
  593 + }
  594 + else {
  595 + Ext.Msg.alert('No intervals', 'Your catalog is invalid, <br>you must have at least one interval');
  596 + }
  597 + }
  598 + },
519 599  
520 600 /**
521 601 * overwrite metod called by Save button
... ... @@ -767,64 +847,8 @@ Ext.define(&#39;amdaUI.CatalogUI&#39;, {
767 847 scope : this,
768 848 handler: function ()
769 849 {
770   - if (this.updateObject())
771   - {
772   - var basicForm = this.formPanel.getForm();
773   - // if there's at least one record in the store of TTGrid
774   - if (this.TTGrid.getStore().getTotalCount() > 0)
775   - {
776   - // update TimeTable object which the content of form
777   - basicForm.updateRecord(this.object);
778   -
779   - var me = this;
780   - this.checkIntervalsStatusForSave(function () {
781   - //Name validation
782   - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
783   -
784   - if (!module) return;
785   - module.linkedNode.isValidName(me.fieldName.getValue(), function (res)
786   - {
787   - if (!res) {
788   - me.fieldName.validFlag = 'Error during object validation';
789   - myDesktopApp.errorMsg(me.fieldName.validFlag);
790   - me.fieldName.validate();
791   - return;
792   - }
793   -
794   - if (!res.valid) {
795   - if (res.error) {
796   - if (res.error.search('subtree') != -1) {
797   - Ext.MessageBox.show({title:'Warning',
798   - msg: res.error+'<br/>Do you want to overwrite it?',
799   - width: 300,
800   - buttons: Ext.MessageBox.OKCANCEL,
801   - fn : me.overwriteProcess,
802   - icon: Ext.MessageBox.WARNING,
803   - scope : me
804   - });
805   - me.fieldName.validFlag = true;
806   - }
807   - else
808   - me.fieldName.validFlag = res.error;
809   - }
810   - else {
811   - me.fieldName.validFlag = 'Invalid object name';
812   - myDesktopApp.errorMsg(me.fieldName.validFlag);
813   - }
814   - me.fieldName.validate();
815   - return;
816   - }
817   -
818   - me.fieldName.validFlag = true;
819   - me.fieldName.validate();
820   - me.saveProcess(false);
821   - });
822   - });
823   - }
824   - else {
825   - Ext.Msg.alert('No intervals', 'Your catalog is invalid, <br>you must have at least one interval');
826   - }
827   - }
  850 + this.saveCatalog();
  851 +
828 852 }
829 853 },{
830 854 type: 'button',
... ... @@ -896,8 +920,8 @@ Ext.define(&#39;amdaUI.CatalogUI&#39;, {
896 920 //dock: 'bottom',
897 921 //ui: 'footer',
898 922 handler: function() {
899   - this.generateTT(this.object.get('id'));
900   - }
  923 + this.generateTT(this.object.get('id'));
  924 + }
901 925 }]},
902 926 ]
903 927 },
... ...