view app/controller/MKommentare.js @ 362:6a7a9267e00f

Issue56: Changed way how to set the form and window to readonly. Now all dialogs should habe proper readonly settings. Now the Save and Cancel button are displayed as needed.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Thu, 15 Aug 2013 14:07:35 +0200
parents e95662994c50
children debfcc7713e3
line wrap: on
line source
/**
 * Controller for Kommentare on Messungen
 */
Ext.define('Lada.controller.MKommentare', {
    extend: 'Lada.controller.Base',
    views: [
        'mkommentare.Create'
    ],
    stores: [
        'MKommentare'
    ],
    models: [
        'MKommentar'
    ],
    init: function() {
        console.log('Initialising the MKommentare controller');
        this.callParent();
    },
    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) {
        console.log('Adding new MKommentar for Messung ' + button.parentId + ' Probe ' + button.probeId);
        var kommentar = Ext.create('Lada.model.MKommentar');
        kommentar.set('probeId', button.probeId);
        kommentar.set('messungsId', button.parentId);
        var view = Ext.widget('mkommentarecreate', {model: kommentar});
    },
    editItem: function(grid, record) {
        console.log('Editing Kommentar');
        record.getAuthInfo(this.initEditWindow)
        console.log("Loaded MKommentar with ID " + record.getId()); //outputs ID
    },
    initEditWindow: function(record, readonly, owner) {
        var view = Ext.widget('mkommentarecreate', {model: record});
        var ignore = Array();
        if (readonly) {
            var form = view.down('form');
            form.setReadOnly(true, ignore);
        }
    },
    createSuccess: function(form, record, operation) {
        // Reload store
        var store = this.getMKommentareStore();
        store.reload();
        var win = form.up('window');
        win.close();
    }
});

http://lada.wald.intevation.org