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

100% Statements 8/8
100% Branches 0/0
100% Functions 3/3
100% Lines 8/8

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 52 53 54 55 56 57 58 59 60 61                    5x                             5x                   9x         9x   9x                     9x 9x 9x          
'use strict';
 
/**
 * Module to display a line in the Select2 dropdown of the Datagrid View Selector.
 * This module accepts extensions to display more info beside the view.
 *
 * @author    Adrien Petremann <adrien.petremann@akeneo.com>
 * @copyright 2016 Akeneo SAS (http://www.akeneo.com)
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
define(
    [
        'jquery',
        'underscore',
        'backbone',
        'pim/form',
        'pim/template/grid/view-selector/line'
    ],
    function (
        $,
        _,
        Backbone,
        BaseForm,
        template
    ) {
        return BaseForm.extend({
            template: _.template(template),
            datagridView: null,
            datagridViewType: null,
            currentViewId: null,
 
            /**
             * {@inheritdoc}
             */
            render: function () {
                this.$el.html(this.template({
                    view: this.datagridView,
                    isCurrent: (this.currentViewId === this.datagridView.id)
                }));
 
                this.renderExtensions();
 
                return this;
            },
 
            /**
             * Set the view of this module.
             *
             * @param {Object}  view
             * @param {String}  viewType
             * @param {int}     currentViewId
             */
            setView: function (view, viewType, currentViewId) {
                this.datagridView = view;
                this.datagridViewType = viewType;
                this.currentViewId = currentViewId;
            }
        });
    }
);