All files / web/bundles/pimui/js/product/form download-pdf.js

90% Statements 9/10
50% Branches 1/2
100% Functions 3/3
90% Lines 9/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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65                  265x                             265x                     322x 322x   322x             393x       393x 393x                 393x          
'use strict';
/**
 * Download pdf extension
 *
 * @author    Julien Sanchez <julien@akeneo.com>
 * @author    Filips Alpe <filips@akeneo.com>
 * @copyright 2015 Akeneo SAS (http://www.akeneo.com)
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
define(
    [
        'underscore',
        'pim/form',
        'pim/template/product/download-pdf',
        'routing',
        'pim/user-context'
    ],
    function (
        _,
        BaseForm,
        template,
        Routing,
        UserContext
    ) {
        return BaseForm.extend({
            tagName: 'a',
 
            className: 'AknDropdown-menuLink btn-download',
 
            template: _.template(template),
 
            /**
             * {@inheritdoc}
             */
            configure: function () {
                UserContext.off('change:catalogLocale change:catalogScope', this.render);
                this.listenTo(UserContext, 'change:catalogLocale change:catalogScope', this.render);
 
                return BaseForm.prototype.configure.apply(this, arguments);
            },
 
            /**
             * {@inheritdoc}
             */
            render: function () {
                Iif (!this.getFormData().meta) {
                    return;
                }
 
                this.$el.html(this.template());
                this.$el.attr('href', Routing.generate(
                    'pim_pdf_generator_download_product_pdf',
                    {
                        id:         this.getFormData().meta.id,
                        dataLocale: UserContext.get('catalogLocale'),
                        dataScope:  UserContext.get('catalogScope')
                    }
                ));
 
                return this;
            }
        });
    }
);