Mercurial > lada > lada-client
annotate app/controller/grid/Datensatzerzeuger.js @ 984:b21421ba6917 stammdatengrids
added buttons for datensatzerzeuger, pobenehmer, added controllers
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Thu, 10 Dec 2015 08:30:14 +0100 |
parents | |
children | 15d8c64049d1 |
rev | line source |
---|---|
984
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
3 * |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
7 */ |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
8 |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
9 /** |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
10 * This is a controller for a grid of Datensatzerzeuger Stammdaten |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
11 */ |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
12 Ext.define('Lada.controller.grid.Datensatzerzeuger', { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
13 extend: 'Ext.app.Controller', |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
14 |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
15 /** |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
16 * Inhitialize the controller |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
17 * It has 3 listeners |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
18 */ |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
19 init: function() { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
20 this.control({ |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
21 'datensatzerzeugergrid': { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
22 edit: this.gridSave, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
23 canceledit: this.cancelEdit, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
24 select: this.activateButtons, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
25 deselect: this.deactivateButtons |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
26 }, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
27 'datensatzerzeugergrid button[action=add]': { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
28 click: this.add |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
29 }, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
30 'datensatzerzeugergrid button[action=delete]': { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
31 click: this.remove |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
32 } |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
33 }); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
34 }, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
35 |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
36 /** |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
37 * This function is called when the grids roweditor saves |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
38 * the record. |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
39 * On success it refreshes the windows which contains the grid |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
40 * On failure it displays a message |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
41 */ |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
42 gridSave: function(editor, context) { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
43 context.record.set('datum', new Date()); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
44 context.record.save({ |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
45 success: function(record, response) { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
46 //Do Nothing |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
47 }, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
48 failure: function(record, response) { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
49 var json = response.request.scope.reader.jsonData; |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
50 if (json) { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
51 if (json.message){ |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
52 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title') |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
53 +' #'+json.message, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
54 Lada.getApplication().bundle.getMsg(json.message)); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
55 } else { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
56 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
57 Lada.getApplication().bundle.getMsg('err.msg.generic.body')); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
58 } |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
59 } |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
60 } |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
61 }); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
62 }, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
63 |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
64 /** |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
65 * When the edit was canceled, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
66 * the empty row might have been created by the roweditor is removed |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
67 */ |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
68 cancelEdit: function(editor, context) { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
69 if (!context.record.get('id') || |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
70 context.record.get('id') === '') { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
71 editor.getCmp().store.remove(context.record); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
72 } |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
73 context.grid.getSelectionModel().deselect(context.record); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
74 }, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
75 |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
76 /** |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
77 * This function adds a new row to add a Datensatzerzeuger |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
78 */ |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
79 add: function(button) { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
80 var record = Ext.create('Lada.model.DatensatzErzeuger'); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
81 button.up('datensatzerzeugergrid').store.insert(0, record); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
82 button.up('datensatzerzeugergrid').rowEditing.startEdit(0, 1); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
83 }, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
84 |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
85 /** |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
86 * A record can be removed from the grid with the remove |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
87 * function. It asks the user for confirmation |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
88 * If the removal was confirmed, it reloads the parent window on success, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
89 * on failure, an error message is shown. |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
90 */ |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
91 remove: function(button) { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
92 var grid = button.up('grid'); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
93 var selection = grid.getView().getSelectionModel().getSelection()[0]; |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
94 //TODO: i18n |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
95 Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn) { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
96 if (btn === 'yes') { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
97 selection.destroy({ |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
98 success: function() { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
99 //DO NOTHING |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
100 }, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
101 failure: function(request, response) { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
102 var json = response.request.scope.reader.jsonData; |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
103 if (json) { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
104 if (json.message){ |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
105 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title') |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
106 +' #'+json.message, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
107 Lada.getApplication().bundle.getMsg(json.message)); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
108 } else { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
109 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title'), |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
110 Lada.getApplication().bundle.getMsg('err.msg.generic.body')); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
111 } |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
112 } else { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
113 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title'), |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
114 Lada.getApplication().bundle.getMsg('err.msg.response.body')); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
115 } |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
116 } |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
117 }); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
118 } |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
119 }); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
120 grid.down('button[action=delete]').disable(); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
121 }, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
122 /** |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
123 * Toggles the buttons in the toolbar |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
124 **/ |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
125 activateButtons: function(rowModel, record) { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
126 var grid = rowModel.view.up('grid'); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
127 this.buttonToggle(true, grid); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
128 }, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
129 |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
130 /** |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
131 * Toggles the buttons in the toolbar |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
132 **/ |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
133 deactivateButtons: function(rowModel, record) { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
134 var grid = rowModel.view.up('grid'); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
135 // Only disable buttons when nothing is selected |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
136 if (rowModel.selected.items == 0) { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
137 this.buttonToggle(false, grid); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
138 } |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
139 }, |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
140 |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
141 /** |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
142 * Enables/Disables a set of buttons |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
143 **/ |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
144 buttonToggle: function(enabled, grid) { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
145 if (!enabled) { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
146 grid.down('button[action=delete]').disable(); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
147 } |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
148 else { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
149 if (!grid.getPlugin('rowedit').editing) { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
150 //only enable buttons, when grid is not beeing edited |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
151 grid.down('button[action=delete]').enable(); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
152 } |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
153 //else turn them off again! |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
154 else { |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
155 this.buttonToggle(false, grid); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
156 } |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
157 } |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
158 } |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
159 }); |
b21421ba6917
added buttons for datensatzerzeuger, pobenehmer, added controllers
Dustin Demuth <dustin@intevation.de>
parents:
diff
changeset
|
160 |