Mercurial > lada > lada-client
annotate app/controller/grid/Messwert.js @ 690:e88381fb3bdb
Use treeModiefied timestamp to determine if working with 'old' objects.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 25 Mar 2015 16:46:48 +0100 |
parents | 8acb3123b46c |
children | f0bc5387abcc |
rev | line source |
---|---|
590
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 * |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 */ |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 Ext.define('Lada.controller.grid.Messwert', { |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 extend: 'Ext.app.Controller', |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 init: function() { |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 this.control({ |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 'messwertgrid': { |
637
8acb3123b46c
Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
591
diff
changeset
|
15 edit: this.gridSave, |
8acb3123b46c
Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
591
diff
changeset
|
16 canceledit: this.cancelEdit |
590
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 }, |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 'messwertgrid button[action=add]': { |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 click: this.add |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 }, |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 'messwertgrid button[action=delete]': { |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 click: this.remove |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 } |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 }); |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 }, |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 gridSave: function(editor, context) { |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 context.record.save({ |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 success: function() { |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 context.grid.store.reload(); |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 context.grid.up('window').initData(); |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 }, |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 failure: function() { |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 // TODO |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 } |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 }); |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 }, |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 |
637
8acb3123b46c
Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
591
diff
changeset
|
39 cancelEdit: function(editor, context) { |
8acb3123b46c
Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
591
diff
changeset
|
40 if (!context.record.get('id') || |
8acb3123b46c
Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
591
diff
changeset
|
41 context.record.get('id') === '') { |
8acb3123b46c
Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
591
diff
changeset
|
42 editor.getCmp().store.remove(context.record); |
8acb3123b46c
Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
591
diff
changeset
|
43 } |
8acb3123b46c
Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
591
diff
changeset
|
44 }, |
8acb3123b46c
Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
591
diff
changeset
|
45 |
590
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 add: function(button) { |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 var record = Ext.create('Lada.model.Messwert', { |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 messungsId: button.up('messwertgrid').recordId |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 }); |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 button.up('messwertgrid').store.insert(0, record); |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 button.up('messwertgrid').rowEditing.startEdit(0, 1); |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 }, |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 remove: function(button) { |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 var grid = button.up('grid'); |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 var selection = grid.getView().getSelectionModel().getSelection()[0]; |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 Ext.MessageBox.confirm('Messwert löschen', 'Sind Sie sicher?', function(btn) { |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 if (btn === 'yes') { |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 selection.destroy({ |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 success: function() { |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 button.up('window').initData(); |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 grid.initData(); |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 }, |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 failure: function() { |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 // TODO |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 } |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 }); |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 } |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 }); |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 } |
e440b66a859f
Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 }); |