Commit dd143fd09a9bcbe4872c1cf34c89244fbabe03c5

Authored by Benjamin Renard
2 parents ba9b1b7d 5b64c444

Fix conflit

Showing 2 changed files with 106 additions and 73 deletions   Show diff stats
js/app/models/InteractiveNode.js
... ... @@ -194,12 +194,18 @@ Ext.define('amdaModel.InteractiveNode', {
194 194  
195 195 if (opt)
196 196 {
  197 +
197 198 var scope = opt.scope ? opt.scope : this;
198 199 if (opt.callback)
199 200 opt.callback.call(scope,'update');
  201 +
200 202 }
201   -
  203 + if(opt.notDisplayMsg){
  204 + //do nothing
  205 + }else{
202 206 Ext.Msg.alert('Complete', 'Object '+this.get('object').get('name')+' has been modified');
  207 + }
  208 +
203 209 // fix the modifications for object
204 210 this.get('object').commit();
205 211  
... ... @@ -290,8 +296,12 @@ Ext.define('amdaModel.InteractiveNode', {
290 296 // set ownerTree panel as the active tab - to enable selection of this node his ownerTree must have a view
291 297 this.myGetOwnerTree().ownerCt.setActiveTab(this.myGetOwnerTree());
292 298 }
293   -
294   - Ext.Msg.alert('Complete', 'New object '+this.get('object').get('name')+' has been created');
  299 + if(opt.notDisplayMsg){
  300 + //do nothing
  301 + }else{
  302 + Ext.Msg.alert('Complete', 'New object '+this.get('object').get('name')+' has been created');
  303 + }
  304 +
295 305 // expand the contextNode
296 306 this.get('contextNode').expand(false, function() {
297 307 if (!this.get('contextNode').findChild('text',this.get('text'))) {
... ...
js/app/views/CatalogUI.js
... ... @@ -116,8 +116,30 @@ 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 + if(this.fclose()){
  121 + Ext.Msg.confirm('Generate TT', 'Current Catalog has been modified.\nDo you want to save it to include these changes in the generated Time Table ?' ,
  122 + function (btn, text){
  123 + if (btn == 'yes'){
  124 + // mark this.closed as true before the call to close() as that will fire the beforeclose event again
  125 + if(this.object.get('id') ==""){
  126 + // case of creation of catalog
  127 + this.saveCatalog(true,true);
  128 + }else{
  129 + // casse existing catalog
  130 + this.saveProcess(false,true,true);
  131 + }
  132 + return;
  133 + }
  134 + }, this);
  135 +
  136 + }else{
  137 + this.createTT(this.object.get('id'));
  138 + return;
  139 + }
  140 + },
  141 + createTT : function(catId){
  142 + var catObj = Ext.create('amdaModel.TimeTable');
121 143 var timeTabNode = Ext.create('amdaModel.TimeTableNode',{leaf : true});
122 144 catObj.set('relatedCatalogId', catId)
123 145 creatDate=new Date(this.object.get('created'));
... ... @@ -133,9 +155,6 @@ Ext.define('amdaUI.CatalogUI', {
133 155 // edit newNode into Parameter Module with node as contextNode
134 156 timeTabNode.editInModule();
135 157 });
136   -
137   -
138   -
139 158 },
140 159 onAfterInit: function(result, e)
141 160 {
... ... @@ -480,7 +499,7 @@ Ext.define('amdaUI.CatalogUI', {
480 499 /*
481 500 * save method called by Save button
482 501 */
483   - saveProcess : function(toRename)
  502 + saveProcess : function(toRename, onAfterSave, notDisplayMsg)
484 503 {
485 504 var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
486 505 // store / columns are the same - not needed to reconfigure grid
... ... @@ -495,7 +514,7 @@ Ext.define('amdaUI.CatalogUI', {
495 514 var obj = module.linkedNode.get('object');
496 515 // synchronisation of objects
497 516 this.object = obj;
498   - module.linkedNode.create();
  517 + module.linkedNode.create({notDisplayMsg:notDisplayMsg, callback : function() {if (onAfterSave) this.createTT(this.object.get('id'));}, scope : this});
499 518 }
500 519 // if the name has been modified this is a creation
501 520 else if (this.fclose()) {
... ... @@ -516,13 +535,73 @@ Ext.define('amdaUI.CatalogUI', {
516 535 this.object = obj;
517 536 if (toRename) module.linkedNode.toRename = true;
518 537 }
519   - module.linkedNode.create({callback : function() {module.linkedNode.update();}, scope : this});
  538 + module.linkedNode.create({callback : function() {module.linkedNode.update({notDisplayMsg:notDisplayMsg, callback : function() {if (onAfterSave) this.createTT(this.object.get('id'));}, scope : this},"",notDisplayMsg);}, scope : this});
520 539 } else {
521 540 //update
522   - module.linkedNode.update();
  541 + module.linkedNode.update({notDisplayMsg:notDisplayMsg,callback : function() {if (onAfterSave) this.createTT(this.object.get('id'));}, scope : this});
523 542 }
524 543 }
525 544 },
  545 + saveCatalog : function (onAfterSave,notDisplayMsg){
  546 + if (this.updateObject())
  547 + {
  548 + var basicForm = this.formPanel.getForm();
  549 + // if there's at least one record in the store of TTGrid
  550 + if (this.TTGrid.getStore().getTotalCount() > 0)
  551 + {
  552 + // update TimeTable object which the content of form
  553 + basicForm.updateRecord(this.object);
  554 +
  555 + var me = this;
  556 + this.checkIntervalsStatusForSave(function () {
  557 + //Name validation
  558 + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
  559 +
  560 + if (!module) return;
  561 + module.linkedNode.isValidName(me.fieldName.getValue(), function (res)
  562 + {
  563 + if (!res) {
  564 + me.fieldName.validFlag = 'Error during object validation';
  565 + myDesktopApp.errorMsg(me.fieldName.validFlag);
  566 + me.fieldName.validate();
  567 + return;
  568 + }
  569 +
  570 + if (!res.valid) {
  571 + if (res.error) {
  572 + if (res.error.search('subtree') != -1) {
  573 + Ext.MessageBox.show({title:'Warning',
  574 + msg: res.error+'<br/>Do you want to overwrite it?',
  575 + width: 300,
  576 + buttons: Ext.MessageBox.OKCANCEL,
  577 + fn : me.overwriteProcess,
  578 + icon: Ext.MessageBox.WARNING,
  579 + scope : me
  580 + });
  581 + me.fieldName.validFlag = true;
  582 + }
  583 + else
  584 + me.fieldName.validFlag = res.error;
  585 + }
  586 + else {
  587 + me.fieldName.validFlag = 'Invalid object name';
  588 + myDesktopApp.errorMsg(me.fieldName.validFlag);
  589 + }
  590 + me.fieldName.validate();
  591 + return;
  592 + }
  593 +
  594 + me.fieldName.validFlag = true;
  595 + me.fieldName.validate();
  596 + me.saveProcess(false, onAfterSave,notDisplayMsg);
  597 + });
  598 + });
  599 + }
  600 + else {
  601 + Ext.Msg.alert('No intervals', 'Your catalog is invalid, <br>you must have at least one interval');
  602 + }
  603 + }
  604 + },
526 605  
527 606 /**
528 607 * overwrite metod called by Save button
... ... @@ -749,7 +828,7 @@ console.log(direction);
749 828  
750 829 var me = this;
751 830  
752   - Ext.Msg.prompt('Define Parameters', 'Please enter parameters number:', function(btn, text){
  831 + Ext.Msg.prompt('Create catalog', 'Enter the number of columns:', function(btn, text){
753 832 if (btn == 'ok'){
754 833 module.createLinkedNode();
755 834 module.createObject();
... ... @@ -780,64 +859,8 @@ console.log(direction);
780 859 scope : this,
781 860 handler: function ()
782 861 {
783   - if (this.updateObject())
784   - {
785   - var basicForm = this.formPanel.getForm();
786   - // if there's at least one record in the store of TTGrid
787   - if (this.TTGrid.getStore().getTotalCount() > 0)
788   - {
789   - // update TimeTable object which the content of form
790   - basicForm.updateRecord(this.object);
791   -
792   - var me = this;
793   - this.checkIntervalsStatusForSave(function () {
794   - //Name validation
795   - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
796   -
797   - if (!module) return;
798   - module.linkedNode.isValidName(me.fieldName.getValue(), function (res)
799   - {
800   - if (!res) {
801   - me.fieldName.validFlag = 'Error during object validation';
802   - myDesktopApp.errorMsg(me.fieldName.validFlag);
803   - me.fieldName.validate();
804   - return;
805   - }
806   -
807   - if (!res.valid) {
808   - if (res.error) {
809   - if (res.error.search('subtree') != -1) {
810   - Ext.MessageBox.show({title:'Warning',
811   - msg: res.error+'<br/>Do you want to overwrite it?',
812   - width: 300,
813   - buttons: Ext.MessageBox.OKCANCEL,
814   - fn : me.overwriteProcess,
815   - icon: Ext.MessageBox.WARNING,
816   - scope : me
817   - });
818   - me.fieldName.validFlag = true;
819   - }
820   - else
821   - me.fieldName.validFlag = res.error;
822   - }
823   - else {
824   - me.fieldName.validFlag = 'Invalid object name';
825   - myDesktopApp.errorMsg(me.fieldName.validFlag);
826   - }
827   - me.fieldName.validate();
828   - return;
829   - }
830   -
831   - me.fieldName.validFlag = true;
832   - me.fieldName.validate();
833   - me.saveProcess(false);
834   - });
835   - });
836   - }
837   - else {
838   - Ext.Msg.alert('No intervals', 'Your catalog is invalid, <br>you must have at least one interval');
839   - }
840   - }
  862 + this.saveCatalog();
  863 +
841 864 }
842 865 },{
843 866 type: 'button',
... ... @@ -909,8 +932,8 @@ console.log(direction);
909 932 //dock: 'bottom',
910 933 //ui: 'footer',
911 934 handler: function() {
912   - this.generateTT(this.object.get('id'));
913   - }
  935 + this.generateTT(this.object.get('id'));
  936 + }
914 937 }]},
915 938 ]
916 939 },
... ...