annotate app/controller/grid/Status.js @ 1390:dca8a3e9836e

change of incorrect string
author Maximilian Krambach <mkrambach@intevation.de>
date Tue, 28 Feb 2017 17:20:14 +0100
parents 3b4dcc83a21b
children
rev   line source
594
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 */
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
9 /**
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
10 * This is a controller for a grid of Status
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
11 */
594
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 Ext.define('Lada.controller.grid.Status', {
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 extend: 'Ext.app.Controller',
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
15 /**
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
16 * Initialize the Controller with
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
17 * 3 Listeners
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
18 */
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
19 init: function() {
594
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 this.control({
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 'statusgrid': {
637
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 594
diff changeset
22 edit: this.gridSave,
1280
3b4dcc83a21b fix sencha compile warnings
Michael Stanko <mstanko@bfs.de>
parents: 1225
diff changeset
23 canceledit: this.cancelEdit
594
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 },
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 'statusgrid button[action=add]': {
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 click: this.add
994
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
27 },
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
28 'statusgrid button[action=reset]': {
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
29 click: this.reset
594
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 }
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 });
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 },
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
34 /**
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
35 * This function is called when the grids roweditor saves
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
36 * the record.
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
37 * On success it refreshes the windows which contains the grid
974
ea477f62a667 Refresh a Probe and its Messungengrid when the status of a messung was changed
Dustin Demuth <dustin@intevation.de>
parents: 970
diff changeset
38 * it also tries to refresh the ProbeWindow and the messunggrid
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
39 * On failure it displays a message
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
40 */
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
41 gridSave: function(editor, context) {
1217
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
42 context.record.set('datum', new Date());
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
43 var wert = editor.getEditor().down('combobox[displayField=wert]').value;
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
44 var stufe = editor.getEditor().down('combobox[displayField=stufe]').value;
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
45 var kombis = Ext.data.StoreManager.get('statuskombi');
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
46 var kombiNdx = kombis.findBy(function(record, id) {
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
47 if (record.raw.statusStufe.id === stufe &&
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
48 record.raw.statusWert.id === wert
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
49 ) {
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
50 return true;
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
51 }
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
52 });
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
53 context.record.set('statusKombi', kombis.getAt(kombiNdx).get('id'));
594
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 context.record.save({
1025
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
55 success: function(response) {
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
56 var i18n = Lada.getApplication().bundle;
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
57 var json = Ext.JSON.decode(response.responseText);
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
58
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
59 if(json) {
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
60 if (!json.success) {
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
61 if(json.message){
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
62 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title')
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
63 +' #'+json.message,
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
64 i18n.getMsg(json.message));
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
65 } else {
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
66 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
67 i18n.getMsg('err.msg.generic.body'));
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
68 }
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
69 } else {
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
70 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
71 i18n.getMsg('err.msg.generic.body'));
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
72 }
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
73 }
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
74
594
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 context.grid.initData();
974
ea477f62a667 Refresh a Probe and its Messungengrid when the status of a messung was changed
Dustin Demuth <dustin@intevation.de>
parents: 970
diff changeset
76 var win = context.grid.up('window');
ea477f62a667 Refresh a Probe and its Messungengrid when the status of a messung was changed
Dustin Demuth <dustin@intevation.de>
parents: 970
diff changeset
77 win.initData();
ea477f62a667 Refresh a Probe and its Messungengrid when the status of a messung was changed
Dustin Demuth <dustin@intevation.de>
parents: 970
diff changeset
78 try {
ea477f62a667 Refresh a Probe and its Messungengrid when the status of a messung was changed
Dustin Demuth <dustin@intevation.de>
parents: 970
diff changeset
79 win.parentWindow.initData();
ea477f62a667 Refresh a Probe and its Messungengrid when the status of a messung was changed
Dustin Demuth <dustin@intevation.de>
parents: 970
diff changeset
80 win.parentWindow.down('messunggrid').store.reload();
ea477f62a667 Refresh a Probe and its Messungengrid when the status of a messung was changed
Dustin Demuth <dustin@intevation.de>
parents: 970
diff changeset
81 }
ea477f62a667 Refresh a Probe and its Messungengrid when the status of a messung was changed
Dustin Demuth <dustin@intevation.de>
parents: 970
diff changeset
82 catch(e) {
ea477f62a667 Refresh a Probe and its Messungengrid when the status of a messung was changed
Dustin Demuth <dustin@intevation.de>
parents: 970
diff changeset
83 }
594
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 },
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
85 failure: function(request, response) {
998
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
86 var i18n = Lada.getApplication().bundle;
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
87 var json = response.request.scope.reader.jsonData;
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
88 if (json) {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
89 if (json.message){
998
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
90 Ext.Msg.alert(i18n.getMsg('err.msg.save.title')
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
91 +' #'+json.message,
998
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
92 i18n.getMsg(json.message));
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
93 } else {
998
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
94 Ext.Msg.alert(i18n.getMsg('err.msg.save.title'),
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
95 i18n.getMsg('err.msg.generic.body'));
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
96 }
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
97 } else {
998
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
98 Ext.Msg.alert(i18n.getMsg('err.msg.save.title'),
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
99 i18n.getMsg('err.msg.response.body'));
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
100 }
594
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 }
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 });
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 },
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
105 /**
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
106 * When the edit was canceled,
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
107 * the empty row might have been created by the roweditor is removed
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
108 */
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
109 cancelEdit: function(editor, context) {
637
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 594
diff changeset
110 if (!context.record.get('id') ||
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 594
diff changeset
111 context.record.get('id') === '') {
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 594
diff changeset
112 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: 594
diff changeset
113 }
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 594
diff changeset
114 },
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 594
diff changeset
115
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
116 /**
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
117 * This function adds a new row to add a Status
990
c2a726887dd7 The last status can not be edited anymore. When a new status is added, the new record is preset with ALL previous variables, this includes the StatusStufe! The Date is corrected to the current date. Also the store is sorted by Datum now.
Dustin Demuth <dustin@intevation.de>
parents: 974
diff changeset
118 * and copies the data of the previous status into the new one
c2a726887dd7 The last status can not be edited anymore. When a new status is added, the new record is preset with ALL previous variables, this includes the StatusStufe! The Date is corrected to the current date. Also the store is sorted by Datum now.
Dustin Demuth <dustin@intevation.de>
parents: 974
diff changeset
119 * if possible.
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
120 */
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
121 add: function(button) {
945
023e622f9551 Added the ability to work with "StatusWerten" which are delivered by the lada-server.
Dustin Demuth <dustin@intevation.de>
parents: 944
diff changeset
122 var lastrow = button.up('statusgrid').store.count()
594
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123
992
77ea9a5c5f1d Do not clone the Status if the Recent UserID differs from the Recent Status Erzeuger. In addition: Use a Method to determine the recent status which does not require correct ordering of status
Dustin Demuth <dustin@intevation.de>
parents: 990
diff changeset
124 // retrive current status from the messung.
77ea9a5c5f1d Do not clone the Status if the Recent UserID differs from the Recent Status Erzeuger. In addition: Use a Method to determine the recent status which does not require correct ordering of status
Dustin Demuth <dustin@intevation.de>
parents: 990
diff changeset
125 var s = button.up('window').down('messungform').getRecord().get('status');
77ea9a5c5f1d Do not clone the Status if the Recent UserID differs from the Recent Status Erzeuger. In addition: Use a Method to determine the recent status which does not require correct ordering of status
Dustin Demuth <dustin@intevation.de>
parents: 990
diff changeset
126 var recentStatus = button.up('statusgrid').store.getById(s);
945
023e622f9551 Added the ability to work with "StatusWerten" which are delivered by the lada-server.
Dustin Demuth <dustin@intevation.de>
parents: 944
diff changeset
127
1001
e92931b8f6b0 A fix which is supposed to reload the statuswerte store, when the Add button is used, part 2
Dustin Demuth <dustin@intevation.de>
parents: 1000
diff changeset
128 button.up('statusgrid').statusWerteStore.reload();
1000
5beb2581a989 A fix which is supposed to reload the statuswerte store, when the Add button is used
Dustin Demuth <dustin@intevation.de>
parents: 998
diff changeset
129
990
c2a726887dd7 The last status can not be edited anymore. When a new status is added, the new record is preset with ALL previous variables, this includes the StatusStufe! The Date is corrected to the current date. Also the store is sorted by Datum now.
Dustin Demuth <dustin@intevation.de>
parents: 974
diff changeset
130 //If possible copy the previous record into the new one.
c2a726887dd7 The last status can not be edited anymore. When a new status is added, the new record is preset with ALL previous variables, this includes the StatusStufe! The Date is corrected to the current date. Also the store is sorted by Datum now.
Dustin Demuth <dustin@intevation.de>
parents: 974
diff changeset
131 //this assumes the store is ordered correctly, most recent status last.
992
77ea9a5c5f1d Do not clone the Status if the Recent UserID differs from the Recent Status Erzeuger. In addition: Use a Method to determine the recent status which does not require correct ordering of status
Dustin Demuth <dustin@intevation.de>
parents: 990
diff changeset
132 // Do not copy, if current userid differs from the id of the current status
77ea9a5c5f1d Do not clone the Status if the Recent UserID differs from the Recent Status Erzeuger. In addition: Use a Method to determine the recent status which does not require correct ordering of status
Dustin Demuth <dustin@intevation.de>
parents: 990
diff changeset
133 if (lastrow > 0 &&
77ea9a5c5f1d Do not clone the Status if the Recent UserID differs from the Recent Status Erzeuger. In addition: Use a Method to determine the recent status which does not require correct ordering of status
Dustin Demuth <dustin@intevation.de>
parents: 990
diff changeset
134 Ext.Array.contains(Lada.mst, recentStatus.get('erzeuger'))) {
77ea9a5c5f1d Do not clone the Status if the Recent UserID differs from the Recent Status Erzeuger. In addition: Use a Method to determine the recent status which does not require correct ordering of status
Dustin Demuth <dustin@intevation.de>
parents: 990
diff changeset
135 if (recentStatus) {
77ea9a5c5f1d Do not clone the Status if the Recent UserID differs from the Recent Status Erzeuger. In addition: Use a Method to determine the recent status which does not require correct ordering of status
Dustin Demuth <dustin@intevation.de>
parents: 990
diff changeset
136 // clone the status
77ea9a5c5f1d Do not clone the Status if the Recent UserID differs from the Recent Status Erzeuger. In addition: Use a Method to determine the recent status which does not require correct ordering of status
Dustin Demuth <dustin@intevation.de>
parents: 990
diff changeset
137 var record = recentStatus.copy()
77ea9a5c5f1d Do not clone the Status if the Recent UserID differs from the Recent Status Erzeuger. In addition: Use a Method to determine the recent status which does not require correct ordering of status
Dustin Demuth <dustin@intevation.de>
parents: 990
diff changeset
138 }
77ea9a5c5f1d Do not clone the Status if the Recent UserID differs from the Recent Status Erzeuger. In addition: Use a Method to determine the recent status which does not require correct ordering of status
Dustin Demuth <dustin@intevation.de>
parents: 990
diff changeset
139
990
c2a726887dd7 The last status can not be edited anymore. When a new status is added, the new record is preset with ALL previous variables, this includes the StatusStufe! The Date is corrected to the current date. Also the store is sorted by Datum now.
Dustin Demuth <dustin@intevation.de>
parents: 974
diff changeset
140 record.set('id', null);
1023
3e9ff7786d2c Do not Copy the StatusWert if it equals 0
Dustin Demuth <dustin@intevation.de>
parents: 1007
diff changeset
141 if (record.get('statusWert') === 0) {
1027
859e2e9859cd Fixed an issue concerning the selection of status
Dustin Demuth <dustin@intevation.de>
parents: 1025
diff changeset
142 record.set('statusWert', '');
1023
3e9ff7786d2c Do not Copy the StatusWert if it equals 0
Dustin Demuth <dustin@intevation.de>
parents: 1007
diff changeset
143 }
990
c2a726887dd7 The last status can not be edited anymore. When a new status is added, the new record is preset with ALL previous variables, this includes the StatusStufe! The Date is corrected to the current date. Also the store is sorted by Datum now.
Dustin Demuth <dustin@intevation.de>
parents: 974
diff changeset
144 } else {
c2a726887dd7 The last status can not be edited anymore. When a new status is added, the new record is preset with ALL previous variables, this includes the StatusStufe! The Date is corrected to the current date. Also the store is sorted by Datum now.
Dustin Demuth <dustin@intevation.de>
parents: 974
diff changeset
145 //create a new one
c2a726887dd7 The last status can not be edited anymore. When a new status is added, the new record is preset with ALL previous variables, this includes the StatusStufe! The Date is corrected to the current date. Also the store is sorted by Datum now.
Dustin Demuth <dustin@intevation.de>
parents: 974
diff changeset
146 var record = Ext.create('Lada.model.Status', {
c2a726887dd7 The last status can not be edited anymore. When a new status is added, the new record is preset with ALL previous variables, this includes the StatusStufe! The Date is corrected to the current date. Also the store is sorted by Datum now.
Dustin Demuth <dustin@intevation.de>
parents: 974
diff changeset
147 messungsId: button.up('statusgrid').recordId
c2a726887dd7 The last status can not be edited anymore. When a new status is added, the new record is preset with ALL previous variables, this includes the StatusStufe! The Date is corrected to the current date. Also the store is sorted by Datum now.
Dustin Demuth <dustin@intevation.de>
parents: 974
diff changeset
148 });
1044
8e579acfe0b1 Set preselected messstelle in status editor.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1027
diff changeset
149 if (Ext.data.StoreManager.get('messstellenFiltered').count() === 1) {
8e579acfe0b1 Set preselected messstelle in status editor.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1027
diff changeset
150 record.set('erzeuger', Ext.data.StoreManager.get('messstellenFiltered').getAt(0).get('id'));
8e579acfe0b1 Set preselected messstelle in status editor.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1027
diff changeset
151 }
990
c2a726887dd7 The last status can not be edited anymore. When a new status is added, the new record is preset with ALL previous variables, this includes the StatusStufe! The Date is corrected to the current date. Also the store is sorted by Datum now.
Dustin Demuth <dustin@intevation.de>
parents: 974
diff changeset
152 }
945
023e622f9551 Added the ability to work with "StatusWerten" which are delivered by the lada-server.
Dustin Demuth <dustin@intevation.de>
parents: 944
diff changeset
153
990
c2a726887dd7 The last status can not be edited anymore. When a new status is added, the new record is preset with ALL previous variables, this includes the StatusStufe! The Date is corrected to the current date. Also the store is sorted by Datum now.
Dustin Demuth <dustin@intevation.de>
parents: 974
diff changeset
154 //Set the Date
c2a726887dd7 The last status can not be edited anymore. When a new status is added, the new record is preset with ALL previous variables, this includes the StatusStufe! The Date is corrected to the current date. Also the store is sorted by Datum now.
Dustin Demuth <dustin@intevation.de>
parents: 974
diff changeset
155 record.set('datum', new Date());
945
023e622f9551 Added the ability to work with "StatusWerten" which are delivered by the lada-server.
Dustin Demuth <dustin@intevation.de>
parents: 944
diff changeset
156
990
c2a726887dd7 The last status can not be edited anymore. When a new status is added, the new record is preset with ALL previous variables, this includes the StatusStufe! The Date is corrected to the current date. Also the store is sorted by Datum now.
Dustin Demuth <dustin@intevation.de>
parents: 974
diff changeset
157 button.up('statusgrid').store.insert(lastrow, record);
c2a726887dd7 The last status can not be edited anymore. When a new status is added, the new record is preset with ALL previous variables, this includes the StatusStufe! The Date is corrected to the current date. Also the store is sorted by Datum now.
Dustin Demuth <dustin@intevation.de>
parents: 974
diff changeset
158 button.up('statusgrid').getPlugin('rowedit').startEdit(lastrow, 1);
994
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
159 },
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
160
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
161 /**
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
162 * Reset
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
163 * This Function instructs the server to reset the current status
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
164 * WIP / TODO
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
165 *
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
166 **/
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
167 reset: function(button) {
998
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
168 var me = this;
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
169 var rstbutton = button;
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
170 var i18n = Lada.getApplication().bundle;
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
171 Ext.MessageBox.confirm(
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
172 i18n.getMsg('statusgrid.reset.mbox.title'),
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
173 i18n.getMsg('statusgrid.reset.mbox.text'),
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
174 function(btn) {
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
175 if (btn === 'yes') {
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
176 me.doReset(rstbutton);
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
177 }
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
178 });
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
179 },
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
180
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
181 doReset: function(button) {
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
182 var i18n = Lada.getApplication().bundle;
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
183
1217
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
184 var s = button.up('window').down('messungform').getCurrentStatus();
994
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
185 var messId = button.up('window').down('messungform').getRecord().get('id');
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
186
1217
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
187 if(!s) {
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
188 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
189 i18n.getMsg('err.msg.generic.body'));
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
190 return;
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
191 }
1225
19855757a950 Fix status reset.
Tom Gottfried <tom@intevation.de>
parents: 1217
diff changeset
192
994
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
193 //Set Status to 'Resetted' (8)
1217
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
194 var kombis = Ext.data.StoreManager.get('statuskombi');
1225
19855757a950 Fix status reset.
Tom Gottfried <tom@intevation.de>
parents: 1217
diff changeset
195 var stufe = kombis.getById(s.get('statusKombi')).get('statusStufe').id;
1217
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
196 var kombiNdx = kombis.findBy(function(record, id) {
1225
19855757a950 Fix status reset.
Tom Gottfried <tom@intevation.de>
parents: 1217
diff changeset
197 return record.get('statusStufe').id === stufe
19855757a950 Fix status reset.
Tom Gottfried <tom@intevation.de>
parents: 1217
diff changeset
198 && record.get('statusWert').id === 8
1217
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
199 });
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
200 var record = s.copy();
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
201 record.set('datum', new Date());
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
202 record.set('statusKombi', kombis.getAt(kombiNdx).get('id'));
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
203 record.set('id', null);
4270da0f7d3b Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents: 1062
diff changeset
204 record.set('text', i18n.getMsg('statusgrid.resetText'));
994
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
205
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
206 Ext.Ajax.request({
1007
23bfcbdb4527 merged.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1002
diff changeset
207 url: 'lada-server/rest/status',
994
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
208 jsonData: record.getData(),
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
209 method: 'POST',
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
210 success: function(response) {
1025
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
211 var i18n = Lada.getApplication().bundle;
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
212 var json = Ext.JSON.decode(response.responseText);
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
213
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
214 if(json) {
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
215 if (!json.success) {
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
216 if(json.message){
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
217 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title')
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
218 +' #'+json.message,
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
219 i18n.getMsg(json.message));
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
220 } else {
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
221 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
222 i18n.getMsg('err.msg.generic.body'));
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
223 }
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
224 }
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
225 }
2329acae1705 Added Error handlers for Statuswerte
Dustin Demuth <dustin@intevation.de>
parents: 1023
diff changeset
226
1062
0497693d5b74 Show statusStufe in messunggrid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1044
diff changeset
227 var win = button.up('window');
0497693d5b74 Show statusStufe in messunggrid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1044
diff changeset
228 win.initData();
996
bf7bb9583a40 Statusworkflow: More work on the reset Button
Dustin Demuth <dustin@intevation.de>
parents: 994
diff changeset
229 button.up('grid').initData();
1062
0497693d5b74 Show statusStufe in messunggrid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1044
diff changeset
230 try {
0497693d5b74 Show statusStufe in messunggrid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1044
diff changeset
231 win.parentWindow.initData();
0497693d5b74 Show statusStufe in messunggrid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1044
diff changeset
232 win.parentWindow.down('messunggrid').store.reload();
0497693d5b74 Show statusStufe in messunggrid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1044
diff changeset
233 }
0497693d5b74 Show statusStufe in messunggrid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1044
diff changeset
234 catch(e) {
0497693d5b74 Show statusStufe in messunggrid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1044
diff changeset
235 }
994
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
236 },
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
237 failure: function(response) {
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
238 // TODO sophisticated error handling, with understandable Texts
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
239 var json = Ext.JSON.decode(response.responseText);
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
240 if (json) {
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
241 if(json.message){
998
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
242 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title')
994
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
243 +' #'+json.message,
998
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
244 i18n.getMsg(json.message));
994
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
245 } else {
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
246 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
247 i18n.getMsg('err.msg.generic.body'));
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
248 }
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
249 } else {
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
250 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
251 i18n.getMsg('err.msg.generic.body'));
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
252 }
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
253 }
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
254 });
998
4bbb3da88c14 Statusreset: added a confirmation dialog and i18n
Dustin Demuth <dustin@intevation.de>
parents: 996
diff changeset
255 }
994
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
256
594
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
257 });

http://lada.wald.intevation.org