annotate app/controller/Base.js @ 526:381066c87ba8

Merge
author Roland Geider <roland.geider@intevation.de>
date Tue, 16 Dec 2014 18:22:04 +0100
parents 8b4ec61c5752
children
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
497
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
472
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 this.addListeners();
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 /**
497
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
34 * Function to add listeners for various events in UI items. The UI Items
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
35 * are selected with a CSS like selector.See ComponentQuery documentation
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
36 * for more details.
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
37 * The function is called while initializing the controller.
286
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 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
50 form.commit();
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
51 },
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
52 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
53 * 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
54 * 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
55 * grid toolbar.
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
56 */
497
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
57 addItem: function() {
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
58 return;
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
59 },
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
60 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
61 * 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
62 * 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
63 * grid.
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
64 */
497
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
65 editItem: function() {
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
66 return;
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
67 },
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
68 /**
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
69 * 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
70 * 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
71 * refreshed.
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
72 * 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
73 * 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
74 */
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
75 deleteItem: function(button) {
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
76 var grid = button.up('grid');
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
77 var selection = grid.getView().getSelectionModel().getSelection()[0];
491
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
78 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn) {
850ccfe5f3c4 Code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 490
diff changeset
79 if (btn === 'yes') {
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
80 var store = grid.getStore();
490
446e99cfd425 Updated views and controllers using the new model and stores.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 472
diff changeset
81 var deleteUrl = selection.getProxy().url + selection.getId();
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
82 Ext.Ajax.request({
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
83 url: deleteUrl,
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
84 method: 'DELETE',
497
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
85 success: function() {
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
86 store.reload();
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
87 }
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
88 });
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 */
497
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
96 createSuccess: function() {
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
97 return;
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
98 },
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
99 /**
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
100 * 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
101 * 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
102 */
497
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
103 createFailure: function(form) {
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
104 Ext.MessageBox.show({
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
105 title: 'Fehler beim Speichern',
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
106 msg: form.message,
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
107 icon: Ext.MessageBox.ERROR,
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
108 buttons: Ext.Msg.OK
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 },
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
111 /**
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
112 * 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
113 * 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
114 */
497
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
115 editSuccess: function() {
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
116 return;
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
117 },
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
118 /**
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
119 * 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
120 * 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
121 */
497
7c0653e8d9f7 Fixed some js related issues (unused vars, arrays, etc.) and code style.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 491
diff changeset
122 editFailure: function(form) {
287
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
123 Ext.MessageBox.show({
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
124 title: 'Fehler beim Speichern',
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
125 msg: form.message,
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
126 icon: Ext.MessageBox.ERROR,
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
127 buttons: Ext.Msg.OK
12e7f0ef90b6 Move more methods into the BaseController.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 286
diff changeset
128 });
360
302db31ac50a Fixed syntax
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 287
diff changeset
129 }
286
c509e9f6d4db Added BaseController and inherit Kommentar controller from it.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
130 });

http://lada.wald.intevation.org