<commit_before>Vps.Auto.FormPanel = Ext.extend(Vps.Binding.AbstractPanel, {
    autoScroll: true, //um scrollbars zu bekommen
    border: false,
    maskDisabled: true,
    layout: 'fit',

    initComponent: function()
    {
        if (!this.formConfig) this.formConfig = {};
        if (!this.baseParams) this.baseParams = {};
        if (this.autoLoad !== false) {
            this.autoLoad = true;
        } else {
            delete this.autoLoad;
        }

        this.addEvents(
            'loadform',
            'deleteaction',
            'addaction',
            'renderform'
        );
        this.actions.save = new Ext.Action({
            text    : trlVps('Save'),
            icon    : '/assets/silkicons/table_save.png',
            cls     : 'x-btn-text-icon',
            handler : this.onSave,
            scope   : this
        });
        this.actions.saveBack = new Ext.Action({
            text    : trlVps('Save and Back'),
            icon    : '/assets/silkicons/table_save.png',
            cls     : 'x-btn-text-icon',
            handler : this.onSaveBack,
            scope   : this,
            hidden  : true //standardmäßig versteckt, ComponentPanel ruft show() auf
        });
        this.actions['delete'] = new Ext.Action({
            text    : trlVps('Delete'),
            icon    : '/assets/silkicons/table_delete.png',
            cls     : 'x-btn-text-icon',
            handler : this.onDelete,
            scope   : this
        });
        this.actions.add = new Ext.Action({
            text    : trlVps('New Entry'),
            icon    : '/assets/silkicons/table_add.png',
            cls     : 'x-btn-text-icon',
            handler : this.onAdd,
            scope   : this
        });

        Vps.Auto.FormPanel.superclass.initComponent.call(this);

        if (!this.formConfig) this.formConfig = {};
        Ext.applyIf(this.formConfig, {
            baseParams       : {},
            trackResetOnLoad : true,
            maskDisabled     : false,
        });

        if (!this.controllerUrl) {
            throw new Error('No controllerUrl specified for AutoForm.');
        }
        this.formConfig.url = this.controllerUrl + '/json-save';
    },

    doAutoLoad : function()
    {
        //autoLoad kann in der zwischenzeit abgeschaltet werden, zB wenn
        //wir in einem Binding sind
        if (!this.autoLoad) return;

        this.load();
    },

    onMetaChange : function(meta)
    {
        Ext.applyIf(meta.form, this.formConfig);

        if (this.baseCls) meta.form.baseCls = this.baseCls; //use the same

        for (var i in this.actions) {
            if (!meta.permissions[i]) {
                this.getAction(i).hide();
            }
        }

        if (meta.buttons && typeof meta.form.tbar == 'undefined') {
            for (var b in meta.buttons) {
                if (!meta.form.tbar) meta.form.tbar = [];
                meta.form.tbar.push(this.getAction(b));
            }
	        if (meta.helpText) {
				meta.form.tbar.push('->');
	            meta.form.tbar.push(new Ext.Action({
	                icon : '/assets/silkicons/information.png',
	                cls : 'x-btn-icon',
	                handler : function (a) {
	                    var helpWindow = new Ext.Window({
	                        html: meta.helpText,
	                        width: 400,
	                        bodyStyle: 'padding: 10px; background-color: white;',
	                        autoHeight: true,
	                        bodyBorder : false,
	                        title: trlVps('Info'),
	                        resize: false
	                    });
	                    helpWindow.show();
	                },
	                scope: this
	            }));
	        }
        }
        if (this.formPanel != undefined) {
            this.remove(this.formPanel, true);
        }

        this.formPanel = new Ext.FormPanel({
            autoScroll: true,
            items: meta.form
        });
        this.formPanel.on('render', function() {
            this.fireEvent('renderform', this.getForm());
        }, this);
        this.add(this.formPanel);
        this.doLayout();
        this.getForm().baseParams = this.baseParams;
    },

    isDirty : function() {
        var f = this.getForm();
        if (!f) return false;
        return f.isDirty();
    },

    load : function(params, options) {

        if (this.el) this.el.mask(trlVps('Loading...'));

        if (!params) params = {};

        //es kann auch direkt die id übergeben werden<commit_msg>hintergrundfarbe in popup nicht weiss<commit_after>Vps.Auto.FormPanel = Ext.extend(Vps.Binding.AbstractPanel, {
    autoScroll: true, //um scrollbars zu bekommen
    border: false,
    maskDisabled: true,
    layout: 'fit',

    initComponent: function()
    {
        if (!this.formConfig) this.formConfig = {};
        if (!this.baseParams) this.baseParams = {};
        if (this.autoLoad !== false) {
            this.autoLoad = true;
        } else {
            delete this.autoLoad;
        }

        this.addEvents(
            'loadform',
            'deleteaction',
            'addaction',
            'renderform'
        );
        this.actions.save = new Ext.Action({
            text    : trlVps('Save'),
            icon    : '/assets/silkicons/table_save.png',
            cls     : 'x-btn-text-icon',
            handler : this.onSave,
            scope   : this
        });
        this.actions.saveBack = new Ext.Action({
            text    : trlVps('Save and Back'),
            icon    : '/assets/silkicons/table_save.png',
            cls     : 'x-btn-text-icon',
            handler : this.onSaveBack,
            scope   : this,
            hidden  : true //standardmäßig versteckt, ComponentPanel ruft show() auf
        });
        this.actions['delete'] = new Ext.Action({
            text    : trlVps('Delete'),
            icon    : '/assets/silkicons/table_delete.png',
            cls     : 'x-btn-text-icon',
            handler : this.onDelete,
            scope   : this
        });
        this.actions.add = new Ext.Action({
            text    : trlVps('New Entry'),
            icon    : '/assets/silkicons/table_add.png',
            cls     : 'x-btn-text-icon',
            handler : this.onAdd,
            scope   : this
        });

        Vps.Auto.FormPanel.superclass.initComponent.call(this);

        if (!this.formConfig) this.formConfig = {};
        Ext.applyIf(this.formConfig, {
            baseParams       : {},
            trackResetOnLoad : true,
            maskDisabled     : false,
        });

        if (!this.controllerUrl) {
            throw new Error('No controllerUrl specified for AutoForm.');
        }
        this.formConfig.url = this.controllerUrl + '/json-save';
    },

    doAutoLoad : function()
    {
        //autoLoad kann in der zwischenzeit abgeschaltet werden, zB wenn
        //wir in einem Binding sind
        if (!this.autoLoad) return;

        this.load();
    },

    onMetaChange : function(meta)
    {
        Ext.applyIf(meta.form, this.formConfig);

        if (this.baseCls) meta.form.baseCls = this.baseCls; //use the same

        for (var i in this.actions) {
            if (!meta.permissions[i]) {
                this.getAction(i).hide();
            }
        }

        if (meta.buttons && typeof meta.form.tbar == 'undefined') {
            for (var b in meta.buttons) {
                if (!meta.form.tbar) meta.form.tbar = [];
                meta.form.tbar.push(this.getAction(b));
            }
	        if (meta.helpText) {
				meta.form.tbar.push('->');
	            meta.form.tbar.push(new Ext.Action({
	                icon : '/assets/silkicons/information.png',
	                cls : 'x-btn-icon',
	                handler : function (a) {
	                    var helpWindow = new Ext.Window({
	                        html: meta.helpText,
	                        width: 400,
	                        bodyStyle: 'padding: 10px; background-color: white;',
	                        autoHeight: true,
	                        bodyBorder : false,
	                        title: trlVps('Info'),
	                        resize: false
	                    });
	                    helpWindow.show();
	                },
	                scope: this
	            }));
	        }
        }
        if (this.formPanel != undefined) {
            this.remove(this.formPanel, true);
        }

        this.formPanel = new Ext.FormPanel({
            baseCls: 'x-plain',
            autoScroll: true,
            items: meta.form
        });
        this.formPanel.on('render', function() {
            this.fireEvent('renderform', this.getForm());
        }, this);
        this.add(this.formPanel);
        this.doLayout();
        this.getForm().baseParams = this.baseParams;
    },

    isDirty : function() {
        var f = this.getForm();
        if (!f) return false;
        return f.isDirty();
    },

    load : function(params, options) {

        if (this.el) this.el.mask(trlVps('Loading...'));

        if (!params) params = {};

        //es kann auch direkt die id übergeben werden
{'fraction_non_alphanumeric': 0.12611924000873553, 'fraction_numerical': 0.0010919414719371041, 'mean_word_length': 1.3801975051975053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '83827', 'n_tokens_mistral': 2660, 'n_tokens_neox': 2549, 'n_words': 521}