comparison app/controller/Status.js @ 295:841dc60824b5

Inherit from Base controller
author Torsten Irländer <torsten.irlaender@intevation.de>
date Fri, 09 Aug 2013 15:00:07 +0200
parents 7a4d93c9b0ff
children 6a7a9267e00f
comparison
equal deleted inserted replaced
294:92b475303806 295:841dc60824b5
1 Ext.define('Lada.controller.Status', { 1 Ext.define('Lada.controller.Status', {
2 extend: 'Ext.app.Controller', 2 extend: 'Lada.controller.Base',
3 views: [ 3 views: [
4 'status.Create' 4 'status.Create'
5 ], 5 ],
6 stores: [ 6 stores: [
7 'Status' 7 'Status'
8 ], 8 ],
9 init: function() { 9 init: function() {
10 console.log('Initialising the Status controller'); 10 console.log('Initialising the Status controller');
11 this.callParent();
12 },
13 addListeners: function() {
11 this.control({ 14 this.control({
12 // CSS like selector to select element in the viewpzusatzwert. See
13 // ComponentQuery documentation for more details.
14 'statuslist': { 15 'statuslist': {
15 itemdblclick: this.editStatus 16 itemdblclick: this.editItem
16 }, 17 },
17 'statuslist toolbar button[action=add]': { 18 'statuslist toolbar button[action=add]': {
18 click: this.addStatus 19 click: this.addItem
19 }, 20 },
20 'statuslist toolbar button[action=delete]': { 21 'statuslist toolbar button[action=delete]': {
21 click: this.deleteStatus 22 click: this.deleteItem
22 }, 23 },
23 'statuscreate form': { 24 'statuscreate form': {
24 savesuccess: this.createSuccess, 25 savesuccess: this.createSuccess,
25 savefailure: this.createFailure 26 savefailure: this.createFailure
26 }, 27 },
27 'statuscreate button[action=save]': { 28 'statuscreate button[action=save]': {
28 click: this.saveStatus 29 click: this.saveItem
29 }, 30 },
30 'statusedit form': { 31 'statusedit form': {
31 savesuccess: this.editSuccess, 32 savesuccess: this.editSuccess,
32 savefailure: this.editFailure 33 savefailure: this.editFailure
33 } 34 }
34 }); 35 });
35 }, 36 },
36 saveStatus: function(button) { 37 addItem: function(button) {
37 console.log('Saving Status');
38 var form = button.up('window').down('form');
39 form.commit();
40 },
41 addStatus: function(button) {
42 console.log('Adding new Status for Messung ' + button.parentId + ' in Probe ' + button.probeId); 38 console.log('Adding new Status for Messung ' + button.parentId + ' in Probe ' + button.probeId);
43 var zusatzwert = Ext.create('Lada.model.Status'); 39 var zusatzwert = Ext.create('Lada.model.Status');
44 zusatzwert.set('probeId', button.probeId); 40 zusatzwert.set('probeId', button.probeId);
45 zusatzwert.set('messungsId', button.parentId); 41 zusatzwert.set('messungsId', button.parentId);
46 var view = Ext.widget('statuscreate', {model: zusatzwert}); 42 var view = Ext.widget('statuscreate', {model: zusatzwert});
47 }, 43 },
48 editStatus: function(grid, record) { 44 editItem: function(grid, record) {
49 console.log('Editing Status'); 45 console.log('Editing Status');
50 var view = Ext.widget('statuscreate', {model: record}); 46 var view = Ext.widget('statuscreate', {model: record});
51 console.log("Loaded Status with ID " + record.getId()); //outputs ID 47 console.log("Loaded Status with ID " + record.getId()); //outputs ID
52 },
53 deleteStatus: function(button) {
54 // Get selected item in grid
55 var grid = button.up('grid');
56 var selection = grid.getView().getSelectionModel().getSelection()[0];
57 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){
58 if(btn === 'yes'){
59 var store = grid.getStore();
60 var deleteUrl = selection.getProxy().url + selection.getEidi();
61 Ext.Ajax.request({
62 url: deleteUrl,
63 method: 'DELETE',
64 success: function(response, opts) {
65 store.reload();
66 }
67 });
68 console.log('Deleting Kommentar');
69 } else {
70 console.log('Cancel Deleting Kommentar');
71 }
72 });
73 }, 48 },
74 createSuccess: function(form, record, operation) { 49 createSuccess: function(form, record, operation) {
75 // Reload store 50 // Reload store
76 var store = this.getStatusStore(); 51 var store = this.getStatusStore();
77 store.reload(); 52 store.reload();
78 var win = form.up('window'); 53 var win = form.up('window');
79 win.close(); 54 win.close();
80 }, 55 },
81 createFailure: function(form, record, operation) {
82 Ext.MessageBox.show({
83 title: 'Fehler beim Speichern',
84 msg: form.message,
85 icon: Ext.MessageBox.ERROR,
86 buttons: Ext.Msg.OK
87 });
88 },
89 editSuccess: function(form, record, operation) { 56 editSuccess: function(form, record, operation) {
90 // Reload store 57 // Reload store
91 var store = this.getStatusStore(); 58 var store = this.getStatusStore();
92 store.reload(); 59 store.reload();
93 var win = form.up('window'); 60 var win = form.up('window');
94 win.close(); 61 win.close();
95 }, 62 },
96 editFailure: function(form, record, operation) {
97 Ext.MessageBox.show({
98 title: 'Fehler beim Speichern',
99 msg: form.message,
100 icon: Ext.MessageBox.ERROR,
101 buttons: Ext.Msg.OK
102 });
103 }
104 }); 63 });

http://lada.wald.intevation.org