annotate app/controller/Base.js @ 360:302db31ac50a

Fixed syntax
author Torsten Irländer <torsten.irlaender@intevation.de>
date Thu, 15 Aug 2013 14:04:25 +0200
parents 12e7f0ef90b6
children debfcc7713e3
rev   line source
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
1 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
2 * Base Controller
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
3 *
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
4 * The controller defines the main logic of the application. It provides
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
5 * various methods which are bound to listeners and called when the defined
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
6 * events in the various UI elements occour (e.g User clicks on a button)
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
7 */
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
8 Ext.define('Lada.controller.Base', {
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
9 extend: 'Ext.app.Controller',
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
10 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
11 * Define required views for this controller
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
12 */
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
13 views: [],
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
14 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
15 * Define required stores for this controller
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
16 */
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
17 stores: [],
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
18 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
19 * Define required models for this controller
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
20 */
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
21 models: [],
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
22 init: function() {
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
23 console.log('Initialising the Kommentare controller');
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
24 this.addListeners();
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
25 },
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
26 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
27 * Function to add listeners for various events in UI items. The UI Items are selected
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
28 * with a CSS like selector.See ComponentQuery documentation for more
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
29 * details. The function is called while initializing the controller.
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
30 *
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
31 * The function should be overwritten by a specfic implementation.
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
32 */
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
33 addListeners: function() {
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
34 this.control({});
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
35 },
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
36 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
37 * Method to save the kommentar in the database. The method is called when
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
38 * the user clicks on the "Save" button
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
39 */
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
40 saveItem: function(button) {
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
41 console.log('Saving ...');
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
42 var form = button.up('window').down('form');
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
43 form.commit();
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
44 },
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
45 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
46 * Method to open a window to enter the values for a new kommentar.
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
47 * The method is called when the user clicks on the "Add" button in the
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
48 * grid toolbar.
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
49 */
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
50 addItem: function(button) {},
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
51 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
52 * Method to open a window to edit the values for an existing kommentar.
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
53 * The method is called when the user doubleclicks on the item in the
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
54 * grid.
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
55 */
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
56 editItem: function(grid, record) {},
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
57 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
58 * Method to delete a kommentar. This will trigger the display of a
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
59 * Confirmation dialog. After the deletion the related store will be
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
60 * refreshed.
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
61 * The method is called when the user selects the item in the grid and
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
62 * selects the delete button in the grid toolbar.
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
63 */
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
64 deleteItem: function(button) {
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
65 var grid = button.up('grid');
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
66 var selection = grid.getView().getSelectionModel().getSelection()[0];
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
67 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
68 if(btn === 'yes'){
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
69 var store = grid.getStore();
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
70 var deleteUrl = selection.getProxy().url + selection.getEidi();
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
71 Ext.Ajax.request({
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
72 url: deleteUrl,
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
73 method: 'DELETE',
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
74 success: function(response, opts) {
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
75 store.reload();
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
76 }
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
77 });
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
78 console.log('Deleting ' + selection);
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
79 } else {
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
80 console.log('Cancel Deleting ' + selection);
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
81 }
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
82 });
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
83 },
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
84 /**
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
85 * Method to trigger the action after successfull save (create).
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
86 * In this case the related store is refreshed and the window is closed.
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
87 */
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
88 createSuccess: function(form, record, operation) {},
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
89 /**
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
90 * Method to trigger the action after save (create) fails.
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
91 * In this case a Message Boss with a general error is shown.
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
92 */
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
93 createFailure: function(form, record, operation) {
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
94 Ext.MessageBox.show({
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
95 title: 'Fehler beim Speichern',
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
96 msg: form.message,
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
97 icon: Ext.MessageBox.ERROR,
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
98 buttons: Ext.Msg.OK
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
99 });
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
100 },
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
101 /**
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
102 * Method to trigger the action after successfull save (edit).
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
103 * In this case the related store is refreshed and the window is closed.
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
104 */
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
105 editSuccess: function(form, record, operation) {},
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
106 /**
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
107 * Method to trigger the action after save ( edit) fails.
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
108 * In this case a Message Boss with a general error is shown.
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
109 */
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
110 editFailure: function(form, record, operation) {
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
111 Ext.MessageBox.show({
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
112 title: 'Fehler beim Speichern',
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
113 msg: form.message,
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
114 icon: Ext.MessageBox.ERROR,
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
115 buttons: Ext.Msg.OK
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
116 });
360
302db31ac50a Fixed syntax
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 287
diff changeset
117 }
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
118 });

http://lada.wald.intevation.org