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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | 89x 89x 220x 220x 20x 20x 20x 1694x 46x 46x 20x 20x 4x 4x 4x 4x 4x | 'use strict';
/**
* Allow to search a product with family variant in order to update it
*
* @author Pierre Allard <pierre.allard@akeneo.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(
[
'jquery',
'underscore',
'oro/translator',
'oro/messenger',
'pim/mass-edit-form/product/operation',
'pim/common/property',
'pim/template/mass-edit/product/update-entity-with-family-variant-parent'
],
function (
$,
_,
__,
messenger,
BaseOperation,
propertyAccessor,
template
) {
return BaseOperation.extend({
template: _.template(template),
events: {
},
/**
* {@inheritdoc}
*/
configure: function () {
this.listenTo(this.getRoot(), 'pim_enrich:form:entity:post_update', this.updateModel);
return BaseOperation.prototype.configure.apply(this, arguments);
},
/**
* {@inheritdoc}
*/
render: function () {
this.$el.html(this.template({
value: this.getValue(),
readOnly: this.readOnly
}));
BaseOperation.prototype.render.apply(this, arguments);
return this;
},
/**
* Updates the model to store action
*
* @param {Object} formData
*/
updateModel: function (formData) {
if (this.getParent().getCurrentOperation() === this.getCode()) {
formData.actions = [{
field: 'productModelCode',
value: formData.product_model
}];
this.setData(formData, {silent: true});
}
},
/**
* {@inheritdoc}
*/
getValue: function () {
const action = _.findWhere(this.getFormData().actions, { field: 'productModelCode' });
return action ? action.value : null;
},
/**
* Checks there is one product model selected to go to the next step
*/
validate: function () {
const data = this.getFormData();
const productModelCode = propertyAccessor.accessProperty(data, 'actions.0.value', null);
const hasUpdate = null !== productModelCode;
Iif (!hasUpdate) {
messenger.notify(
'error',
__('pim_enrich.mass_edit.product.operation.add_to_existing_product_model.no_update')
);
}
return $.Deferred().resolve(hasUpdate);
}
});
}
);
|