Mercurial > lada > lada-client
annotate app/controller/MKommentare.js @ 246:c5d7fae5997a
Change logic how to show and hide the search filters. Now we iterate over the
list of defined filters for the selected query and show all matching filters.
If no filter is configured at all the whole filter widget is hidden.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Tue, 23 Jul 2013 14:18:11 +0200 |
parents | 62e116cd3e3b |
children | e95662994c50 |
rev | line source |
---|---|
205
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
1 Ext.define('Lada.controller.MKommentare', { |
207
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
2 extend: 'Ext.app.Controller', |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
3 views: [ |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
4 'mkommentare.Create' |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
5 ], |
205
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
6 stores: [ |
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
7 'MKommentare' |
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
8 ], |
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
9 models: [ |
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
10 'MKommentar' |
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
11 ], |
207
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
12 init: function() { |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
13 console.log('Initialising the MKommentare controller'); |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
14 this.control({ |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
15 // CSS like selector to select element in the viewport. See |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
16 // ComponentQuery documentation for more details. |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
17 'mkommentarelist': { |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
18 itemdblclick: this.editKommentar |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
19 }, |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
20 'mkommentarelist toolbar button[action=add]': { |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
21 click: this.addKommentar |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
22 }, |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
23 'mkommentarelist toolbar button[action=delete]': { |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
24 click: this.deleteKommentar |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
25 }, |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
26 'mkommentarecreate button[action=save]': { |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
27 click: this.saveKommentar |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
28 }, |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
29 'mkommentarecreate form': { |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
30 savesuccess: this.createSuccess, |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
31 savefailure: this.createFailure |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
32 } |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
33 }); |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
34 }, |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
35 saveKommentar: function(button) { |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
36 console.log('Saving MKommentar'); |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
37 var form = button.up('window').down('form'); |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
38 form.commit(); |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
39 }, |
205
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
40 addKommentar: function(button) { |
207
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
41 console.log('Adding new MKommentar for Messung ' + button.parentId + ' Probe ' + button.probeId); |
205
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
42 var kommentar = Ext.create('Lada.model.MKommentar'); |
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
43 kommentar.set('probeId', button.probeId); |
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
44 kommentar.set('messungsId', button.parentId); |
207
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
45 var view = Ext.widget('mkommentarecreate', {model: kommentar}); |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
46 }, |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
47 editKommentar: function(grid, record) { |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
48 console.log('Editing Kommentar'); |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
49 var view = Ext.widget('mkommentarecreate', {model: record}); |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
50 console.log("Loaded MKommentar with ID " + record.getId()); //outputs ID |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
51 }, |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
52 deleteKommentar: function(button) { |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
53 // Get selected item in grid |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
54 var grid = button.up('grid'); |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
55 var selection = grid.getView().getSelectionModel().getSelection()[0]; |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
56 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){ |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
57 if(btn === 'yes'){ |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
58 var store = grid.getStore(); |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
59 var deleteUrl = selection.getProxy().url + selection.getEidi(); |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
60 Ext.Ajax.request({ |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
61 url: deleteUrl, |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
62 method: 'DELETE', |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
63 success: function(response, opts) { |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
64 store.reload(); |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
65 } |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
66 }); |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
67 console.log('Deleting MKommentar'); |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
68 } else { |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
69 console.log('Cancel Deleting MKommentar'); |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
70 } |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
71 }); |
205
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
72 }, |
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
73 createSuccess: function(form, record, operation) { |
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
74 // Reload store |
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
75 var store = this.getMKommentareStore(); |
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
76 store.reload(); |
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
77 var win = form.up('window'); |
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
78 win.close(); |
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
79 }, |
207
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
80 createFailure: function(form, record, operation) { |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
81 Ext.MessageBox.show({ |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
82 title: 'Fehler beim Speichern', |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
83 msg: form.message, |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
84 icon: Ext.MessageBox.ERROR, |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
85 buttons: Ext.Msg.OK |
62e116cd3e3b
Inheritance of Mkommentare from Kommentare does not work as expected. So write
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
205
diff
changeset
|
86 }); |
205
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
87 } |
cd8cd3ac0231
Added new Controller for MKommentare.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
88 }); |