annotate app/controller/Kommentare.js @ 286:c509e9f6d4db

Added BaseController and inherit Kommentar controller from it.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Fri, 09 Aug 2013 14:21:08 +0200
parents 6c030e5739a7
children ea60be45fd4d
rev   line source
285
6c030e5739a7 Added Docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 204
diff changeset
1 /**
6c030e5739a7 Added Docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 204
diff changeset
2 * Controller for Kommentare
6c030e5739a7 Added Docstrings
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 204
diff changeset
3 */
54
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
4 Ext.define('Lada.controller.Kommentare', {
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 285
diff changeset
5 extend: 'Lada.controller.Base',
54
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
6 views: [
107
84f32c62670f Added form to create kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 61
diff changeset
7 'kommentare.Create'
54
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 stores: [
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
10 'Kommentare'
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 models: [
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
13 'Kommentar'
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
14 ],
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 285
diff changeset
15 addListeners: function() {
54
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
16 this.control({
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': {
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 285
diff changeset
18 itemdblclick: this.editItem
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]': {
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 285
diff changeset
21 click: this.addItem
60
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]': {
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 285
diff changeset
24 click: this.deleteItem
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]': {
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 285
diff changeset
27 click: this.saveItem
144
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
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
32 }
54
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
33 });
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
34 },
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 285
diff changeset
35 saveItem: function(button) {
144
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 111
diff changeset
36 console.log('Saving Kommentar');
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 111
diff changeset
37 var form = button.up('window').down('form');
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 111
diff changeset
38 form.commit();
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 111
diff changeset
39 },
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 285
diff changeset
40 addItem: function(button) {
144
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 111
diff changeset
41 console.log('Adding new Kommentar for Probe ' + button.probeId);
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 111
diff changeset
42 var kommentar = Ext.create('Lada.model.Kommentar');
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 111
diff changeset
43 kommentar.set('probeId', button.probeId);
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 111
diff changeset
44 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
45 },
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 285
diff changeset
46 editItem: function(grid, record) {
111
6273b73b4b27 Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 107
diff changeset
47 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
48 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
49 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
50 },
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 285
diff changeset
51 deleteItem: function(button) {
59
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
52 var grid = button.up('grid');
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
53 var selection = grid.getView().getSelectionModel().getSelection()[0];
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
54 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
55 if(btn === 'yes'){
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
56 var store = grid.getStore();
144
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 111
diff changeset
57 var deleteUrl = selection.getProxy().url + selection.getEidi();
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 111
diff changeset
58 Ext.Ajax.request({
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 111
diff changeset
59 url: deleteUrl,
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 111
diff changeset
60 method: 'DELETE',
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 111
diff changeset
61 success: function(response, opts) {
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 111
diff changeset
62 store.reload();
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 111
diff changeset
63 }
7b1140bd8b3d Re-Added Kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 111
diff changeset
64 });
59
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
65 console.log('Deleting Kommentar');
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
66 } else {
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
67 console.log('Cancel Deleting Kommentar');
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
68 }
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
69 });
9e23eca8dfc7 Added function to delete kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 55
diff changeset
70 },
111
6273b73b4b27 Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 107
diff changeset
71 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
72 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
73 store.reload();
6273b73b4b27 Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 107
diff changeset
74 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
75 win.close();
54
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
76 },
111
6273b73b4b27 Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 107
diff changeset
77 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
78 Ext.MessageBox.show({
6273b73b4b27 Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 107
diff changeset
79 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
80 msg: form.message,
6273b73b4b27 Replaced Logic for Kommentare. Use copied code form Orte.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 107
diff changeset
81 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
82 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
83 });
54
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
84 }
3c7bfff8bd64 Added Controller for kommentare
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
85 });

http://lada.wald.intevation.org