Skip to content

Commit

Permalink
MAGETWO-52775: [Github] Updating products with Multiple Select Attrib…
Browse files Browse the repository at this point in the history
…ute #4346 #4312
  • Loading branch information
Yurii Hryhoriev committed May 18, 2016
1 parent 36be09e commit ce3223e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 26 deletions.
3 changes: 2 additions & 1 deletion app/code/Magento/Catalog/Ui/Component/ColumnFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ColumnFactory
protected $jsComponentMap = [
'text' => 'Magento_Ui/js/grid/columns/column',
'select' => 'Magento_Ui/js/grid/columns/select',
'multiselect' => 'Magento_Ui/js/grid/columns/select',
'date' => 'Magento_Ui/js/grid/columns/date',
];

Expand All @@ -29,7 +30,7 @@ class ColumnFactory
'text' => 'text',
'boolean' => 'select',
'select' => 'select',
'multiselect' => 'select',
'multiselect' => 'multiselect',
'date' => 'date',
];

Expand Down
7 changes: 6 additions & 1 deletion app/code/Magento/Ui/Component/Filters/Type/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,14 @@ protected function applyFilter()
{
if (isset($this->filterData[$this->getName()])) {
$value = $this->filterData[$this->getName()];
$conditionType = is_array($value) ? 'in' : 'eq';

if (!empty($value) || is_numeric($value)) {
if (is_array($value)) {
$conditionType = 'in';
} else {
$dataType = $this->getData('config/dataType');
$conditionType = $dataType == 'multiselect' ? 'finset' : 'eq';
}
$filter = $this->filterBuilder->setConditionType($conditionType)
->setField($this->getName())
->setValue($value)
Expand Down
29 changes: 5 additions & 24 deletions app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,6 @@ define([
elementTmpl: 'ui/form/element/multiselect'
},

/**
* @inheritdoc
*/
initConfig: function () {
this._super();

this.value = this.normalizeData(this.value);

return this;
},

/**
* @inheritdoc
*/
initLinks: function () {
var scope = this.source.get(this.dataScope);

this.multipleScopeValue = _.isArray(scope) ? utils.copy(scope) : undefined;

return this._super();
},

/**
* @inheritdoc
*/
Expand All @@ -64,11 +42,14 @@ define([
* @inheritdoc
*/
getInitialValue: function () {
var values = [this.multipleScopeValue, this.default, this.value.peek(), []],
var values = [
this.normalizeData(this.source.get(this.dataScope)),
this.normalizeData(this.default)
],
value;

values.some(function (v) {
return _.isArray(v) && (value = utils.copy(v));
return _.isArray(v) && (value = utils.copy(v)) && !_.isEmpty(v);
});

return value;
Expand Down
4 changes: 4 additions & 0 deletions app/code/Magento/Ui/view/base/web/js/grid/columns/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ define([
values = this._super(),
label = [];

if (_.isString(values)) {
values = values.split(',');
}

if (!Array.isArray(values)) {
values = [values];
}
Expand Down

0 comments on commit ce3223e

Please sign in to comment.