annotate app/controller/grid/Status.js @ 996:bf7bb9583a40

Statusworkflow: More work on the reset Button
author Dustin Demuth <dustin@intevation.de>
date Fri, 08 Jan 2016 14:34:27 +0100
parents 092e245b13a4
children 4bbb3da88c14
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,
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
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) {
944
1f1467713c3f Status grid modified
Michael Stanko <mstanko@bfs.de>
parents: 826
diff changeset
42 context.record.set('sdatum', new Date());
594
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 context.record.save({
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 success: function() {
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 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
46 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
47 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
48 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
49 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
50 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
51 }
ea477f62a667 Refresh a Probe and its Messungengrid when the status of a messung was changed
Dustin Demuth <dustin@intevation.de>
parents: 970
diff changeset
52 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
53 }
594
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 },
701
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
55 failure: function(request, response) {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
56 var json = response.request.scope.reader.jsonData;
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
57 if (json) {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
58 if (json.message){
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
59 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title')
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
60 +' #'+json.message,
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
61 Lada.getApplication().bundle.getMsg(json.message));
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
62 } else {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
63 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'),
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
64 Lada.getApplication().bundle.getMsg('err.msg.generic.body'));
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
65 }
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
66 } else {
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
67 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'),
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
68 Lada.getApplication().bundle.getMsg('err.msg.response.body'));
f0bc5387abcc Added failure - Messages
Dustin Demuth <dustin@intevation.de>
parents: 637
diff changeset
69 }
594
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 }
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 });
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 },
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
74 /**
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
75 * When the edit was canceled,
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
76 * 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
77 */
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
78 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
79 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
80 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
81 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
82 }
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 594
diff changeset
83 },
8acb3123b46c Remove a new record on cancel in grids with rowediting plugin.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 594
diff changeset
84
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
85 /**
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
86 * 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
87 * 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
88 * if possible.
742
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
89 */
6e28ebbe1a73 added documentation for Form and Grid controllers
Dustin Demuth <dustin@intevation.de>
parents: 701
diff changeset
90 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
91 var lastrow = button.up('statusgrid').store.count()
594
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92
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
93 // 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
94 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
95 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
96
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
97 //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
98 //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
99 // 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
100 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
101 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
102
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
103 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
104 // 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
105 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
106 }
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
107
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
108 record.set('id', null);
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
109 } 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
110 //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
111 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
112 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
113 });
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
114 }
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
115
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
116 //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
117 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
118
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
119 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
120 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
121 },
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
122
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
123 /**
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
124 * 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
125 * 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
126 * 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
127 *
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
128 **/
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
129 reset: function(button) {
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
130 var s = button.up('window').down('messungform').getRecord().get('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
131 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
132 var recentStatus = button.up('statusgrid').store.getById(s);
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
133
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
134 //Set Status to 'Resetted' (8)
996
bf7bb9583a40 Statusworkflow: More work on the reset Button
Dustin Demuth <dustin@intevation.de>
parents: 994
diff changeset
135 if (recentStatus) {
bf7bb9583a40 Statusworkflow: More work on the reset Button
Dustin Demuth <dustin@intevation.de>
parents: 994
diff changeset
136 var record = recentStatus.copy();
bf7bb9583a40 Statusworkflow: More work on the reset Button
Dustin Demuth <dustin@intevation.de>
parents: 994
diff changeset
137 record.set('datum', new Date());
bf7bb9583a40 Statusworkflow: More work on the reset Button
Dustin Demuth <dustin@intevation.de>
parents: 994
diff changeset
138 record.set('statusWert', 8);
bf7bb9583a40 Statusworkflow: More work on the reset Button
Dustin Demuth <dustin@intevation.de>
parents: 994
diff changeset
139 record.set('id', null);
bf7bb9583a40 Statusworkflow: More work on the reset Button
Dustin Demuth <dustin@intevation.de>
parents: 994
diff changeset
140 record.set('text', null);
bf7bb9583a40 Statusworkflow: More work on the reset Button
Dustin Demuth <dustin@intevation.de>
parents: 994
diff changeset
141 }
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
142
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
143 Ext.Ajax.request({
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
144 url: 'lada-server/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
145 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
146 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
147 success: 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
148 button.up('window').initData();
996
bf7bb9583a40 Statusworkflow: More work on the reset Button
Dustin Demuth <dustin@intevation.de>
parents: 994
diff changeset
149 button.up('grid').initData();
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
150 },
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
151 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
152 // 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
153 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
154 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
155 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
156 formPanel.setMessages(json.errors, json.warnings);
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
157 }
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
158 if(json.message){
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 Ext.Msg.alert(Lada.getApplication().bundle.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
160 +' #'+json.message,
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 Lada.getApplication().bundle.getMsg(json.message));
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 } 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
163 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
164 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
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 } 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
167 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
168 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
169 }
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
170 }
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
171 });
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
172
092e245b13a4 draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
Dustin Demuth <dustin@intevation.de>
parents: 992
diff changeset
173 }
594
89b337cbfb5d Added status grid and controller.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
174 });

http://lada.wald.intevation.org