annotate app/controller/grid/Messwert.js @ 739:efb1369a8cac

Enabled autocompletion for Messwerte in a Messung.
author Dustin Demuth <dustin@intevation.de>
date Mon, 20 Apr 2015 14:11:39 +0200
parents f0bc5387abcc
children 2e8da590ea0c
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({
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
29 success: function(request, response) {
739
efb1369a8cac Enabled autocompletion for Messwerte in a Messung.
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
30 Ext.data.StoreManager.get('messgroessen').clearFilters();
efb1369a8cac Enabled autocompletion for Messwerte in a Messung.
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
31 Ext.data.StoreManager.get('messgroessen').reload();
efb1369a8cac Enabled autocompletion for Messwerte in a Messung.
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
32 // If you don't do the reset above, the grid will only contain
efb1369a8cac Enabled autocompletion for Messwerte in a Messung.
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
33 // one row in cases in when autocompletion was used!
590
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 context.grid.store.reload();
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 context.grid.up('window').initData();
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 },
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
37 failure: function(request, response) {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
38 var json = response.request.scope.reader.jsonData;
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
39 if (json) {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
40 if (json.message){
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
41 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title')
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
42 +' #'+json.message,
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
43 Lada.getApplication().bundle.getMsg(json.message));
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
44 } else {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
45 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'),
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
46 Lada.getApplication().bundle.getMsg('err.msg.generic.body'));
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
47 }
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
48 } else {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
49 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'),
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
50 Lada.getApplication().bundle.getMsg('err.msg.response.body'));
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
51 }
590
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 },
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55
637
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 591
diff changeset
56 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
57 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
58 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
59 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
60 }
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 591
diff changeset
61 },
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 591
diff changeset
62
590
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 add: function(button) {
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 var record = Ext.create('Lada.model.Messwert', {
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 messungsId: button.up('messwertgrid').recordId
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 button.up('messwertgrid').store.insert(0, record);
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 button.up('messwertgrid').rowEditing.startEdit(0, 1);
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 remove: function(button) {
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 var grid = button.up('grid');
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 var selection = grid.getView().getSelectionModel().getSelection()[0];
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 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
75 if (btn === 'yes') {
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 selection.destroy({
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 success: function() {
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 button.up('window').initData();
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 grid.initData();
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 },
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
81 failure: function(request, response) {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
82 var json = response.request.scope.reader.jsonData;
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
83 if (json) {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
84 if (json.message){
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
85 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title')
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
86 +' #'+json.message,
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
87 Lada.getApplication().bundle.getMsg(json.message));
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
88 } else {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
89 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title'),
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
90 Lada.getApplication().bundle.getMsg('err.msg.generic.body'));
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
91 }
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
92 } else {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
93 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title'),
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
94 Lada.getApplication().bundle.getMsg('err.msg.response.body'));
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
95 }
590
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96 }
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 });
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 }
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 });
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 }
e440b66a859f Added grid (+controller) for messwerte.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 });

http://lada.wald.intevation.org