comparison app/controller/grid/Ortszuordnung.js @ 1051:981339d774b8

merged stammdatengrids to default.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 01 Mar 2016 14:12:39 +0100
parents 2e7adc19b4fe
children 291df0037835
comparison
equal deleted inserted replaced
1048:eacf25f071c0 1051:981339d774b8
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU GPL (v>=3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
6 * the documentation coming with IMIS-Labordaten-Application for details.
7 */
8
9 /**
10 * This is a controller for a grid of Orte
11 */
12 Ext.define('Lada.controller.grid.Ortszuordnung', {
13 extend: 'Ext.app.Controller',
14
15 requires: [
16 'Lada.view.window.Ortszuordnung'
17 ],
18
19 /**
20 * Inhitialize the controller
21 * It has 3 listeners
22 */
23 init: function() {
24 this.control({
25 'ortszuordnunggrid': {
26 itemdblclick: this.open
27 },
28 'ortszuordnunggrid button[action=add]': {
29 click: this.add
30 },
31 'ortszuordnunggrid button[action=delete]': {
32 click: this.remove
33 }
34 });
35 },
36
37 /**
38 * When open is called, a {@link Lada.view.window.Ortszuordnung}
39 * is created which allows to edit the Orte
40 */
41 open: function(grid, record) {
42 var probe = grid.up('window').record;
43 var win = Ext.create('Lada.view.window.Ortszuordnung', {
44 parentWindow: grid.up('window'),
45 probe: grid.up('window').down('probeform').record,
46 record: record,
47 grid: grid
48 });
49 win.show();
50 win.initData();
51 },
52
53 /**
54 * This function adds a new row to add an Ort
55 */
56 add: function(button) {
57 var probe = button.up('window').record;
58 var win = Ext.create('Lada.view.window.Ortszuordnung', {
59 parentWindow: button.up('window'),
60 probe: probe,
61 record: null,
62 grid: button.up('ortszuordnung')
63 });
64 win.show();
65 win.initData();
66 },
67
68 /**
69 * A Ort-row can be removed from the grid with the remove
70 * function. It asks the user for confirmation
71 * If the removal was confirmed, it reloads the parent window on success,
72 * on failure, an error message is shown.
73 */
74 remove: function(button) {
75 var grid = button.up('grid');
76 var selection = grid.getView().getSelectionModel().getSelection()[0];
77 var i18n = Lada.getApplication().bundle;
78 Ext.MessageBox.confirm(i18n.getMsg('delete'), i18n.getMsg('confirmation.question'),
79 function(btn) {
80 if (btn === 'yes') {
81 selection.destroy({
82 success: function() {
83 button.up('window').initData();
84 },
85 failure: function(request, response) {
86 var i18n = Lada.getApplication().bundle;
87 var json = response.request.scope.reader.jsonData;
88 if (json) {
89 if (json.message){
90 Ext.Msg.alert(i18n.getMsg('err.msg.delete.title')
91 +' #'+json.message,
92 i18n.getMsg(json.message));
93 } else {
94 Ext.Msg.alert(i18n.getMsg('err.msg.delete.title'),
95 i18n.getMsg('err.msg.generic.body'));
96 }
97 } else {
98 Ext.Msg.alert(i18n.getMsg('err.msg.delete.title'),
99 i18n.getMsg('err.msg.response.body'));
100 }
101 }
102 });
103 }
104 });
105 grid.down('button[action=delete]').disable();
106 }
107 });

http://lada.wald.intevation.org