Commit cbc60301 authored by Damian Kryger's avatar Damian Kryger
Browse files

Merge branch '781-destination-attribute-filtering' into 'master'

#781 Destination attribute filtering

See merge request !609
parents 71ac14a9 e4d3c2cc
Pipeline #264518565 passed with stages
in 24 minutes and 39 seconds
......@@ -16,7 +16,6 @@ define(['jquery', 'underscore', 'pim/base-fetcher', 'routing'], function($, _, B
searchOptions[option] = options[option];
}
});
console.log(searchOptions);
return this.search(searchOptions);
},
......
......@@ -111,22 +111,44 @@ define(
this.render();
},
render: function () {
let rows = [];
_.each(this.mappingValues, function(element) {
rows.push(this.renderRow(element));
}.bind(this));
this.$el.html(this.template({
rowCount : this.rowCount,
rowTemplate: this.rowTemplate,
mappingValues: this.mappingValues,
sourceAttributeList: this.sourceAttributeList,
destinationAttributeList: this.destinationAttributeList,
i18n: i18n,
locale: UserContext.get('catalogLocale'),
rows: rows,
error: this.getParent().getValidationErrorsForField(this.getFieldCode()),
}));
this.$('.select2').select2();
this.delegateEvents();
return this;
},
renderRow: function(element) {
let sourceAttribute = this.getSourceAttribute(element.sourceValue);
// show only those matching the type of source attribute
let destinationAttributeList = sourceAttribute ?
_.filter(this.destinationAttributeList, function(attr) {
return attr.type === sourceAttribute.type;
}) :
[];
return this.rowTemplate({
element: element,
sourceAttributeList: this.sourceAttributeList,
destinationAttributeList: destinationAttributeList,
i18n: i18n,
locale: UserContext.get('catalogLocale'),
});
},
getSourceAttribute: function(code) {
return _.find(this.sourceAttributeList, function(attr) {
return attr.code === code;
});
},
updateModelAfterChange: function (event) {
this.updateModelValue(parseInt(event.target.dataset.index), event.target.name, event.target.value);
this.render();
},
updateModelValue: function (index, type, value) {
let mappingValue = _.find(this.mappingValues, function(element) {
......
......@@ -7,14 +7,8 @@
<table class="AknGrid">
<tbody class="AknGrid-body">
<% _.each(mappingValues, function(element) { %>
<%= rowTemplate({
element: element,
sourceAttributeList: sourceAttributeList,
destinationAttributeList: destinationAttributeList,
i18n: i18n,
locale: locale
}) %>
<% _.each(rows, function(row) { %>
<%= row %>
<% }); %>
</tbody>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment