raimund@1082: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
raimund@1082: * Software engineering by Intevation GmbH
raimund@1082: *
raimund@1082: * This file is Free Software under the GNU GPL (v>=3)
raimund@1082: * and comes with ABSOLUTELY NO WARRANTY! Check out
raimund@1082: * the documentation coming with IMIS-Labordaten-Application for details.
raimund@1082: */
raimund@1082:
raimund@1082: /**
raimund@1082: * This is a simple Window to set the Status for multiple Messungen on bulk.
raimund@1082: */
raimund@1082: Ext.define('Lada.view.window.SetStatus', {
raimund@1082: extend: 'Ext.window.Window',
raimund@1082: alias: 'setstatuswindow',
raimund@1082:
raimund@1082: requires: [
raimund@1082: 'Lada.view.widget.Status'
raimund@1082: ],
raimund@1082:
raimund@1082: grid: null,
raimund@1082: selection: null,
raimund@1082:
raimund@1082: modal: true,
raimund@1082: closable: false,
raimund@1082: resultMessage: '',
raimund@1082:
raimund@1082: /**
raimund@1082: * This function initialises the Window
raimund@1082: */
raimund@1082: initComponent: function() {
raimund@1082: var i18n = Lada.getApplication().bundle;
raimund@1082: var me = this;
raimund@1082: this.items = [{
raimund@1082: xtype: 'panel',
raimund@1082: name: 'valueselection',
raimund@1082: border: 0,
raimund@1082: items: [{
raimund@1082: xtype: 'fieldset',
raimund@1082: title: 'Status für ' + this.selection.length + ' Messung(en) setzen',
raimund@1082: margin: '5, 5, 10, 5',
raimund@1082: items: [{
raimund@1082: xtype: 'combobox',
raimund@1082: store: Ext.data.StoreManager.get('messstellenFiltered'),
raimund@1082: displayField: 'messStelle',
raimund@1082: valueField: 'id',
raimund@1082: allowBlank: false,
raimund@1082: queryMode: 'local',
raimund@1082: editable: false,
raimund@1082: width: 300,
raimund@1082: labelWidth: 100,
raimund@1082: emptyText: 'Wählen Sie einen Erzeuger aus.',
raimund@1082: fieldLabel: i18n.getMsg('statusgrid.header.erzeuger')
raimund@1082: }, {
raimund@1082: xtype: 'statuswert',
raimund@1082: allowBlank: false,
raimund@1082: width: 300,
raimund@1082: labelWidth: 100,
raimund@1082: fieldLabel: i18n.getMsg('statusgrid.header.statusWert')
raimund@1082: }, {
raimund@1082: xtype: 'textarea',
raimund@1082: width: 300,
raimund@1082: height: 100,
raimund@1082: labelWidth: 100,
raimund@1082: fieldLabel: i18n.getMsg('statusgrid.header.text'),
raimund@1082: emptyText: 'Geben Sie einen Kommentar ein.'
raimund@1082: }]
raimund@1082: }]
raimund@1082: }, {
raimund@1082: xtype: 'panel',
raimund@1082: hidden: true,
raimund@1082: margin: '5, 5, 5, 5',
raimund@1082: overflow: 'auto',
raimund@1082: name: 'result'
raimund@1082: }, {
raimund@1082: xtype: 'progressbar',
raimund@1082: margin: '5, 5, 5, 5',
raimund@1082: hidden: true,
raimund@1082: text: 'Verarbeite Statusänderungen'
raimund@1082: }];
raimund@1082: this.buttons = [{
raimund@1082: text: i18n.getMsg('statusSetzen'),
raimund@1082: name: 'start',
raimund@1082: icon: 'resources/img/emblem-important.png',
raimund@1082: handler: this.setStatus
raimund@1082: }, {
raimund@1082: text: i18n.getMsg('cancel'),
raimund@1082: name: 'abort',
raimund@1082: handler: this.closeWindow
raimund@1082: }, {
raimund@1082: text: i18n.getMsg('close'),
raimund@1082: name: 'close',
raimund@1082: hidden: true,
raimund@1082: handler: this.closeWindow
raimund@1082: }];
raimund@1082:
raimund@1082: this.callParent(arguments);
raimund@1082: },
raimund@1082:
raimund@1082: /**
raimund@1082: * @private
raimund@1082: * A handler for a Abort-Button
raimund@1082: */
raimund@1082: closeWindow: function(button) {
raimund@1082: var win = button.up('window');
raimund@1082: win.close();
raimund@1082: },
raimund@1082:
raimund@1082: /**
raimund@1082: * @private
raimund@1082: * A handler to setStatus on Bulk.
raimund@1082: */
raimund@1082: setStatus: function(button) {
raimund@1082: var win = button.up('window');
raimund@1082: win.down('panel').disable();
raimund@1082: win.down('button[name=start]').disable();
raimund@1082: win.down('button[name=abort]').disable();
raimund@1082: var progress = win.down('progressbar');
raimund@1082: progress.show();
raimund@1082: win.send();
raimund@1082: },
raimund@1082:
raimund@1082: send: function() {
raimund@1082: var i18n = Lada.getApplication().bundle;
raimund@1082: var me = this;
raimund@1082: var progress = me.down('progressbar');
raimund@1082: var progressText = progress.getText();
raimund@1082: var count = 0;
raimund@1082: for (var i = 0; i < this.selection.length; i++) {
raimund@1082: var data = Ext.create('Lada.model.Status', {
raimund@1082: messungsId: this.selection[i].get('id'),
raimund@1082: erzeuger: this.down('combobox').getValue(),
raimund@1082: datum: new Date(),
raimund@1082: statusWert: this.down('statuswert').getValue(),
raimund@1082: text: this.down('textarea').getValue()
raimund@1082: });
raimund@1082: Ext.Ajax.request({
raimund@1082: url: 'lada-server/rest/status',
raimund@1082: method: 'POST',
raimund@1082: jsonData: data.raw,
raimund@1082: success: function(response) {
raimund@1082: var json = Ext.JSON.decode(response.responseText);
raimund@1082: me.resultMessage += '' + i18n.getMsg('messung') + ': ';
raimund@1082: var sel = me.selection[count];
raimund@1082: me.resultMessage += sel.get('hauptprobenNr') + ' - ' + sel.get('nebenprobenNr') + '