comparison app/controller/Messungen.js @ 491:850ccfe5f3c4

Code style.
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 31 Oct 2014 23:23:32 +0100
parents 446e99cfd425
children d07e5086a64b
comparison
equal deleted inserted replaced
490:446e99cfd425 491:850ccfe5f3c4
9 /** 9 /**
10 * Controller for Messungen 10 * Controller for Messungen
11 */ 11 */
12 Ext.define('Lada.controller.Messungen', { 12 Ext.define('Lada.controller.Messungen', {
13 extend: 'Lada.controller.Base', 13 extend: 'Lada.controller.Base',
14
14 views: [ 15 views: [
15 'messungen.Create', 16 'messungen.Create',
16 'messungen.Edit' 17 'messungen.Edit'
17 ], 18 ],
19
18 stores: [ 20 stores: [
19 'Proben', 21 'Proben',
20 'Messungen', 22 'Messungen',
21 'Messwerte', 23 'Messwerte',
22 'KommentareM', 24 'KommentareM',
23 'Status', 25 'Status',
24 'StaMessgroessen' 26 'StaMessgroessen'
25 ], 27 ],
28
26 init: function() { 29 init: function() {
27 console.log('Initialising the Messungen controller'); 30 console.log('Initialising the Messungen controller');
28 this.callParent(); 31 this.callParent();
29 }, 32 },
33
30 addListeners: function() { 34 addListeners: function() {
31 this.control({ 35 this.control({
32 'messungenlist': { 36 'messungenlist': {
33 itemdblclick: this.editItem 37 itemdblclick: this.editItem
34 }, 38 },
52 savesuccess: this.editSuccess, 56 savesuccess: this.editSuccess,
53 savefailure: this.editFailure 57 savefailure: this.editFailure
54 } 58 }
55 }); 59 });
56 }, 60 },
61
57 saveItem: function(button) { 62 saveItem: function(button) {
58 console.log('Saving new Messung for Probe ' + button.probeId); 63 console.log('Saving new Messung for Probe ' + button.probeId);
59 var form = button.up('window').down('form'); 64 var form = button.up('window').down('form');
60 form.commit(); 65 form.commit();
61 }, 66 },
67
62 addItem: function(button) { 68 addItem: function(button) {
63 console.log('Adding new Messung for Probe ' + button.probeId); 69 console.log('Adding new Messung for Probe ' + button.probeId);
64 var messung = Ext.create('Lada.model.Messung'); 70 var messung = Ext.create('Lada.model.Messung');
65 messung.set('probeId', button.probeId); 71 messung.set('probeId', button.probeId);
66 var view = Ext.widget('messungencreate', {model: messung}); 72 var view = Ext.widget('messungencreate', {model: messung});
67 }, 73 },
74
68 editItem: function(grid, record) { 75 editItem: function(grid, record) {
69 console.log('Editing Messung'); 76 console.log('Editing Messung');
70 var kstore = this.getKommentareMStore(); 77 var kstore = this.getKommentareMStore();
71 kstore.load({ 78 kstore.load({
72 params: { 79 params: {
89 } 96 }
90 }); 97 });
91 record.getAuthInfo(this.initEditWindow); 98 record.getAuthInfo(this.initEditWindow);
92 console.log("Loaded Messung with ID " + record.getId()); //outputs ID 99 console.log("Loaded Messung with ID " + record.getId()); //outputs ID
93 }, 100 },
101
94 initEditWindow: function(record, readonly, owner) { 102 initEditWindow: function(record, readonly, owner) {
95 var view = Ext.widget('messungenedit', {model: record}); 103 var view = Ext.widget('messungenedit', {
104 model: record
105 });
96 var ignore = Array(); 106 var ignore = Array();
97 if (owner) { 107 if (owner) {
98 ignore.push('fertig'); 108 ignore.push('fertig');
99 } 109 }
100 if (readonly) { 110 if (readonly) {
101 var form = view.down('form'); 111 var form = view.down('form');
102 form.setReadOnly(true, ignore); 112 form.setReadOnly(true, ignore);
103 } 113 }
104 }, 114 },
115
105 deleteItem: function(button) { 116 deleteItem: function(button) {
106 // Get selected item in grid 117 // Get selected item in grid
107 var grid = button.up('grid'); 118 var grid = button.up('grid');
108 var selection = grid.getView().getSelectionModel().getSelection()[0]; 119 var selection = grid.getView().getSelectionModel().getSelection()[0];
109 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){ 120 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn) {
110 if(btn === 'yes'){ 121 if (btn === 'yes') {
111 var store = grid.getStore(); 122 var store = grid.getStore();
112 var deleteUrl = selection.getProxy().url + selection.getId(); 123 var deleteUrl = selection.getProxy().url + selection.getId();
113 Ext.Ajax.request({ 124 Ext.Ajax.request({
114 url: deleteUrl, 125 url: deleteUrl,
115 method: 'DELETE', 126 method: 'DELETE',
121 } else { 132 } else {
122 console.log('Cancel Deleting Messung'); 133 console.log('Cancel Deleting Messung');
123 } 134 }
124 }); 135 });
125 }, 136 },
137
126 createSuccess: function(form, record, operation) { 138 createSuccess: function(form, record, operation) {
127 var store = this.getMessungenStore(); 139 var store = this.getMessungenStore();
128 store.reload(); 140 store.reload();
129 var win = form.up('window'); 141 var win = form.up('window');
130 win.close(); 142 win.close();
131 }, 143 },
144
132 createFailure: function(form, record, operation) { 145 createFailure: function(form, record, operation) {
133 Ext.MessageBox.show({ 146 Ext.MessageBox.show({
134 title: 'Fehler beim Speichern', 147 title: 'Fehler beim Speichern',
135 msg: form.message, 148 msg: form.message,
136 icon: Ext.MessageBox.ERROR, 149 icon: Ext.MessageBox.ERROR,
137 buttons: Ext.Msg.OK 150 buttons: Ext.Msg.OK
138 }); 151 });
139 }, 152 },
153
140 editSuccess: function(form, record, operation) { 154 editSuccess: function(form, record, operation) {
141 var store = this.getMessungenStore(); 155 var store = this.getMessungenStore();
142 store.reload(); 156 store.reload();
143 var win = form.up('window'); 157 var win = form.up('window');
144 win.close(); 158 win.close();
145 }, 159 },
160
146 editFailure: function(form, record, operation) { 161 editFailure: function(form, record, operation) {
147 Ext.MessageBox.show({ 162 Ext.MessageBox.show({
148 title: 'Fehler beim Speichern', 163 title: 'Fehler beim Speichern',
149 msg: form.message, 164 msg: form.message,
150 icon: Ext.MessageBox.ERROR, 165 icon: Ext.MessageBox.ERROR,

http://lada.wald.intevation.org