comparison app/controller/Messungen.js @ 289:1bda6420c87c

Inherit from Base controller
author Torsten Irländer <torsten.irlaender@intevation.de>
date Fri, 09 Aug 2013 15:00:06 +0200
parents 12ef979e73ce
children c5b8c0d8aec3
comparison
equal deleted inserted replaced
288:ea60be45fd4d 289:1bda6420c87c
1 /**
2 * Controller for Messungen
3 */
1 Ext.define('Lada.controller.Messungen', { 4 Ext.define('Lada.controller.Messungen', {
2 extend: 'Ext.app.Controller', 5 extend: 'Lada.controller.Base',
3 views: [ 6 views: [
4 'messungen.Create', 7 'messungen.Create',
5 'messungen.Edit' 8 'messungen.Edit'
6 ], 9 ],
7 stores: [ 10 stores: [
12 'Status', 15 'Status',
13 'Messgroessen' 16 'Messgroessen'
14 ], 17 ],
15 init: function() { 18 init: function() {
16 console.log('Initialising the Messungen controller'); 19 console.log('Initialising the Messungen controller');
20 },
21 addListeners: function() {
17 this.control({ 22 this.control({
18 // CSS like selector to select element in the viewpzusatzwert. See
19 // ComponentQuery documentation for more details.
20 'messungenlist': { 23 'messungenlist': {
21 itemdblclick: this.editMessung 24 itemdblclick: this.editItem
22 }, 25 },
23 'messungenlist toolbar button[action=add]': { 26 'messungenlist toolbar button[action=add]': {
24 click: this.addMessung 27 click: this.addItem
25 }, 28 },
26 'messungenlist toolbar button[action=delete]': { 29 'messungenlist toolbar button[action=delete]': {
27 click: this.deleteMessung 30 click: this.deleteItem
28 }, 31 },
29 'messungencreate button[action=save]': { 32 'messungencreate button[action=save]': {
30 click: this.saveMessung 33 click: this.saveItem
31 }, 34 },
32 'messungenedit button[action=save]': { 35 'messungenedit button[action=save]': {
33 click: this.saveMessung 36 click: this.saveItem
34 }, 37 },
35 'messungencreate form': { 38 'messungencreate form': {
36 savesuccess: this.createSuccess, 39 savesuccess: this.createSuccess,
37 savefailure: this.createFailure 40 savefailure: this.createFailure
38 }, 41 },
40 savesuccess: this.editSuccess, 43 savesuccess: this.editSuccess,
41 savefailure: this.editFailure 44 savefailure: this.editFailure
42 } 45 }
43 }); 46 });
44 }, 47 },
45 saveMessung: function(button) { 48 saveItem: function(button) {
46 console.log('Saving new Messung for Probe ' + button.probeId); 49 console.log('Saving new Messung for Probe ' + button.probeId);
47 var form = button.up('window').down('form'); 50 var form = button.up('window').down('form');
48 form.commit(); 51 form.commit();
49 }, 52 },
50 addMessung: function(button) { 53 addItem: function(button) {
51 console.log('Adding new Messung for Probe ' + button.probeId); 54 console.log('Adding new Messung for Probe ' + button.probeId);
52 var messung = Ext.create('Lada.model.Messung'); 55 var messung = Ext.create('Lada.model.Messung');
53 messung.set('probeId', button.probeId); 56 messung.set('probeId', button.probeId);
54 var view = Ext.widget('messungencreate', {model: messung}); 57 var view = Ext.widget('messungencreate', {model: messung});
55 }, 58 },
56 editMessung: function(grid, record) { 59 editItem: function(grid, record) {
57 console.log('Editing Messung'); 60 console.log('Editing Messung');
58 var kstore = this.getMKommentareStore(); 61 var kstore = this.getMKommentareStore();
59 kstore.load({ 62 kstore.load({
60 params: { 63 params: {
61 probeId: record.get('probeId'), 64 probeId: record.get('probeId'),
87 ignore.push('fertig'); 90 ignore.push('fertig');
88 form.setReadOnly(true, ignore); 91 form.setReadOnly(true, ignore);
89 } 92 }
90 console.log("Loaded Messung with ID " + record.getId()); //outputs ID 93 console.log("Loaded Messung with ID " + record.getId()); //outputs ID
91 }, 94 },
92 deleteMessung: function(button) { 95 deleteItem: function(button) {
93 // Get selected item in grid 96 // Get selected item in grid
94 var grid = button.up('grid'); 97 var grid = button.up('grid');
95 var selection = grid.getView().getSelectionModel().getSelection()[0]; 98 var selection = grid.getView().getSelectionModel().getSelection()[0];
96 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){ 99 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){
97 if(btn === 'yes'){ 100 if(btn === 'yes'){
109 console.log('Cancel Deleting Messung'); 112 console.log('Cancel Deleting Messung');
110 } 113 }
111 }); 114 });
112 }, 115 },
113 createSuccess: function(form, record, operation) { 116 createSuccess: function(form, record, operation) {
114 // Reload store
115 var store = this.getMessungenStore(); 117 var store = this.getMessungenStore();
116 store.reload(); 118 store.reload();
117 var win = form.up('window'); 119 var win = form.up('window');
118 win.close(); 120 win.close();
119 }, 121 },
124 icon: Ext.MessageBox.ERROR, 126 icon: Ext.MessageBox.ERROR,
125 buttons: Ext.Msg.OK 127 buttons: Ext.Msg.OK
126 }); 128 });
127 }, 129 },
128 editSuccess: function(form, record, operation) { 130 editSuccess: function(form, record, operation) {
129 // Reload store
130 var store = this.getMessungenStore(); 131 var store = this.getMessungenStore();
131 store.reload(); 132 store.reload();
132 var win = form.up('window'); 133 var win = form.up('window');
133 win.close(); 134 win.close();
134 }, 135 },

http://lada.wald.intevation.org