dustin@576: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
dustin@576:  * Software engineering by Intevation GmbH
dustin@576:  *
dustin@576:  * This file is Free Software under the GNU GPL (v>=3)
dustin@576:  * and comes with ABSOLUTELY NO WARRANTY! Check out
dustin@576:  * the documentation coming with IMIS-Labordaten-Application for details.
dustin@576:  */
dustin@576: 
dustin@576: /*
raimund@590:  * Window to edit a Messung
dustin@576:  */
dustin@576: Ext.define('Lada.view.window.MessungEdit', {
dustin@576:     extend: 'Ext.window.Window',
dustin@576:     alias: 'widget.messungedit',
dustin@576: 
dustin@581:     requires: [
raimund@590:       'Lada.view.form.Messung',
raimund@595:       'Lada.view.grid.Messwert',
raimund@595:       'Lada.view.grid.Status',
raimund@597:       'Lada.view.grid.MKommentar'
dustin@581:     ],
dustin@576: 
dustin@576:     collapsible: true,
dustin@576:     maximizable: true,
dustin@576:     autoshow: true,
dustin@576:     autoscroll: true,
dustin@576:     layout: 'fit',
dustin@576: 
dustin@576:     record: null,
raimund@644:     grid: null,
dustin@576: 
raimund@590:     initComponent: function() {
dustin@576:         if (this.record === null) {
dustin@576:             Ext.Msg.alert('Keine valide Messung ausgewählt!');
dustin@576:             this.callParent(arguments);
dustin@576:             return;
dustin@576:         }
raimund@590:         this.title = 'Messung ' + this.record.get('nebenprobenNr');
dustin@576:         this.buttons = [{
dustin@576:             text: 'Schließen',
dustin@576:             scope: this,
dustin@576:             handler: this.close
dustin@576:         }];
dustin@576:         this.width = 700;
dustin@576:         this.height = Ext.getBody().getViewSize().height - 30;
dustin@576: 
dustin@576:         this.items = [{
dustin@576:             border: 0,
dustin@576:             autoScroll: true,
dustin@576:             items: [{
dustin@581:                 xtype: 'messungform',
dustin@611:                 margin: 5,
raimund@590:                 recordId: this.record.get('id')
dustin@613:            }, {
dustin@576:                 xtype: 'fset',
dustin@576:                 name: 'messwerte',
raimund@590:                 title: 'Messwerte',
raimund@590:                 padding: '5, 5',
raimund@590:                 margin: 5,
raimund@590:                 items: [{
raimund@590:                     xtype: 'messwertgrid',
raimund@590:                     recordId: this.record.get('id')
dustin@613:                 }]
dustin@576:             }, {
dustin@576:                 xtype: 'fset',
dustin@576:                 name: 'messungstatus',
raimund@595:                 title: 'Status',
raimund@595:                 padding: '5, 5',
raimund@595:                 margin: 5,
raimund@595:                 items: [{
raimund@595:                     xtype: 'statusgrid',
raimund@595:                     recordId: this.record.get('id')
raimund@595:                 }]
dustin@576:            }, {
dustin@576:                 xtype: 'fset',
dustin@576:                 name: 'messungskommentare',
raimund@597:                 title: 'Kommentare',
raimund@597:                 padding: '5, 5',
raimund@597:                 margin: 5,
raimund@597:                 items: [{
raimund@597:                     xtype: 'mkommentargrid',
raimund@597:                     recordId: this.record.get('id')
raimund@597:                 }]
dustin@576:            }]
dustin@576:         }];
dustin@576:         this.callParent(arguments);
dustin@576:     },
dustin@576: 
dustin@576:     initData: function() {
dustin@576:         this.clearMessages();
dustin@611:         this.down('messungform').setRecord(this.record);
dustin@576:         Ext.ClassManager.get('Lada.model.Messung').load(this.record.get('id'), {
raimund@590:             failure: function(record) {
raimund@590:                 // TODO
raimund@590:                 console.log(record);
dustin@576:             },
raimund@590:             success: function(record, response) {
raimund@590:                 this.down('messungform').setRecord(record);
raimund@590:                 var json = Ext.decode(response.response.responseText);
raimund@590:                 if (json) {
raimund@590:                     this.setMessages(json.errors, json.warnings);
raimund@590:                 }
dustin@576:             },
dustin@576:             scope: this
dustin@611:         });
dustin@576:     },
dustin@576: 
dustin@576:     setMessages: function(errors, warnings) {
dustin@576:         //todo this is a stub
dustin@576:     },
dustin@576:     clearMessages: function() {
dustin@576:         //todo this is a stub
dustin@576:     }
dustin@576: 
dustin@576: });