Skip to content
Code-Schnipsel Gruppen Projekte
BrickEdit.js 25,8 KiB
Newer Older
  • Learn to ignore specific revisions
  • Henning Leutz's avatar
    Henning Leutz committed
    /**
    
    Henning Leutz's avatar
    Henning Leutz committed
     * BrickEdit Panel
    
    Henning Leutz's avatar
    Henning Leutz committed
     * Edit and change a Brick
    
    Henning Leutz's avatar
    Henning Leutz committed
     *
    
    Henning Leutz's avatar
    Henning Leutz committed
     * @module package/quiqqer/bricks/bin/BrickEdit
    
    Henning Leutz's avatar
    Henning Leutz committed
     * @author www.pcsg.de (Henning Leutz)
     *
    
     * @require qui/QUI
     * @require qui/controls/desktop/Panel
     * @require package/quiqqer/bricks/bin/BrickAreas
     * @require Ajax
     * @require Locale
     * @require qui/utils/Form
     * @require utils/Controls
     * @require utils/Template
     * @require css!package/quiqqer/bricks/bin/BrickEdit.css
     *
    
    Henning Leutz's avatar
    Henning Leutz committed
     * @event onLoaded [ this ]
    
     * @event onSave [ this ]
    
    Henning Leutz's avatar
    Henning Leutz committed
     * @event onDelete [ this ]
    
    Henning Leutz's avatar
    Henning Leutz committed
     */
    
    Henning Leutz's avatar
    Henning Leutz committed
    define('package/quiqqer/bricks/bin/BrickEdit', [
    
    Henning Leutz's avatar
    Henning Leutz committed
    
        'qui/QUI',
    
        'qui/controls/desktop/Panel',
    
    Henning Leutz's avatar
    Henning Leutz committed
        'qui/controls/windows/Confirm',
    
    Henning Leutz's avatar
    Henning Leutz committed
        'package/quiqqer/bricks/bin/BrickAreas',
    
    Henning Leutz's avatar
    Henning Leutz committed
        'Ajax',
        'Locale',
    
        'qui/utils/Form',
    
    Henning Leutz's avatar
    Henning Leutz committed
        'utils/Controls',
    
        'utils/Template',
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
    Henning Leutz's avatar
    Henning Leutz committed
        'css!package/quiqqer/bricks/bin/BrickEdit.css'
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
    Michael's avatar
    Michael committed
    ], function (QUI, QUIPanel, QUIConfirm, BrickAreas, QUIAjax, QUILocale, QUIFormUtils, ControlUtils, Template) {
    
    Henning Leutz's avatar
    Henning Leutz committed
        "use strict";
    
    
    Henning Leutz's avatar
    Henning Leutz committed
        var lg = 'quiqqer/bricks';
    
    
    Henning Leutz's avatar
    Henning Leutz committed
        return new Class({
    
    
    Henning Leutz's avatar
    Henning Leutz committed
            Extends: QUIPanel,
            Type   : 'package/quiqqer/bricks/bin/BrickEdit',
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
    Henning Leutz's avatar
    Henning Leutz committed
            Binds: [
    
    Henning Leutz's avatar
    Henning Leutz committed
                '$onInject',
    
                '$onCreate',
                '$onDestroy',
                '$load',
                '$unload',
    
    Henning Leutz's avatar
    Henning Leutz committed
                'save',
                'del'
    
    Henning Leutz's avatar
    Henning Leutz committed
            ],
    
    
    Henning Leutz's avatar
    Henning Leutz committed
            options: {
                id         : false,
                projectName: false,
                projectLang: false
    
    Henning Leutz's avatar
    Henning Leutz committed
            },
    
    
    Henning Leutz's avatar
    Henning Leutz committed
            initialize: function (options) {
    
    Michael's avatar
    Michael committed
                this.parent(options);
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
                this.$availableBricks = [];
    
                this.$availableSettings = [];
    
                this.$customfields = [];
    
    Henning Leutz's avatar
    Henning Leutz committed
    
                this.$Editor = false;
    
                this.$Active = false;
    
    Henning Leutz's avatar
    Henning Leutz committed
    
                this.addEvents({
    
                                   onInject : this.$onInject,
                                   onCreate : this.$onCreate,
                                   onDestroy: this.$onDestroy,
                                   onResize : function () {
                                       var controls = QUI.Controls.getControlsInElement(this.getContent());
                                       controls.each(function (Control) {
                                           if ("resize" in Control) {
                                               Control.resize();
                                           }
                                       });
                                   }.bind(this)
                               });
    
    Henning Leutz's avatar
    Henning Leutz committed
            },
    
            /**
    
             * event : on create
    
    Henning Leutz's avatar
    Henning Leutz committed
             */
    
    Henning Leutz's avatar
    Henning Leutz committed
            $onCreate: function () {
    
                this.setAttributes({
    
                                       icon : 'fa fa-spinner fa-spin',
                                       title: '...'
                                   });
    
                                   name     : 'save',
                                   textimage: 'fa fa-save',
                                   text     : QUILocale.get('quiqqer/system', 'save'),
                                   events   : {
                                       click: this.save
                                   }
                               });
    
                                   name  : 'delete',
                                   icon  : 'fa fa-trash-o',
                                   title : QUILocale.get('quiqqer/system', 'delete'),
                                   events: {
                                       click: this.del
                                   },
                                   styles: {
                                       'float': 'right'
                                   }
                               });
    
                                     name  : 'information',
                                     icon  : 'fa fa-file-o',
                                     text  : QUILocale.get('quiqqer/system', 'information'),
                                     events: {
                                         onActive: this.$load
                                     }
                                 });
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
                this.addCategory({
    
                                     name  : 'settings',
                                     icon  : 'fa fa-magic',
                                     text  : QUILocale.get('quiqqer/system', 'properties'),
                                     events: {
                                         onActive: this.$load
                                     }
                                 });
    
                                     name  : 'extra',
                                     icon  : 'fa fa-gears',
                                     text  : QUILocale.get('quiqqer/system', 'settings'),
                                     events: {
                                         onActive: this.$load
                                     }
                                 });
    
                                     name  : 'content',
                                     icon  : 'fa fa-file-text-o',
                                     text  : QUILocale.get('quiqqer/system', 'content'),
                                     events: {
                                         onActive: this.$load
                                     }
                                 });
    
    Henning Leutz's avatar
    Henning Leutz committed
            },
    
            /**
             * event : on inject
             */
    
    Henning Leutz's avatar
    Henning Leutz committed
            $onInject: function () {
    
                this.Loader.show();
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
    Henning Leutz's avatar
    Henning Leutz committed
                QUIAjax.get([
    
                                'package_quiqqer_bricks_ajax_getBrick',
                                'package_quiqqer_bricks_ajax_getAvailableBricks'
                            ], function (brick, bricks) {
    
    Henning Leutz's avatar
    Henning Leutz committed
                    /**
                     * @param {{availableSettings:object}} data
                     * @param {{attributes:object}} data
                     * @param {{settings:object}} data
                     */
    
    Henning Leutz's avatar
    Henning Leutz committed
                    this.$availableBricks = bricks;
    
                    this.$availableSettings = brick.availableSettings;
    
                    this.$customfields = brick.customfields;
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
                    this.setAttribute('data', brick);
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
                    this.setAttributes({
    
                                           icon : 'fa fa-th',
                                           title: QUILocale.get('quiqqer/bricks', 'panel.title', {
                                               brickId   : this.getAttribute('id'),
                                               brickTitle: brick.attributes.title
                                           })
                                       });
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
                    this.refresh();
    
                    this.fireEvent('loaded', [this]);
                    this.getCategory('information').click();
    
                }.bind(this), {
    
                                'package': 'quiqqer/brick',
                                brickId  : this.getAttribute('id')
                            });
    
    Henning Leutz's avatar
    Henning Leutz committed
            },
    
            /**
             * event : on destroy
             */
    
    Henning Leutz's avatar
    Henning Leutz committed
            $onDestroy: function () {
    
                if (this.$Editor) {
    
    Henning Leutz's avatar
    Henning Leutz committed
                    this.$Editor.destroy();
                }
    
    
                if (this.$Areas) {
                    this.$Areas.destroy();
                }
    
    Henning Leutz's avatar
    Henning Leutz committed
            },
    
            /**
    
             * Saves the brick
    
    Henning Leutz's avatar
    Henning Leutz committed
             *
    
             * @return Promise
             */
    
    Henning Leutz's avatar
    Henning Leutz committed
            save: function (callback) {
    
                var Active = this.$Active;
    
                this.Loader.show();
                this.$unload();
    
    
    Michael's avatar
    Michael committed
                return this.$load(Active).then(function () {
    
    Michael's avatar
    Michael committed
                    return new Promise(function (resolve, reject) {
    
                        var data = this.getAttribute('data');
    
    
                        data.customfields = this.$customfields;
    
    Michael's avatar
    Michael committed
                        QUIAjax.post('package_quiqqer_bricks_ajax_brick_save', function () {
    
                            if (typeof callback === 'function') {
                                callback();
                            }
    
                            resolve();
    
    
    Michael's avatar
    Michael committed
                            QUI.getMessageHandler().then(function (MH) {
    
    Henning Leutz's avatar
    Henning Leutz committed
                                MH.addSuccess(
                                    QUILocale.get(lg, 'message.brick.save.success')
                                );
                            });
    
    
                            this.fireEvent('save', [this]);
                            this.Loader.hide();
    
                        }.bind(this), {
    
                                         'package': 'quiqqer/brick',
                                         brickId  : this.getAttribute('id'),
                                         data     : JSON.encode(data),
                                         onError  : reject
                                     });
    
    Henning Leutz's avatar
    Henning Leutz committed
            /**
             * Delete the brick
             */
    
    Henning Leutz's avatar
    Henning Leutz committed
            del: function () {
    
    Henning Leutz's avatar
    Henning Leutz committed
                var self = this;
    
                new QUIConfirm({
    
    Henning Leutz's avatar
    Henning Leutz committed
                    title      : QUILocale.get(lg, 'window.brick.delete.title'),
                    text       : QUILocale.get(lg, 'window.brick.delete.text'),
                    information: QUILocale.get(lg, 'window.brick.delete.information'),
                    maxHeight  : 300,
                    maxWidth   : 600,
                    autoclose  : false,
                    events     : {
                        onSubmit: function (Win) {
    
    Henning Leutz's avatar
    Henning Leutz committed
                            Win.Loader.show();
    
    
    Michael's avatar
    Michael committed
                            QUIAjax.post('package_quiqqer_bricks_ajax_brick_delete', function () {
    
    Henning Leutz's avatar
    Henning Leutz committed
                                Win.close();
    
                                self.fireEvent('delete');
                                self.destroy();
                            }, {
    
                                             'package': 'quiqqer/bricks',
                                             brickIds : JSON.encode([self.getAttribute('id')])
                                         });
    
    Henning Leutz's avatar
    Henning Leutz committed
                        }
                    }
                }).open();
            },
    
    
            /**
             * event on button active
             *
             * @param {Object} Button - qui/controls/buttons/Button
             *
             * @return Promise
    
    Henning Leutz's avatar
    Henning Leutz committed
             */
    
    Henning Leutz's avatar
    Henning Leutz committed
            $load: function (Button) {
    
                this.Loader.show();
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
    Michael's avatar
    Michael committed
                return new Promise(function (resolve, reject) {
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
                    var Prom = false,
                        self = this;
    
                    if (Button == this.$Active) {
                        reject();
                        self.Loader.hide();
                        return;
                    }
    
                    var data = this.getAttribute('data');
    
                    this.$unload();
    
                    this.setAttribute('data', data);
                    this.$Active = Button;
    
    
    Henning Leutz's avatar
    Henning Leutz committed
                    switch (Button.getAttribute('name')) {
    
                        case 'information':
                            Prom = this.$showInformation();
                            break;
    
                        case 'settings':
                            Prom = this.$showSettings();
                            break;
    
                        case 'extra':
                            Prom = this.$showExtras();
                            break;
    
                        case 'content':
                            Prom = this.$showContent();
                            break;
    
                        default:
                            reject();
                            return;
                    }
    
                    if (!Prom) {
                        reject();
                        self.Loader.hide();
                        return;
                    }
    
    Michael's avatar
    Michael committed
                    Prom.then(function () {
    
                        resolve();
                        self.Loader.hide();
    
    Michael's avatar
    Michael committed
                    }).catch(function () {
    
                        reject();
                        self.Loader.hide();
                    });
    
                }.bind(this));
            },
    
            /**
             * event unload category
             */
    
    Henning Leutz's avatar
    Henning Leutz committed
            $unload: function () {
    
                if (!this.$Active) {
                    return;
                }
    
                var Form   = this.getContent().getElement('form'),
                    unload = this.$Active.getAttribute('name'),
                    data   = this.getAttribute('data');
    
                if (unload == 'information') {
                    data.attributes = Object.merge(
                        data.attributes,
                        QUIFormUtils.getFormData(Form)
                    );
                }
    
    
                if (Form.getElement('[name="frontendTitle"]')) {
                    data.attributes.frontendTitle = Form.getElement('[name="frontendTitle"]').value;
                }
    
    
                if (unload == 'settings') {
    
    Henning Leutz's avatar
    Henning Leutz committed
                    data.attributes.areas = this.$Areas.getAreas().join(',');
    
    Henning Leutz's avatar
    Henning Leutz committed
                    //data.attributes.width   = Form.elements.width.value;
                    //data.attributes.height  = Form.elements.height.value;
                    //data.attributes.classes = Form.elements.classes.value;
    
    Henning Leutz's avatar
    Henning Leutz committed
                        fieldData    = QUIFormUtils.getFormData(Form);
    
    
                    for (var key in fieldData) {
    
                        if (!fieldData.hasOwnProperty(key)) {
                            continue;
                        }
    
                        if (!key.match('flexible')) {
                            continue;
                        }
    
                        if (fieldData[key]) {
                            flexibleList.push(key);
                        }
                    }
    
                    this.$customfields = flexibleList;
    
    
                    this.$Areas.destroy();
                    this.$Areas = false;
                }
    
                if (unload == 'extra') {
    
                    data.settings = Object.merge(
                        data.settings,
                        QUIFormUtils.getFormData(Form)
                    );
    
                }
    
                if (unload == 'content') {
                    data.attributes.content = this.$Editor.getContent();
    
                    this.$Editor.destroy();
                    this.$Editor = false;
                }
    
                this.$Active = null;
    
                this.setAttribute('data', data);
            },
    
            /**
             * Information template
             *
             * @returns {Promise}
             */
    
    Henning Leutz's avatar
    Henning Leutz committed
            $showInformation: function () {
    
    Michael's avatar
    Michael committed
                return new Promise(function (resolve, reject) {
    
    Michael's avatar
    Michael committed
                    Template.get('ajax/brick/templates/information', function (result) {
    
                        this.setContent(result);
    
                        QUIFormUtils.setDataToForm(
                            this.getAttribute('data').attributes,
                            this.getContent().getElement('form')
                        );
    
                        resolve();
    
                    }.bind(this), {
    
                                     'package': 'quiqqer/bricks',
                                     onError  : reject
                                 });
    
    
                }.bind(this));
            },
    
            /**
             * Settings template
             *
             * @returns {Promise}
             */
    
    Henning Leutz's avatar
    Henning Leutz committed
            $showSettings: function () {
    
    Michael's avatar
    Michael committed
                return new Promise(function (resolve, reject) {
    
    Michael's avatar
    Michael committed
                    Template.get('ajax/brick/templates/settings', function (result) {
    
                        this.setContent(result);
    
                        // areas
    
    Henning Leutz's avatar
    Henning Leutz committed
                        var Content      = this.getContent(),
                            areas        = [],
    
                            attributes   = this.getAttribute('data').attributes,
                            customfields = this.$customfields;
    
    Michael's avatar
    Michael committed
                        if (attributes.areas) {
    
                            areas = attributes.areas
    
    Henning Leutz's avatar
    Henning Leutz committed
                                .replace(/^,*/, '')
                                .replace(/,*$/, '')
                                .split(',');
    
                        }
    
                        // areas
                        this.$Areas = new BrickAreas({
    
    Henning Leutz's avatar
    Henning Leutz committed
                            brickId    : this.getAttribute('id'),
                            projectName: this.getAttribute('projectName'),
                            projectLang: this.getAttribute('projectLang'),
                            areas      : areas,
                            styles     : {
                                height: 120
    
                        }).inject(Content.getElement('.quiqqer-bricks-areas'));
    
    Henning Leutz's avatar
    Henning Leutz committed
                        //if ("width" in attributes) {
                        //    Content.getElement('[name="width"]').value = attributes.width;
                        //}
                        //
                        //if ("height" in attributes) {
                        //    Content.getElement('[name="height"]').value = attributes.height;
                        //}
                        //
                        //if ("classes" in attributes) {
                        //    Content.getElement('[name="classes"]').value = attributes.classes;
                        //}
    
                        // flexble settings
                        var i, len, data;
                        var TBody = Content.getElement('.brick-table-flexible tbody');
    
                        for (i = 0, len = this.$availableSettings.length; i < len; i++) {
    
                            data = this.$availableSettings[i];
    
                            new Element('tr', {
    
    Henning Leutz's avatar
    Henning Leutz committed
                                'class': i % 2 ? 'odd' : 'even',
                                html   : '<td>' +
                                         '<label>' +
                                         '<input type="checkbox" name="flexible-' + data.name + '" />' +
                                         '<span>' + QUILocale.get(data.text[0], data.text[1]) + '</span>' +
                                         '</label>' +
                                         '</td>'
    
                            }).inject(TBody);
                        }
    
                        if (customfields) {
    
                            var name;
                            var Form = Content.getElement('form');
    
                            for (i = 0, len = customfields.length; i < len; i++) {
    
                                name = customfields[i];
    
                                if (typeof Form.elements[name] !== 'undefined') {
                                    Form.elements[name].checked = true;
                                }
    
    
    Michael's avatar
    Michael committed
                                if (typeof Form.elements['flexible-' + name] !== 'undefined') {
                                    Form.elements['flexible-' + name].checked = true;
    
                    }.bind(this), {
    
                                     'package': 'quiqqer/bricks',
                                     onError  : reject
                                 });
    
    
                }.bind(this));
            },
    
            /**
             * Setting extras
             *
             * @returns {Promise}
             */
    
    Henning Leutz's avatar
    Henning Leutz committed
            $showExtras: function () {
    
    Michael's avatar
    Michael committed
                return new Promise(function (resolve, reject) {
    
    Michael's avatar
    Michael committed
                    Template.get('ajax/brick/templates/extras', function (result) {
    
                        this.setContent(result);
    
    
    Michael's avatar
    Michael committed
                        this.$createExtraData().then(function () {
    
                    }.bind(this), {
    
                                     'package': 'quiqqer/bricks',
                                     onError  : reject
                                 });
    
             * Setting content
    
    Henning Leutz's avatar
    Henning Leutz committed
             *
    
             * @returns {Promise}
    
    Henning Leutz's avatar
    Henning Leutz committed
             */
    
    Henning Leutz's avatar
    Henning Leutz committed
            $showContent: function () {
    
    Michael's avatar
    Michael committed
                return new Promise(function (resolve, reject) {
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
    Michael's avatar
    Michael committed
                    Template.get('ajax/brick/templates/content', function (result) {
    
                        this.setContent(result);
    
    Michael's avatar
    Michael committed
                        this.$createContentEditor().then(function () {
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
                    }.bind(this), {
    
                                     'package': 'quiqqer/bricks',
                                     onError  : reject
                                 });
    
                }.bind(this));
            },
    
            /**
             * Create the editor, if the brick type is a content type
             *
             * @param {Function} [callback]
             * @return Promise
             */
    
    Henning Leutz's avatar
    Henning Leutz committed
            $createContentEditor: function (callback) {
    
    Michael's avatar
    Michael committed
                return new Promise(function (resolve) {
    
    
                    var TableBody = this.$Elm.getElement('table.brick-edit-content tbody'),
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
    Henning Leutz's avatar
    Henning Leutz committed
                        TD        = new Element('td'),
                        TR        = new Element('tr', {
                            'class': 'odd'
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
                    TD.inject(TR);
                    TR.inject(TableBody);
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
                    var contenSize = this.getContent().getSize();
    
    Michael's avatar
    Michael committed
                    require(['classes/editor/Manager'], function (EditorManager) {
                        new EditorManager().getEditor(null, function (Editor) {
    
                            this.$Editor = Editor;
                            this.$Editor.setAttribute('showLoader', false);
    
                            var height = 300;
    
                            if ((contenSize.y - 100) > height) {
                                height = contenSize.y - 100;
                            }
    
    
    
                            var EditorContainer = new Element('div', {
    
    Henning Leutz's avatar
    Henning Leutz committed
                                styles: {
                                    clear  : 'both',
                                    'float': 'left',
                                    height : height,
                                    width  : '100%'
    
    Michael's avatar
    Michael committed
                            }).inject(TD);
    
    Michael's avatar
    Michael committed
                            this.$Editor.addEvent('onLoaded', function () {
    
                                if (typeof callback === 'function') {
    
    Michael's avatar
    Michael committed
                            this.$Editor.inject(EditorContainer);
                            this.$Editor.setHeight(EditorContainer.getSize().y);
                            this.$Editor.setWidth(EditorContainer.getSize().x);
    
                            this.$Editor.setContent(
                                this.getAttribute('data').attributes.content
                            );
    
                        }.bind(this));
                    }.bind(this));
    
    Henning Leutz's avatar
    Henning Leutz committed
            },
    
            /**
             * Create the extra settings table
    
    Henning Leutz's avatar
    Henning Leutz committed
             */
    
    Henning Leutz's avatar
    Henning Leutz committed
            $createExtraData: function () {
    
    Michael's avatar
    Michael committed
                return new Promise(function (resolve, reject) {
    
                    var TableExtra = this.$Elm.getElement('table.brick-edit-extra-header'),
                        TableBody  = TableExtra.getElement('tbody');
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
                    TableBody.getElement('[name="frontendTitle"]').value = this.getAttribute('data').attributes.frontendTitle;
    
    
    Michael's avatar
    Michael committed
                    if (!this.$availableSettings || !this.$availableSettings.length) {
    
                        TableExtra.setStyle('display', 'none');
    
    Henning Leutz's avatar
    Henning Leutz committed
                            html: QUILocale.get(lg, 'window.brick.no.extra.settings')
    
                        }).inject(TableExtra, 'before');
    
    
                    TableExtra.setStyle('display', null);
    
                    var Form = this.getContent().getElement('form');
    
                    var i, len, Row, text, Value, setting, extraFieldId;
    
                    var self = this,
                        id   = this.getId();
    
    Michael's avatar
    Michael committed
                    for (i = 0, len = this.$availableSettings.length; i < len; i++) {
    
                        setting = this.$availableSettings[i];
    
    Michael's avatar
    Michael committed
                        extraFieldId = 'extraField_' + id + '_' + i;
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
                        if (typeOf(setting.text) === 'array') {
    
    Henning Leutz's avatar
    Henning Leutz committed
                            text = QUILocale.get(setting.text[0], setting.text[1]);
    
                        Row = new Element('tr', {
    
                            'class': i % 2 ? 'odd' : 'even',
    
    Henning Leutz's avatar
    Henning Leutz committed
                            html   : '<td>' +
                                     '    <label class="quiqqer-bricks-areas" for="' + extraFieldId + '">' +
                                     text +
                                     '    </label>' +
                                     '</td>' +
                                     '<td></td>'
    
    Michael's avatar
    Michael committed
                        if (setting.type != 'select') {
    
                            Value = new Element('input', {
    
    Henning Leutz's avatar
    Henning Leutz committed
                                type   : setting.type,
                                name   : setting.name,
                                'class': setting.class,
                                id     : extraFieldId
    
                            }).inject(Row.getElement('td:last-child'));
    
                            if (setting['data-qui'] !== '') {
                                Value.set('data-qui', setting['data-qui']);
                            }
    
                            continue;
                        }
    
                        Value = new Element('select', {
    
    Henning Leutz's avatar
    Henning Leutz committed
                            name   : setting.name,
                            'class': setting.class,
                            id     : extraFieldId
    
                        }).inject(Row.getElement('td:last-child'));
    
    Michael's avatar
    Michael committed
                        for (var c = 0, clen = setting.options.length; c < clen; c++) {
    
                            text = setting.options[c].text;
    
                            if (typeOf(setting.options[c].text) === 'array') {
                                text = QUILocale.get(
    
    Henning Leutz's avatar
    Henning Leutz committed
                                    setting.options[c].text[0],
                                    setting.options[c].text[1]
    
    Henning Leutz's avatar
    Henning Leutz committed
                                html : text,
                                value: setting.options[c].value
    
    Henning Leutz's avatar
    Henning Leutz committed
                        }
    
                    TableExtra.setStyle('display', null);
    
                    QUIFormUtils.setDataToForm(
                        this.getAttribute('data').settings,
                        Form
                    );
    
    Michael's avatar
    Michael committed
                    QUI.parse(TableExtra).then(function () {
    
                        return ControlUtils.parse(TableExtra);
    
    
    Michael's avatar
    Michael committed
                    }).then(function () {
    
                        // set project to the controls
    
    Michael's avatar
    Michael committed
                        TableExtra.getElements('[data-quiid]').each(function (Elm) {
    
                            var Control = QUI.Controls.getById(
                                Elm.get('data-quiid')
                            );
    
    
    Michael's avatar
    Michael committed
                            if ('setProject' in Control) {
    
                                    self.getAttribute('projectName'),
                                    self.getAttribute('projectLang')
    
    Henning Leutz's avatar
    Henning Leutz committed
            }
        });
    });