Mercurial > lada > lada-client
comparison app/controller/grid/Ortszuordnung.js @ 1012:2adc329d90fe stammdatengrids
Replaced Locations with Ortszuordnung
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Tue, 26 Jan 2016 10:40:48 +0100 |
parents | app/controller/grid/Ort.js@2362f8ab1e9f |
children | 75ce503ab296 |
comparison
equal
deleted
inserted
replaced
1011:6afdbc8ee920 | 1012:2adc329d90fe |
---|---|
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.OrtEdit', | |
17 'Lada.view.window.OrtCreate' | |
18 ], | |
19 | |
20 /** | |
21 * Inhitialize the controller | |
22 * It has 3 listeners | |
23 */ | |
24 init: function() { | |
25 this.control({ | |
26 'ortszuordnunggrid': { | |
27 itemdblclick: this.open | |
28 }, | |
29 'ortszuordnunggrid button[action=add]': { | |
30 click: this.add | |
31 }, | |
32 'ortszuordnunggrid button[action=delete]': { | |
33 click: this.remove | |
34 } | |
35 }); | |
36 }, | |
37 | |
38 /** | |
39 * When open is called, a {@link Lada.view.window.OrtEdit} | |
40 * is created which allows to edit the Orte | |
41 */ | |
42 open: function(grid, record) { | |
43 var probe = grid.up('window').record; | |
44 var win = Ext.create('Lada.view.window.OrtEdit', { | |
45 parentWindow: grid.up('window'), | |
46 probe: probe, | |
47 record: record, | |
48 grid: grid | |
49 }); | |
50 win.show(); | |
51 win.initData(); | |
52 }, | |
53 | |
54 /** | |
55 * This function adds a new row to add an Ort | |
56 */ | |
57 add: function(button) { | |
58 var probe = button.up('window').record; | |
59 var win = Ext.create('Lada.view.window.OrtCreate', { | |
60 record: probe, | |
61 grid: button.up('ortszuordnung') | |
62 }); | |
63 win.show(); | |
64 win.initData(); | |
65 }, | |
66 | |
67 /** | |
68 * A Ort-row can be removed from the grid with the remove | |
69 * function. It asks the user for confirmation | |
70 * If the removal was confirmed, it reloads the parent window on success, | |
71 * on failure, an error message is shown. | |
72 */ | |
73 remove: function(button) { | |
74 var grid = button.up('grid'); | |
75 var selection = grid.getView().getSelectionModel().getSelection()[0]; | |
76 var i18n = Lada.getApplication().bundle; | |
77 Ext.MessageBox.confirm(i18n.getMsg('delete'), i18n.getMsg('confirmation.question'), | |
78 function(btn) { | |
79 if (btn === 'yes') { | |
80 selection.destroy({ | |
81 success: function() { | |
82 button.up('window').initData(); | |
83 }, | |
84 failure: function(request, response) { | |
85 var i18n = Lada.getApplication().bundle; | |
86 var json = response.request.scope.reader.jsonData; | |
87 if (json) { | |
88 if (json.message){ | |
89 Ext.Msg.alert(i18n.getMsg('err.msg.delete.title') | |
90 +' #'+json.message, | |
91 i18n.getMsg(json.message)); | |
92 } else { | |
93 Ext.Msg.alert(i18n.getMsg('err.msg.delete.title'), | |
94 i18n.getMsg('err.msg.generic.body')); | |
95 } | |
96 } else { | |
97 Ext.Msg.alert(i18n.getMsg('err.msg.delete.title'), | |
98 i18n.getMsg('err.msg.response.body')); | |
99 } | |
100 } | |
101 }); | |
102 } | |
103 }); | |
104 grid.down('button[action=delete]').disable(); | |
105 } | |
106 }); |