comparison app/controller/Orte.js @ 109:2308094f5a8c

Added forms to add Orte
author Torsten Irländer <torsten.irlaender@intevation.de>
date Wed, 19 Jun 2013 14:10:25 +0200
parents
children 26ac4c99f8c4
comparison
equal deleted inserted replaced
108:6c69bbb61c65 109:2308094f5a8c
1 Ext.define('Lada.controller.Orte', {
2 extend: 'Ext.app.Controller',
3 views: [
4 'orte.List',
5 'orte.Create'
6 ],
7 stores: [
8 ],
9 models: [
10 'Ort'
11 ],
12 init: function() {
13 console.log('Initialising the Orte controller');
14 this.control({
15 // CSS like selector to select element in the viewport. See
16 // ComponentQuery documentation for more details.
17 'ortelist': {
18 itemdblclick: this.editOrt
19 },
20 'ortelist toolbar button[action=add]': {
21 click: this.addOrt
22 },
23 'ortelist toolbar button[action=delete]': {
24 click: this.deleteOrt
25 },
26 'ortecreate form': {
27 savesuccess: this.createSuccess,
28 savefailure: this.createFailure
29 },
30 'orteedit form': {
31 savesuccess: this.editSuccess,
32 savefailure: this.editFailure
33 }
34 });
35 },
36 addOrt: function(button) {
37 console.log('Adding new Ort');
38 var view = Ext.widget('ortecreate');
39 },
40 editOrt: function(grid, record) {
41 console.log('Editing Ort');
42 var view = Ext.widget('ortecreate', {model: record});
43 console.log("Loaded Ort with ID " + record.getId()); //outputs ID
44 },
45 deleteOrt: 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.getOrteStore();
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.getOrteStore();
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 });

http://lada.wald.intevation.org