view app/controller/MKommentare.js @ 524:8972f008dfb1

Make tables editable for 'MKommentare' See LSB 3.5
author Roland Geider <roland.geider@intevation.de>
date Tue, 16 Dec 2014 16:20:42 +0100
parents 8b4ec61c5752
children 99e738c17b81
line wrap: on
line source
/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU GPL (v>=3)
 * and comes with ABSOLUTELY NO WARRANTY! Check out
 * the documentation coming with IMIS-Labordaten-Application for details.
 */

/**
 * Controller for Kommentare on Messungen
 */
Ext.define('Lada.controller.MKommentare', {
    extend: 'Lada.controller.Base',

    views: [
        'mkommentare.Create'
    ],

    stores: [
        'KommentareM'
    ],

    models: [
        'KommentarM'
    ],

    init: function() {
        this.callParent(arguments);
    },

    addListeners: function() {
        this.control({
            //'mkommentarelist': {
            //    itemdblclick: this.editItem
            //},
            'mkommentarelist toolbar button[action=add]': {
                click: this.addItem
            },
            'mkommentarelist toolbar button[action=delete]': {
                click: this.deleteItem
            },
            'mkommentarecreate button[action=save]': {
                click: this.saveItem
            },
            'mkommentarecreate form': {
                savesuccess: this.createSuccess,
                savefailure: this.createFailure
            }
        });
    },

    addItem: function(button) {
        var kommentar = Ext.create('Lada.model.KommentarM');
        kommentar.set('probeId', button.probeId);
        kommentar.set('messungsId', button.parentId);
        Ext.widget('mkommentarecreate', {
            model: kommentar
        });
    },

    editItem: function(grid, record) {
        var mstore = Ext.data.StoreManager.get('Messungen');
        var messung = mstore.getById(record.get('messungsId'));
        record.getAuthInfo(this.initEditWindow, messung.get('probeId'));
    },

    initEditWindow: function(record, readonly) {
        var view = Ext.widget('mkommentarecreate', {
            model: record
        });
        var ignore = [];
        if (readonly) {
            var form = view.down('form');
            form.setReadOnly(true, ignore);
        }
    },

    createSuccess: function(form) {
        // Reload store
        var store = this.getKommentareMStore();
        store.reload();
        var win = form.up('window');
        win.close();
    }
});

http://lada.wald.intevation.org