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

100% Statements 7/7
100% Branches 0/0
100% Functions 2/2
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 52  322x                                           322x             7890x   7890x 7890x   7890x                     4784x          
/* global define */
define(
    [
        'underscore',
        'oro/datagrid/string-cell',
        'pim/media-url-generator',
        'pim/template/datagrid/cell/image-cell'
    ],
    function (
        _,
        StringCell,
        MediaUrlGenerator,
        template
    ) {
        'use strict';
 
        /**
         * Image column cell
         *
         * @export  oro/datagrid/image-cell
         * @class   oro.datagrid.ImageCell
         * @extends oro.datagrid.StringCell
         */
        return StringCell.extend({
            template: _.template(template),
 
            /**
             * Render an image.
             */
            render: function () {
                const image = this.formatter.fromRaw(this.model.get(this.column.get("name")));
 
                const src = MediaUrlGenerator.getMediaShowUrl(image.filePath, 'thumbnail_small');
                this.$el.empty().html(this.getTemplate({label: image.originalFilename, src}));
 
                return this;
            },
 
            /**
             * Returns the template used to show the image.
             *
             * This function can be overridden to alter the way the image is shown.
             *
             * @returns {string}
             */
            getTemplate(params) {
                return this.template(params);
            }
        });
    }
);