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

87.5% Statements 7/8
75% Branches 3/4
100% Functions 2/2
87.5% Lines 7/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  3x                 3x               2x 2x   2x       2x                 2x          
/* global define */
define(['oro/datagrid/string-cell', 'underscore', 'oro/translator', 'pim/template/datagrid/cell/credentials-cell'],
    function (StringCell, _, __, CredentialsTemplate) {
        'use strict';
 
        /**
         * Credentials column cell
         *
         * @extends oro.datagrid.StringCell
         */
        return StringCell.extend({
            className: 'AknGrid-bodyCell AknGrid-bodyCell--credentials',
 
            template: _.template(CredentialsTemplate),
            /**
             * Render the API credentials.
             */
            render: function () {
                var value = this.formatter.fromRaw(this.model.get(this.column.get("name")));
                var credentials = _.object(['public_id', 'secret'], value.split('|'));
 
                Iif (null === credentials || '' === credentials) {
                    return this;
                }
 
                this.$el.empty().html(
                    this.template({
                        clientIdLabel: __('pim_datagrid.cells.credientials.client_id'),
                        secretLabel: __('pim_datagrid.cells.credientials.secret'),
                        publicId: credentials.public_id,
                        secret: credentials.secret
                    })
                );
 
                return this;
            }
        });
    }
);