annotate app/controller/grid/Ort.js @ 994:092e245b13a4

draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
author Dustin Demuth <dustin@intevation.de>
date Thu, 07 Jan 2016 16:19:41 +0100
parents 2362f8ab1e9f
children
rev   line source
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 */
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
9 /**
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
10 * This is a controller for a grid of Orte
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
11 */
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 Ext.define('Lada.controller.grid.Ort', {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 extend: 'Ext.app.Controller',
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14
602
e1ab24758392 Updated the ort grid controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 587
diff changeset
15 requires: [
644
71e8b84d7829 Reload grids on messung or ort changed/added.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 643
diff changeset
16 'Lada.view.window.OrtEdit',
71e8b84d7829 Reload grids on messung or ort changed/added.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 643
diff changeset
17 'Lada.view.window.OrtCreate'
602
e1ab24758392 Updated the ort grid controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 587
diff changeset
18 ],
e1ab24758392 Updated the ort grid controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 587
diff changeset
19
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
20 /**
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
21 * Inhitialize the controller
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
22 * It has 3 listeners
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
23 */
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 init: function() {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 this.control({
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 'ortgrid': {
602
e1ab24758392 Updated the ort grid controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 587
diff changeset
27 itemdblclick: this.open
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 },
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 'ortgrid button[action=add]': {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 click: this.add
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 },
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 'ortgrid button[action=delete]': {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 click: this.remove
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 }
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 });
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 },
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
38 /**
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
39 * When open is called, a {@link Lada.view.window.OrtEdit}
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
40 * is created which allows to edit the Orte
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
41 */
602
e1ab24758392 Updated the ort grid controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 587
diff changeset
42 open: function(grid, record) {
690
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 644
diff changeset
43 var probe = grid.up('window').record;
602
e1ab24758392 Updated the ort grid controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 587
diff changeset
44 var win = Ext.create('Lada.view.window.OrtEdit', {
690
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 644
diff changeset
45 parentWindow: grid.up('window'),
e88381fb3bdb Use treeModiefied timestamp to determine if working with 'old' objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 644
diff changeset
46 probe: probe,
644
71e8b84d7829 Reload grids on messung or ort changed/added.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 643
diff changeset
47 record: record,
71e8b84d7829 Reload grids on messung or ort changed/added.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 643
diff changeset
48 grid: grid
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 });
602
e1ab24758392 Updated the ort grid controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 587
diff changeset
50 win.show();
e1ab24758392 Updated the ort grid controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 587
diff changeset
51 win.initData();
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 },
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
54 /**
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
55 * This function adds a new row to add an Ort
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
56 */
643
477379250512 Open the ort create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 602
diff changeset
57 add: function(button) {
477379250512 Open the ort create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 602
diff changeset
58 var probe = button.up('window').record;
477379250512 Open the ort create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 602
diff changeset
59 var win = Ext.create('Lada.view.window.OrtCreate', {
477379250512 Open the ort create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 602
diff changeset
60 record: probe,
477379250512 Open the ort create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 602
diff changeset
61 grid: button.up('ortgrid')
477379250512 Open the ort create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 602
diff changeset
62 });
477379250512 Open the ort create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 602
diff changeset
63 win.show();
477379250512 Open the ort create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 602
diff changeset
64 win.initData();
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 },
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
67 /**
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
68 * A Ort-row can be removed from the grid with the remove
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
69 * function. It asks the user for confirmation
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
70 * If the removal was confirmed, it reloads the parent window on success,
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
71 * on failure, an error message is shown.
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
72 */
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 remove: function(button) {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 var grid = button.up('grid');
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 var selection = grid.getView().getSelectionModel().getSelection()[0];
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 Ext.MessageBox.confirm('Ortsangabe löschen', 'Sind Sie sicher?', function(btn) {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 if (btn === 'yes') {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 selection.destroy({
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 success: function() {
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 button.up('window').initData();
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 },
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
82 failure: function(request, response) {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
83 var json = response.request.scope.reader.jsonData;
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
84 if (json) {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
85 if (json.message){
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
86 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title')
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
87 +' #'+json.message,
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
88 Lada.getApplication().bundle.getMsg(json.message));
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
89 } else {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
90 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title'),
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
91 Lada.getApplication().bundle.getMsg('err.msg.generic.body'));
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
92 }
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
93 } else {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
94 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title'),
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
95 Lada.getApplication().bundle.getMsg('err.msg.response.body'));
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 690
diff changeset
96 }
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 }
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 });
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 }
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 });
826
2362f8ab1e9f disable remove button after a item is deleted from grid
Dustin Demuth <dustin@intevation.de>
parents: 742
diff changeset
101 grid.down('button[action=delete]').disable();
587
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 }
cf328526b5bb Moved controller into subfolders.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 });

http://lada.wald.intevation.org