comparison app/controller/grid/Status.js @ 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
author Dustin Demuth <dustin@intevation.de>
date Thu, 07 Jan 2016 10:59:46 +0100
parents c2a726887dd7
children 092e245b13a4
comparison
equal deleted inserted replaced
991:19b78162e128 992:77ea9a5c5f1d
85 * if possible. 85 * if possible.
86 */ 86 */
87 add: function(button) { 87 add: function(button) {
88 var lastrow = button.up('statusgrid').store.count() 88 var lastrow = button.up('statusgrid').store.count()
89 89
90 // retrive current status from the messung.
91 var s = button.up('window').down('messungform').getRecord().get('status');
92 var recentStatus = button.up('statusgrid').store.getById(s);
90 93
91 //If possible copy the previous record into the new one. 94 //If possible copy the previous record into the new one.
92 //this assumes the store is ordered correctly, most recent status last. 95 //this assumes the store is ordered correctly, most recent status last.
93 if (lastrow > 0) { 96 // Do not copy, if current userid differs from the id of the current status
94 //clone the old one 97 if (lastrow > 0 &&
95 var recentStatus = button.up('statusgrid').store.getAt(lastrow-1); 98 Ext.Array.contains(Lada.mst, recentStatus.get('erzeuger'))) {
96 var record = recentStatus.copy() 99
100 if (recentStatus) {
101 // clone the status
102 var record = recentStatus.copy()
103 }
104
97 record.set('id', null); 105 record.set('id', null);
98 } else { 106 } else {
99 //create a new one 107 //create a new one
100 var record = Ext.create('Lada.model.Status', { 108 var record = Ext.create('Lada.model.Status', {
101 messungsId: button.up('statusgrid').recordId 109 messungsId: button.up('statusgrid').recordId

http://lada.wald.intevation.org