Mercurial > lada > lada-client
comparison app/controller/Zusatzwerte.js @ 110:c4f97a5a9939
Added Forms to add Zusatzwerte
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Wed, 19 Jun 2013 14:10:54 +0200 |
parents | |
children | a7bfaeb1655d |
comparison
equal
deleted
inserted
replaced
109:2308094f5a8c | 110:c4f97a5a9939 |
---|---|
1 Ext.define('Lada.controller.Zusatzwerte', { | |
2 extend: 'Ext.app.Controller', | |
3 views: [ | |
4 'zusatzwerte.List', | |
5 'zusatzwerte.Create' | |
6 ], | |
7 stores: [ | |
8 ], | |
9 models: [ | |
10 'Zusatzwert' | |
11 ], | |
12 init: function() { | |
13 console.log('Initialising the Zusatzwerte controller'); | |
14 this.control({ | |
15 // CSS like selector to select element in the viewpzusatzwert. See | |
16 // ComponentQuery documentation for more details. | |
17 'zusatzwertelist': { | |
18 itemdblclick: this.editZusatzwert | |
19 }, | |
20 'zusatzwertelist toolbar button[action=add]': { | |
21 click: this.addZusatzwert | |
22 }, | |
23 'zusatzwertelist toolbar button[action=delete]': { | |
24 click: this.deleteZusatzwert | |
25 }, | |
26 'zusatzwertecreate form': { | |
27 savesuccess: this.createSuccess, | |
28 savefailure: this.createFailure | |
29 }, | |
30 'zusatzwerteedit form': { | |
31 savesuccess: this.editSuccess, | |
32 savefailure: this.editFailure | |
33 } | |
34 }); | |
35 }, | |
36 addZusatzwert: function(button) { | |
37 console.log('Adding new Zusatzwert'); | |
38 var view = Ext.widget('zusatzwertecreate'); | |
39 }, | |
40 editZusatzwert: function(grid, record) { | |
41 console.log('Editing Zusatzwert'); | |
42 var view = Ext.widget('zusatzwertecreate', {model: record}); | |
43 console.log("Loaded Zusatzwert with ID " + record.getId()); //outputs ID | |
44 }, | |
45 deleteZusatzwert: function(button) { | |
46 // Get selected item in grid | |
47 var grid = button.up('grid'); | |
48 var selection = grid.getView().getSelectionModel().getSelection()[0]; | |
49 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){ | |
50 if(btn === 'yes'){ | |
51 var store = grid.getStore(); | |
52 store.remove(selection); | |
53 store.sync(); | |
54 console.log('Deleting Kommentar'); | |
55 } else { | |
56 console.log('Cancel Deleting Kommentar'); | |
57 } | |
58 }); | |
59 }, | |
60 createSuccess: function(form, record, operation) { | |
61 // Reload store | |
62 var store = this.getZusatzwerteStore(); | |
63 store.reload(); | |
64 var win = form.up('window'); | |
65 win.close(); | |
66 }, | |
67 createFailure: function(form, record, operation) { | |
68 Ext.MessageBox.show({ | |
69 title: 'Fehler beim Speichern', | |
70 msg: form.message, | |
71 icon: Ext.MessageBox.ERROR, | |
72 buttons: Ext.Msg.OK | |
73 }); | |
74 }, | |
75 editSuccess: function(form, record, operation) { | |
76 // Reload store | |
77 var store = this.getZusatzwerteStore(); | |
78 store.reload(); | |
79 var win = form.up('window'); | |
80 win.close(); | |
81 }, | |
82 editFailure: function(form, record, operation) { | |
83 Ext.MessageBox.show({ | |
84 title: 'Fehler beim Speichern', | |
85 msg: form.message, | |
86 icon: Ext.MessageBox.ERROR, | |
87 buttons: Ext.Msg.OK | |
88 }); | |
89 } | |
90 }); |