Mercurial > lada > lada-client
comparison app/view/window/MessungEdit.js @ 690:e88381fb3bdb
Use treeModiefied timestamp to determine if working with 'old' objects.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 25 Mar 2015 16:46:48 +0100 |
parents | 6a6d1b02a1a3 |
children | 817524db4017 |
comparison
equal
deleted
inserted
replaced
689:c07419f07a0c | 690:e88381fb3bdb |
---|---|
24 maximizable: true, | 24 maximizable: true, |
25 autoshow: true, | 25 autoshow: true, |
26 autoscroll: true, | 26 autoscroll: true, |
27 layout: 'fit', | 27 layout: 'fit', |
28 constrain: true, | 28 constrain: true, |
29 | |
30 probe: null, | |
31 parentWindow: null, | |
29 record: null, | 32 record: null, |
30 grid: null, | 33 grid: null, |
31 | 34 |
32 initComponent: function() { | 35 initComponent: function() { |
33 if (this.record === null) { | 36 if (this.record === null) { |
34 Ext.Msg.alert('Keine valide Messung ausgewählt!'); | 37 Ext.Msg.alert('Keine valide Messung ausgewählt!'); |
38 this.callParent(arguments); | |
39 return; | |
40 } | |
41 if (this.probe === null) { | |
42 Ext.Msg.alert('Zu der Messung existiert keine Probe!'); | |
35 this.callParent(arguments); | 43 this.callParent(arguments); |
36 return; | 44 return; |
37 } | 45 } |
38 this.title = 'Messung ' + this.record.get('nebenprobenNr'); | 46 this.title = 'Messung ' + this.record.get('nebenprobenNr'); |
39 this.buttons = [{ | 47 this.buttons = [{ |
86 this.callParent(arguments); | 94 this.callParent(arguments); |
87 }, | 95 }, |
88 | 96 |
89 initData: function() { | 97 initData: function() { |
90 this.clearMessages(); | 98 this.clearMessages(); |
91 this.down('messungform').setRecord(this.record); | |
92 Ext.ClassManager.get('Lada.model.Messung').load(this.record.get('id'), { | 99 Ext.ClassManager.get('Lada.model.Messung').load(this.record.get('id'), { |
93 failure: function(record) { | 100 failure: function(record) { |
94 // TODO | 101 // TODO |
95 console.log(record); | 102 console.log(record); |
96 }, | 103 }, |
97 success: function(record, response) { | 104 success: function(record, response) { |
105 var me = this; | |
106 if (this.probe.get('treeModified') < record.get('treeModified')) { | |
107 Ext.Msg.show({ | |
108 title: 'Probe nicht aktuell!', | |
109 msg: 'Die zugehörige Probe wurde verändert.\nMöchten Sie zu der Probe zurückkehren und neu laden?\nOhne das erneute Laden der Probe wird das Speichern der Messung nicht möglich sein.', | |
110 buttons: Ext.Msg.OKCANCEL, | |
111 icon: Ext.Msg.WARNING, | |
112 closable: false, | |
113 fn: function(button) { | |
114 if (button === 'ok') { | |
115 me.close(); | |
116 me.parentWindow.initData(); | |
117 } | |
118 else { | |
119 me.record.set('treeModified', me.probe.get('treeModified')); | |
120 } | |
121 } | |
122 }); | |
123 } | |
98 this.down('messungform').setRecord(record); | 124 this.down('messungform').setRecord(record); |
125 this.record = record; | |
99 var json = Ext.decode(response.response.responseText); | 126 var json = Ext.decode(response.response.responseText); |
100 if (json) { | 127 if (json) { |
101 this.setMessages(json.errors, json.warnings); | 128 this.setMessages(json.errors, json.warnings); |
102 } | 129 } |
103 }, | 130 }, |
104 scope: this | 131 scope: this |
105 }); | 132 }); |
106 | |
107 if (this.record.get('readonly') == true){ | |
108 this.down('messungform').setReadOnly(true); | |
109 this.disableChildren(); | |
110 } | |
111 }, | |
112 | |
113 disableChildren: function(){ | |
114 this.down('fset[name=messwerte]').down('messwertgrid').setReadOnly(true); | |
115 this.down('fset[name=messungstatus]').down('statusgrid').setReadOnly(true); | |
116 this.down('fset[name=messungskommentare]').down('mkommentargrid').setReadOnly(true); | |
117 }, | |
118 | |
119 enableChildren: function(){ | |
120 this.down('fset[name=messwerte]').down('messwertgrid').setReadOnly(false); | |
121 this.down('fset[name=messungstatus]').down('statusgrid').setReadOnly(false); | |
122 this.down('fset[name=messungskommentare]').down('mkommentargrid').setReadOnly(false); | |
123 }, | 133 }, |
124 | 134 |
125 setMessages: function(errors, warnings) { | 135 setMessages: function(errors, warnings) { |
126 //todo this is a stub | 136 //todo this is a stub |
127 }, | 137 }, |