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

94.12% Statements 16/17
90% Branches 9/10
100% Functions 2/2
94.12% Lines 16/17

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  330x                 330x         8135x 3106x   3106x     5029x   5029x 5029x 4001x 4001x 2058x 1943x     1943x     4001x     5029x   5029x          
/* global define */
define(['oro/datagrid/string-cell', 'oro/translator'],
    function(StringCell, __) {
        'use strict';
 
        /**
         * Completeness column cell
         *
         * @extends oro.datagrid.StringCell
         */
        return StringCell.extend({
            /**
             * Render the completeness.
             */
            render: function () {
                if ('product_model' === this.model.get('document_type')) {
                    this.$el.empty().html(__('pim_common.not_available'));
 
                    return this;
                }
 
                var ratio = this.formatter.fromRaw(this.model.get(this.column.get('name')));
 
                var completeness = '-';
                if (null !== ratio && '' !== ratio) {
                    var cssClass = '';
                    if (100 === ratio) {
                        cssClass+= 'success';
                    } else Iif (0 === ratio) {
                        cssClass+= 'important';
                    } else {
                        cssClass+= 'warning';
                    }
 
                    completeness = '<span class="AknBadge AknBadge--'+ cssClass +'">'+ ratio +'%</span>';
                }
 
                this.$el.empty().html(completeness);
 
                return this;
            }
        });
    }
);