All files / web/bundles/pimdatagrid/js/datagrid/cell enabled-cell.js

100% Statements 10/10
100% Branches 6/6
100% Functions 2/2
100% Lines 10/10

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  330x                                   330x             7409x   2852x   2852x     4557x 4557x 4557x       4557x   4557x          
/* global define */
define(
    [
        'oro/datagrid/string-cell',
        'oro/translator',
        'pim/template/datagrid/cell/enabled-cell'
    ],
    function(
        StringCell,
        __,
        template
    ) {
        'use strict';
 
        /**
         * Enabled column cell
         *
         * @extends oro.datagrid.StringCell
         */
        return StringCell.extend({
            template: _.template(template),
 
            /**
             * {@inheritdoc}
             */
            render: function () {
                if ('product_model' === this.model.get('document_type')) {
                    // PIM-6493: the value should be calculated depending on the the model subtree.
                    this.$el.empty().html('');
 
                    return this;
                }
 
                const value = this.formatter.fromRaw(this.model.get(this.column.get("name")));
                const enabled = true === value ? 'enabled' : 'disabled';
                const label = true === value ?
                    __('pim_enrich.entity.product.module.status.enabled') :
                    __('pim_enrich.entity.product.module.status.disabled');
 
                this.$el.empty().html(this.template({ enabled, label }));
 
                return this;
            }
        });
    }
);