All files / web/bundles/pimui/js/family/mass-edit form-model-updater.js

100% Statements 10/10
100% Branches 0/0
100% Functions 3/3
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                  6x             6x         6x 6x   6x             18x 18x 18x   18x   18x          
'use strict';
 
/**
 * Mass edit attribute requirements
 *
 * @author    Alexandr Jeliuc <alex@jeliuc.com>
 * @copyright 2017 Akeneo SAS (http://www.akeneo.com)
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 */
define(
    [
        'underscore',
        'jquery',
        'pim/form'
    ],
    function (_, $, BaseForm) {
        return BaseForm.extend({
            /**
             * {@inheritdoc}
             */
            configure: function () {
                this.listenTo(this.getRoot(), 'pim_enrich:form:entity:update_state', this.triggerModelUpdate);
                this.listenTo(this.getRoot(), 'pim_enrich:form:entity:post_update', this.triggerModelUpdate);
 
                return BaseForm.prototype.configure.apply(this, arguments);
            },
 
            /**
             * Update the root model after fake product save
             */
            triggerModelUpdate: function () {
                var data = this.getFormData();
                data.attributes = _.pluck(data.attributes, 'code');
                delete data.meta;
 
                this.getRoot().trigger('pim_enrich:mass_edit:model_updated', data);
 
                return this;
            }
        });
    }
);