comparison app/view/window/SetStatus.js @ 1230:38599f18c863

Fix setting status in bulk via SetStatus window.
author Tom Gottfried <tom@intevation.de>
date Fri, 28 Oct 2016 18:44:10 +0200
parents d5b9a5c75872
children
comparison
equal deleted inserted replaced
1229:eeed1b92341f 1230:38599f18c863
28 * This function initialises the Window 28 * This function initialises the Window
29 */ 29 */
30 initComponent: function() { 30 initComponent: function() {
31 var i18n = Lada.getApplication().bundle; 31 var i18n = Lada.getApplication().bundle;
32 var me = this; 32 var me = this;
33 var statusWerteStore = Ext.create('Lada.store.StatusWerte');
34 statusWerteStore.load({
35 params: {
36 messungsId: Ext.Array.pluck(this.selection, 'id').toString()
37 }
38 });
39
33 this.items = [{ 40 this.items = [{
34 xtype: 'form', 41 xtype: 'form',
35 name: 'valueselection', 42 name: 'valueselection',
36 border: 0, 43 border: 0,
37 items: [{ 44 items: [{
50 labelWidth: 100, 57 labelWidth: 100,
51 emptyText: 'Wählen Sie einen Erzeuger aus.', 58 emptyText: 'Wählen Sie einen Erzeuger aus.',
52 fieldLabel: i18n.getMsg('statusgrid.header.erzeuger') 59 fieldLabel: i18n.getMsg('statusgrid.header.erzeuger')
53 }, { 60 }, {
54 xtype: 'statuswert', 61 xtype: 'statuswert',
62 store: statusWerteStore,
55 allowBlank: false, 63 allowBlank: false,
56 width: 300, 64 width: 300,
57 labelWidth: 100, 65 labelWidth: 100,
58 fieldLabel: i18n.getMsg('statusgrid.header.statusWert') 66 fieldLabel: i18n.getMsg('statusgrid.header.statusWert')
67 }, {
68 xtype: 'combobox',
69 name: 'statusstufe',
70 store: Ext.data.StoreManager.get('statusstufe'),
71 displayField: 'stufe',
72 valueField: 'id',
73 allowBlank: false,
74 editable: false,
75 forceSelection: true,
76 width: 300,
77 labelWidth: 100,
78 fieldLabel: i18n.getMsg('statusgrid.header.statusStufe')
59 }, { 79 }, {
60 xtype: 'textarea', 80 xtype: 'textarea',
61 width: 300, 81 width: 300,
62 height: 100, 82 height: 100,
63 labelWidth: 100, 83 labelWidth: 100,
129 var i18n = Lada.getApplication().bundle; 149 var i18n = Lada.getApplication().bundle;
130 var me = this; 150 var me = this;
131 var progress = me.down('progressbar'); 151 var progress = me.down('progressbar');
132 var progressText = progress.getText(); 152 var progressText = progress.getText();
133 var count = 0; 153 var count = 0;
154
155 var wert = me.down('statuswert').getValue();
156 var stufe = me.down('[name=statusstufe]').getValue();
157 var kombis = Ext.data.StoreManager.get('statuskombi');
158 var kombiIdx = kombis.findBy(function(record) {
159 return record.get('statusStufe').id === stufe
160 && record.get('statusWert').id === wert;
161 });
162 if (kombiIdx < 0) {
163 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
164 'Unerlaubte Kombination aus Status und Stufe');
165 me.down('button[name=close]').show();
166 return;
167 }
168
134 for (var i = 0; i < this.selection.length; i++) { 169 for (var i = 0; i < this.selection.length; i++) {
135 var data = Ext.create('Lada.model.Status', { 170 var data = Ext.create('Lada.model.Status', {
136 messungsId: this.selection[i].get('id'), 171 messungsId: this.selection[i].get('id'),
137 erzeuger: this.down('combobox').getValue(), 172 mstId: this.down('combobox').getValue(),
138 datum: new Date(), 173 datum: new Date(),
139 statusWert: this.down('statuswert').getValue(), 174 statusKombi: kombis.getAt(kombiIdx).get('id'),
140 text: this.down('textarea').getValue() 175 text: this.down('textarea').getValue()
141 }); 176 });
142 Ext.Ajax.request({ 177 Ext.Ajax.request({
143 url: 'lada-server/rest/status', 178 url: 'lada-server/rest/status',
144 method: 'POST', 179 method: 'POST',

http://lada.wald.intevation.org