comparison app/controller/Status.js @ 202:7a4d93c9b0ff

Added status controller.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Mon, 08 Jul 2013 16:16:39 +0200
parents
children 841dc60824b5
comparison
equal deleted inserted replaced
201:7997272bbf4b 202:7a4d93c9b0ff
1 Ext.define('Lada.controller.Status', {
2 extend: 'Ext.app.Controller',
3 views: [
4 'status.Create'
5 ],
6 stores: [
7 'Status'
8 ],
9 init: function() {
10 console.log('Initialising the Status controller');
11 this.control({
12 // CSS like selector to select element in the viewpzusatzwert. See
13 // ComponentQuery documentation for more details.
14 'statuslist': {
15 itemdblclick: this.editStatus
16 },
17 'statuslist toolbar button[action=add]': {
18 click: this.addStatus
19 },
20 'statuslist toolbar button[action=delete]': {
21 click: this.deleteStatus
22 },
23 'statuscreate form': {
24 savesuccess: this.createSuccess,
25 savefailure: this.createFailure
26 },
27 'statuscreate button[action=save]': {
28 click: this.saveStatus
29 },
30 'statusedit form': {
31 savesuccess: this.editSuccess,
32 savefailure: this.editFailure
33 }
34 });
35 },
36 saveStatus: 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);
43 var zusatzwert = Ext.create('Lada.model.Status');
44 zusatzwert.set('probeId', button.probeId);
45 zusatzwert.set('messungsId', button.parentId);
46 var view = Ext.widget('statuscreate', {model: zusatzwert});
47 },
48 editStatus: function(grid, record) {
49 console.log('Editing Status');
50 var view = Ext.widget('statuscreate', {model: record});
51 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 },
74 createSuccess: function(form, record, operation) {
75 // Reload store
76 var store = this.getStatusStore();
77 store.reload();
78 var win = form.up('window');
79 win.close();
80 },
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) {
90 // Reload store
91 var store = this.getStatusStore();
92 store.reload();
93 var win = form.up('window');
94 win.close();
95 },
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 });

http://lada.wald.intevation.org