Mercurial > lada > lada-client
annotate app/controller/Kommentare.js @ 198:808c24773713
Added new widget to list the available Statuswerte.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Mon, 08 Jul 2013 16:14:15 +0200 |
parents | 7b1140bd8b3d |
children | 4a79323336c6 |
rev | line source |
---|---|
54
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
1 Ext.define('Lada.controller.Kommentare', { |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
2 extend: 'Ext.app.Controller', |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
3 views: [ |
107
84f32c62670f
Added form to create kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
61
diff
changeset
|
4 'kommentare.Create' |
54
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
5 ], |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
6 stores: [ |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
7 'Kommentare' |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
8 ], |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
9 models: [ |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
10 'Kommentar' |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
11 ], |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
12 init: function() { |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
13 console.log('Initialising the Kommentare controller'); |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
14 this.control({ |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
15 // CSS like selector to select element in the viewport. See |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
16 // ComponentQuery documentation for more details. |
55
4fa3fba50f79
Added dialog for editing kommentare. Open the dialog on double click on a
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
54
diff
changeset
|
17 'kommentarelist': { |
4fa3fba50f79
Added dialog for editing kommentare. Open the dialog on double click on a
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
54
diff
changeset
|
18 itemdblclick: this.editKommentar |
59
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
19 }, |
60
5db7ab34af6d
Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
59
diff
changeset
|
20 'kommentarelist toolbar button[action=add]': { |
5db7ab34af6d
Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
59
diff
changeset
|
21 click: this.addKommentar |
5db7ab34af6d
Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
59
diff
changeset
|
22 }, |
59
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
23 'kommentarelist toolbar button[action=delete]': { |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
24 click: this.deleteKommentar |
60
5db7ab34af6d
Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
59
diff
changeset
|
25 }, |
144
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
26 'kommentarecreate button[action=save]': { |
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
27 click: this.saveKommentar |
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
28 }, |
111
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
29 'kommentarecreate form': { |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
30 savesuccess: this.createSuccess, |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
31 savefailure: this.createFailure |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
32 }, |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
33 'kommentareedit form': { |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
34 savesuccess: this.editSuccess, |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
35 savefailure: this.editFailure |
55
4fa3fba50f79
Added dialog for editing kommentare. Open the dialog on double click on a
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
54
diff
changeset
|
36 } |
54
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
37 }); |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
38 }, |
144
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
39 saveKommentar: function(button) { |
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
40 console.log('Saving Kommentar'); |
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
41 var form = button.up('window').down('form'); |
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
42 form.commit(); |
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
43 }, |
60
5db7ab34af6d
Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
59
diff
changeset
|
44 addKommentar: function(button) { |
144
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
45 console.log('Adding new Kommentar for Probe ' + button.probeId); |
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
46 var kommentar = Ext.create('Lada.model.Kommentar'); |
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
47 kommentar.set('probeId', button.probeId); |
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
48 var view = Ext.widget('kommentarecreate', {model: kommentar}); |
111
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
49 }, |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
50 editKommentar: function(grid, record) { |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
51 console.log('Editing Kommentar'); |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
52 var view = Ext.widget('kommentarecreate', {model: record}); |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
53 console.log("Loaded Kommentar with ID " + record.getId()); //outputs ID |
60
5db7ab34af6d
Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
59
diff
changeset
|
54 }, |
59
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
55 deleteKommentar: function(button) { |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
56 // Get selected item in grid |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
57 var grid = button.up('grid'); |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
58 var selection = grid.getView().getSelectionModel().getSelection()[0]; |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
59 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){ |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
60 if(btn === 'yes'){ |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
61 var store = grid.getStore(); |
144
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
62 var deleteUrl = selection.getProxy().url + selection.getEidi(); |
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
63 Ext.Ajax.request({ |
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
64 url: deleteUrl, |
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
65 method: 'DELETE', |
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
66 success: function(response, opts) { |
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
67 store.reload(); |
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
68 } |
7b1140bd8b3d
Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
111
diff
changeset
|
69 }); |
59
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
70 console.log('Deleting Kommentar'); |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
71 } else { |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
72 console.log('Cancel Deleting Kommentar'); |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
73 } |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
74 }); |
9e23eca8dfc7
Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
55
diff
changeset
|
75 }, |
111
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
76 createSuccess: function(form, record, operation) { |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
77 // Reload store |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
78 var store = this.getKommentareStore(); |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
79 store.reload(); |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
80 var win = form.up('window'); |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
81 win.close(); |
54
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
82 }, |
111
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
83 createFailure: function(form, record, operation) { |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
84 Ext.MessageBox.show({ |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
85 title: 'Fehler beim Speichern', |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
86 msg: form.message, |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
87 icon: Ext.MessageBox.ERROR, |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
88 buttons: Ext.Msg.OK |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
89 }); |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
90 }, |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
91 editSuccess: function(form, record, operation) { |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
92 // Reload store |
60
5db7ab34af6d
Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
59
diff
changeset
|
93 var store = this.getKommentareStore(); |
111
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
94 store.reload(); |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
95 var win = form.up('window'); |
60
5db7ab34af6d
Implemented Adding und Editing Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
59
diff
changeset
|
96 win.close(); |
111
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
97 }, |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
98 editFailure: function(form, record, operation) { |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
99 Ext.MessageBox.show({ |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
100 title: 'Fehler beim Speichern', |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
101 msg: form.message, |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
102 icon: Ext.MessageBox.ERROR, |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
103 buttons: Ext.Msg.OK |
6273b73b4b27
Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
107
diff
changeset
|
104 }); |
54
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
105 } |
3c7bfff8bd64
Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
106 }); |