annotate app/controller/Base.js @ 488:f7446ebfe5d0

Added and updated models.
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 31 Oct 2014 21:10:35 +0100
parents debfcc7713e3
children 446e99cfd425
rev   line source
472
debfcc7713e3 Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 360
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
debfcc7713e3 Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 360
diff changeset
2 * Software engineering by Intevation GmbH
debfcc7713e3 Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 360
diff changeset
3 *
debfcc7713e3 Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 360
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
debfcc7713e3 Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 360
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
debfcc7713e3 Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 360
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
debfcc7713e3 Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 360
diff changeset
7 */
debfcc7713e3 Added license header to each file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 360
diff changeset
8
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
9 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
10 * Base Controller
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
11 *
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
12 * 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
13 * 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
14 * 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
15 */
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
16 Ext.define('Lada.controller.Base', {
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
17 extend: 'Ext.app.Controller',
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 views 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 views: [],
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
22 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
23 * 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
24 */
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
25 stores: [],
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 * 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
28 */
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
29 models: [],
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
30 init: function() {
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
31 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
32 this.addListeners();
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
33 },
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
34 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
35 * 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
36 * 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
37 * 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
38 *
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
39 * 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
40 */
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
41 addListeners: function() {
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
42 this.control({});
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
43 },
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
44 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
45 * 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
46 * 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
47 */
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
48 saveItem: function(button) {
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
49 console.log('Saving ...');
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
50 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
51 form.commit();
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
52 },
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
53 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
54 * 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
55 * 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
56 * grid toolbar.
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 addItem: function(button) {},
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
59 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
60 * 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
61 * 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
62 * grid.
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
63 */
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
64 editItem: function(grid, record) {},
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
65 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
66 * 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
67 * 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
68 * refreshed.
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
69 * 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
70 * 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
71 */
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
72 deleteItem: function(button) {
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
73 var grid = button.up('grid');
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
74 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
75 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
76 if(btn === 'yes'){
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
77 var store = grid.getStore();
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
78 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
79 Ext.Ajax.request({
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
80 url: deleteUrl,
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
81 method: 'DELETE',
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
82 success: function(response, opts) {
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
83 store.reload();
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
84 }
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
85 });
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
86 console.log('Deleting ' + selection);
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
87 } else {
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
88 console.log('Cancel Deleting ' + selection);
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
89 }
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
90 });
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
91 },
286
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 * 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
94 * 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
95 */
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
96 createSuccess: function(form, record, operation) {},
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
97 /**
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
98 * 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
99 * 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
100 */
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
101 createFailure: function(form, record, operation) {
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
102 Ext.MessageBox.show({
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
103 title: 'Fehler beim Speichern',
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
104 msg: form.message,
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
105 icon: Ext.MessageBox.ERROR,
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
106 buttons: Ext.Msg.OK
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
107 });
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
108 },
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 * 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
111 * 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
112 */
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
113 editSuccess: function(form, record, operation) {},
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
114 /**
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
115 * 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
116 * 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
117 */
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
118 editFailure: function(form, record, operation) {
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
119 Ext.MessageBox.show({
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
120 title: 'Fehler beim Speichern',
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
121 msg: form.message,
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
122 icon: Ext.MessageBox.ERROR,
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
123 buttons: Ext.Msg.OK
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
124 });
360
302db31ac50a Fixed syntax
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 287
diff changeset
125 }
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
126 });

http://lada.wald.intevation.org