Mercurial > lada > lada-client
comparison app/controller/Proben.js @ 293:bd77b6055791
Inherit from Base controller
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Fri, 09 Aug 2013 15:00:07 +0200 |
parents | 0d6552bb28ea |
children | 94884cd8f8c0 |
comparison
equal
deleted
inserted
replaced
292:73a2c114db64 | 293:bd77b6055791 |
---|---|
1 /** | |
2 * Controller for Proben | |
3 */ | |
1 Ext.define('Lada.controller.Proben', { | 4 Ext.define('Lada.controller.Proben', { |
2 extend: 'Ext.app.Controller', | 5 extend: 'Lada.controller.Base', |
3 views: [ | 6 views: [ |
4 'proben.Edit', | 7 'proben.Edit', |
5 'proben.Create' | 8 'proben.Create' |
6 ], | 9 ], |
7 stores: [ | 10 stores: [ |
12 'Orte', | 15 'Orte', |
13 'Messungen' | 16 'Messungen' |
14 ], | 17 ], |
15 init: function() { | 18 init: function() { |
16 console.log('Initialising the Proben controller'); | 19 console.log('Initialising the Proben controller'); |
20 this.callParent(); | |
21 }, | |
22 addListeners: function() { | |
17 this.control({ | 23 this.control({ |
18 // CSS like selector to select element in the viewport. See | |
19 // ComponentQuery documentation for more details. | |
20 'probenlist': { | 24 'probenlist': { |
21 itemdblclick: this.editProbe | 25 itemdblclick: this.editItem |
22 }, | 26 }, |
23 'probenlist toolbar button[action=add]': { | 27 'probenlist toolbar button[action=add]': { |
24 click: this.addProbe | 28 click: this.addItem |
25 }, | 29 }, |
26 'probencreate button[action=save]': { | 30 'probencreate button[action=save]': { |
27 click: this.saveProbe | 31 click: this.saveItem |
28 }, | 32 }, |
29 'probenedit button[action=save]': { | 33 'probenedit button[action=save]': { |
30 click: this.saveProbe | 34 click: this.saveItem |
31 }, | 35 }, |
32 'probencreate form': { | 36 'probencreate form': { |
33 savesuccess: this.createSuccess, | 37 savesuccess: this.createSuccess, |
34 savefailure: this.createFailure | 38 savefailure: this.createFailure |
35 }, | 39 }, |
37 savesuccess: this.editSuccess, | 41 savesuccess: this.editSuccess, |
38 savefailure: this.editFailure | 42 savefailure: this.editFailure |
39 } | 43 } |
40 }); | 44 }); |
41 }, | 45 }, |
42 saveProbe: function(button) { | 46 addItem: function(button) { |
43 console.log('Saving Probe'); | |
44 var form = button.up('window').down('form'); | |
45 form.commit(); | |
46 }, | |
47 addProbe: function(button) { | |
48 console.log('Adding new Probe'); | 47 console.log('Adding new Probe'); |
49 var view = Ext.widget('probencreate'); | 48 var view = Ext.widget('probencreate'); |
50 }, | 49 }, |
51 editProbe: function(grid, record) { | 50 editItem: function(grid, record) { |
52 console.log('Editing Probe'); | 51 console.log('Editing Probe'); |
53 var id = record.get('probeId'); | 52 var id = record.get('probeId'); |
54 var view = Ext.widget('probenedit', {modelId: id}); | 53 var view = Ext.widget('probenedit', {modelId: id}); |
55 | 54 |
56 // Load Zusatzwerte | 55 // Load Zusatzwerte |
98 // Open Editdialog | 97 // Open Editdialog |
99 var json = Ext.decode(response.responseText); | 98 var json = Ext.decode(response.responseText); |
100 if (json) { | 99 if (json) { |
101 var probeId = json.data.probeId; | 100 var probeId = json.data.probeId; |
102 var probe = store.findRecord("probeId", probeId); | 101 var probe = store.findRecord("probeId", probeId); |
103 this.editProbe(null, probe); | 102 this.editItem(null, probe); |
104 } | 103 } |
105 } | 104 } |
106 }); | |
107 }, | |
108 createFailure: function(form, record, response) { | |
109 Ext.MessageBox.show({ | |
110 title: 'Fehler beim Speichern', | |
111 msg: form.message, | |
112 icon: Ext.MessageBox.ERROR, | |
113 buttons: Ext.Msg.OK | |
114 }); | 105 }); |
115 }, | 106 }, |
116 editSuccess: function(form, record, response) { | 107 editSuccess: function(form, record, response) { |
117 // Reload store | 108 // Reload store |
118 var store = this.getProbenStore(); | 109 var store = this.getProbenStore(); |
119 store.reload(); | 110 store.reload(); |
120 var win = form.up('window'); | 111 var win = form.up('window'); |
121 win.close(); | 112 win.close(); |
122 }, | |
123 editFailure: function(form, record, response) { | |
124 Ext.MessageBox.show({ | |
125 title: 'Fehler beim Speichern', | |
126 msg: form.message, | |
127 icon: Ext.MessageBox.ERROR, | |
128 buttons: Ext.Msg.OK | |
129 }); | |
130 } | 113 } |
131 }); | 114 }); |