comparison app/controller/Messwert.js @ 290:fe51239321d9

Inherit from Base controller
author Torsten Irländer <torsten.irlaender@intevation.de>
date Fri, 09 Aug 2013 15:00:06 +0200
parents c32be5f97b5d
children 6a7a9267e00f
comparison
equal deleted inserted replaced
289:1bda6420c87c 290:fe51239321d9
1 /**
2 * Controller for Messwerte
3 */
1 Ext.define('Lada.controller.Messwert', { 4 Ext.define('Lada.controller.Messwert', {
2 extend: 'Ext.app.Controller', 5 extend: 'Lada.controller.Base',
3 views: [ 6 views: [
4 'messwerte.Create' 7 'messwerte.Create'
5 ], 8 ],
6 stores: [ 9 stores: [
7 'Proben', 10 'Proben',
9 'Messwerte', 12 'Messwerte',
10 'Messeinheit', 13 'Messeinheit',
11 'Messgroessen' 14 'Messgroessen'
12 ], 15 ],
13 init: function() { 16 init: function() {
14 console.log('Initialising the Messungen controller'); 17 console.log('Initialising the Messwert controller');
18 this.callParent();
19 },
20 addListeners: function() {
15 this.control({ 21 this.control({
16 // CSS like selector to select element in the viewpzusatzwert. See
17 // ComponentQuery documentation for more details.
18 'messwertelist': { 22 'messwertelist': {
19 itemdblclick: this.editMesswert 23 itemdblclick: this.editItem
20 }, 24 },
21 'messwertelist toolbar button[action=add]': { 25 'messwertelist toolbar button[action=add]': {
22 click: this.addMesswert 26 click: this.addItem
23 }, 27 },
24 'messwertelist toolbar button[action=delete]': { 28 'messwertelist toolbar button[action=delete]': {
25 click: this.deleteMesswert 29 click: this.deleteItem
26 }, 30 },
27 'messwertecreate button[action=save]': { 31 'messwertecreate button[action=save]': {
28 click: this.saveMesswert 32 click: this.saveItem
29 }, 33 },
30 'messwertecreate form': { 34 'messwertecreate form': {
31 savesuccess: this.createSuccess, 35 savesuccess: this.createSuccess,
32 savefailure: this.createFailure 36 savefailure: this.createFailure
33 } 37 }
34 }); 38 });
35 }, 39 },
36 saveMesswert: function(button) { 40 saveItem: function(button) {
37 console.log('Saving MesswerMesswert'); 41 console.log('Saving MesswerMesswert');
38 var form = button.up('window').down('form'); 42 var form = button.up('window').down('form');
39 form.commit(); 43 form.commit();
40 }, 44 },
41 addMesswert: function(button) { 45 addItem: function(button) {
42 console.log('Adding new Messwert for Messung ' + button.parentId + ' for Probe ' + button.probeId); 46 console.log('Adding new Messwert for Messung ' + button.parentId + ' for Probe ' + button.probeId);
43 var messung = Ext.create('Lada.model.Messwert'); 47 var messung = Ext.create('Lada.model.Messwert');
44 messung.set('probeId', button.probeId); 48 messung.set('probeId', button.probeId);
45 messung.set('messungsId', button.parentId); 49 messung.set('messungsId', button.parentId);
46 var view = Ext.widget('messwertecreate', {model: messung}); 50 var view = Ext.widget('messwertecreate', {model: messung});
47 }, 51 },
48 editMesswert: function(grid, record) { 52 editItem: function(grid, record) {
49 console.log('Editing Messwert'); 53 console.log('Editing Messwert');
50 var probe = this.getProbenStore().getById(record.get('probeId')); 54 var probe = this.getProbenStore().getById(record.get('probeId'));
51 var view = Ext.widget('messwertecreate', {model: record}); 55 var view = Ext.widget('messwertecreate', {model: record});
52 if (probe.get('readonly') === true) { 56 if (probe.get('readonly') === true) {
53 var form = view.down('form'); 57 var form = view.down('form');
54 form.setReadOnly(true); 58 form.setReadOnly(true);
55 } 59 }
56 60
57 console.log("Loaded Messwert with ID " + record.getId()); //outputs ID 61 console.log("Loaded Messwert with ID " + record.getId()); //outputs ID
58 }, 62 },
59 deleteMesswert: function(button) { 63 deleteItem: function(button) {
60 var grid = button.up('grid'); 64 var grid = button.up('grid');
61 var selection = grid.getView().getSelectionModel().getSelection()[0]; 65 var selection = grid.getView().getSelectionModel().getSelection()[0];
62 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){ 66 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){
63 if(btn === 'yes'){ 67 if(btn === 'yes'){
64 var store = grid.getStore(); 68 var store = grid.getStore();

http://lada.wald.intevation.org