All files / web/bundles/pimui/js/product/grid view-selector.js

100% Statements 7/7
50% Branches 1/2
100% Functions 3/3
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51              299x                         299x                   497x   497x             497x     496x 495x              
 /**
 * Parent extension to render the child extensions for the view selector in the product grid index
 *
 * @author    Tamara Robichet <tamara.robichet@akeneo.com>
 * @copyright 2017 Akeneo SAS (http://www.akeneo.com)
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
define(
    [
        'underscore',
        'jquery',
        'pim/form-builder',
        'pim/form'
    ],
    function(
        _,
        $,
        FormBuilder,
        BaseForm
    ) {
        return BaseForm.extend({
            className: 'view-selector',
            config: {
                gridName: 'product-grid'
            },
 
            /**
             * {@inheritdoc}
             */
            initialize(options) {
                this.config = Object.assign(this.config, options.config || {});
 
                return BaseForm.prototype.initialize.apply(this, arguments);
            },
 
            /**
             * {@inheritdoc}
             */
            render() {
                FormBuilder.getFormMeta('pim-grid-view-selector')
                    .then(FormBuilder.buildForm)
                    .then(form => {
                        return form.configure(this.config.gridName).then(() => {
                            form.setElement('.view-selector').render();
                        });
                    });
            }
        });
    }
);