Mercurial > lada > lada-client
comparison app/view/window/ProbeEdit.js @ 706:3e4be37e3e46
Re-Enable Add/Delete Button of a MessungGrid in Cases when the User owns the Probe
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Fri, 27 Mar 2015 14:48:42 +0100 |
parents | b0f1dcdf981d |
children | c632c7c34029 |
comparison
equal
deleted
inserted
replaced
705:cc9107d9be17 | 706:3e4be37e3e46 |
---|---|
47 this.width = 700; | 47 this.width = 700; |
48 this.height = Ext.getBody().getViewSize().height - 30; | 48 this.height = Ext.getBody().getViewSize().height - 30; |
49 // InitialConfig is the config object passed to the constructor on | 49 // InitialConfig is the config object passed to the constructor on |
50 // creation of this window. We need to pass it throuh to the form as | 50 // creation of this window. We need to pass it throuh to the form as |
51 // we need the "modelId" param to load the correct item. | 51 // we need the "modelId" param to load the correct item. |
52 | |
53 this.items = [{ | 52 this.items = [{ |
54 border: 0, | 53 border: 0, |
55 autoScroll: true, | 54 autoScroll: true, |
56 items: [{ | 55 items: [{ |
57 xtype: 'probeform', | 56 xtype: 'probeform', |
107 this.callParent(arguments); | 106 this.callParent(arguments); |
108 }, | 107 }, |
109 | 108 |
110 initData: function() { | 109 initData: function() { |
111 this.clearMessages(); | 110 this.clearMessages(); |
111 me = this; | |
112 Ext.ClassManager.get('Lada.model.Probe').load(this.record.get('id'), { | 112 Ext.ClassManager.get('Lada.model.Probe').load(this.record.get('id'), { |
113 failure: function(record, action) { | 113 failure: function(record, action) { |
114 // TODO | 114 // TODO |
115 console.log("An unhandled Failure occured. See following Response and Record"); | 115 console.log("An unhandled Failure occured. See following Response and Record"); |
116 console.log(response); | 116 console.log(response); |
117 console.log(record); | 117 console.log(record); |
118 }, | 118 }, |
119 success: function(record, response) { | 119 success: function(record, response) { |
120 this.down('probeform').setRecord(record); | 120 this.down('probeform').setRecord(record); |
121 this.record = record; | 121 this.record = record; |
122 owner = this.record.get('owner'); | |
123 | |
124 if (owner) { | |
125 //Always allow to Add Messungen. | |
126 me.enableAddMessungen(); | |
127 } | |
128 | |
122 var json = Ext.decode(response.response.responseText); | 129 var json = Ext.decode(response.response.responseText); |
123 if (json) { | 130 if (json) { |
124 this.setMessages(json.errors, json.warnings); | 131 this.setMessages(json.errors, json.warnings); |
125 } | 132 } |
126 }, | 133 }, |
129 | 136 |
130 // If the Probe is ReadOnly, disable Inputfields and grids | 137 // If the Probe is ReadOnly, disable Inputfields and grids |
131 if (this.record.get('readonly') == true){ | 138 if (this.record.get('readonly') == true){ |
132 this.down('probeform').setReadOnly(true); | 139 this.down('probeform').setReadOnly(true); |
133 this.disableChildren(); | 140 this.disableChildren(); |
134 | 141 } |
135 //The Owner of a Probe is always allowed to add a Messung. | 142 }, |
136 // ToDo ist it required to check if a Status exists? | 143 |
137 // ToDo this doesn't work here because the owner is unknown when this code | 144 enableAddMessungen: function(){ |
138 // is executed. | 145 this.down('fset[name=messungen]').down('messunggrid').setReadOnly(false); |
139 if (this.record.get('owner') == true){ | |
140 //allow to add Messungen | |
141 this.down('fset[name=messungen]').down('messunggrid').down('button[name=add]').enable(); | |
142 } | |
143 } | |
144 }, | 146 }, |
145 | 147 |
146 disableChildren: function(){ | 148 disableChildren: function(){ |
147 this.down('fset[name=messungen]').down('messunggrid').setReadOnly(true); | 149 this.down('fset[name=messungen]').down('messunggrid').setReadOnly(true); |
148 this.down('fset[name=orte]').down('ortgrid').setReadOnly(true); | 150 this.down('fset[name=orte]').down('ortgrid').setReadOnly(true); |
149 this.down('fset[name=probenzusatzwerte]').down('probenzusatzwertgrid').setReadOnly(true); | 151 this.down('fset[name=probenzusatzwerte]').down('probenzusatzwertgrid').setReadOnly(true); |
150 this.down('fset[name=pkommentare]').down('pkommentargrid').setReadOnly(true); | 152 this.down('fset[name=pkommentare]').down('pkommentargrid').setReadOnly(true); |
151 }, | 153 }, |
152 | 154 |
153 enableChildren: function(){ | 155 enableChildren: function(){ |
154 this.down('fset[name=messungen]').down('messunggrid').setReadOnly(false); | 156 this.down('fset[name=messungen]').down('messunggrid').setReadOnly(false); |
155 this.down('fset[name=orte]').down('ortgrid').setReadOnly(false); | 157 this.down('fset[name=orte]').down('ortgrid').setReadOnly(false); |
156 this.down('fset[name=probenzusatzwerte]').down('probenzusatzwertgrid').setReadOnly(false); | 158 this.down('fset[name=probenzusatzwerte]').down('probenzusatzwertgrid').setReadOnly(false); |
157 this.down('fset[name=pkommentare]').down('pkommentargrid').setReadOnly(false); | 159 this.down('fset[name=pkommentare]').down('pkommentargrid').setReadOnly(false); |
158 }, | 160 }, |
159 | 161 |
160 setMessages: function(errors, warnings) { | 162 setMessages: function(errors, warnings) { |
161 this.down('probeform').setMessages(errors, warnings); | 163 this.down('probeform').setMessages(errors, warnings); |
162 var errorOrtText = ''; | 164 var errorOrtText = ''; |