Skip to content

Commit

Permalink
MAGETWO-90285: 8830: Can`t delete row in dynamicRows component #921
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaVasyltsun committed May 7, 2018
1 parent 98e4a6e commit 6a11839
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ private function customizeAddAttributeModal(array $meta)
. '.create_new_attribute_modal',
'actionName' => 'toggleModal',
],
[
'targetName' => 'product_form.product_form.add_attribute_modal'
. '.create_new_attribute_modal.product_attribute_add_form',
'actionName' => 'destroyInserted'
],
[
'targetName'
=> 'product_form.product_form.add_attribute_modal'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@
<item name="isTemplate" xsi:type="boolean">true</item>
<item name="is_collection" xsi:type="boolean">true</item>
<item name="componentType" xsi:type="string">container</item>
<item name="positionProvider" xsi:type="string">attribute_options.position</item>
</item>
</argument>
<field name="is_default" component="Magento_Catalog/js/form/element/checkbox" sortOrder="0" formElement="checkbox">
Expand Down Expand Up @@ -189,12 +188,8 @@
</item>
</argument>
<settings>
<additionalClasses>
<class name="_hidden">true</class>
</additionalClasses>
<dataType>text</dataType>
<visible>false</visible>
<dataScope>position</dataScope>
</settings>
</field>
</container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,16 @@ define([
if (!_.isEmpty(this.suffixName) || _.isNumber(this.suffixName)) {
suffixName = '.' + this.suffixName;
}
this.dataScope = 'data.' + this.prefixName + '.' + this.elementName + suffixName;

this.links.value = this.provider + ':' + this.dataScope;
this.exportDataLink = 'data.' + this.prefixName + '.' + this.elementName + suffixName;
this.exports.value = this.provider + ':' + this.exportDataLink;
},

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

this.source.remove(this.exportDataLink);
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<button class="action-delete"
attr="{'data-action': 'remove_row'}"
data-bind="
click: function(){ $data.processingDeleteRecord($parents); },
click: function(){ $parent.processingDeleteRecord($record().index, $record.recordId); },
attr: {
title: $parent.deleteButtonLabel
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
<additionalClasses>
<class name="admin__field-wide">true</class>
</additionalClasses>
<dataScope>text_swatch</dataScope>
<componentType>dynamicRows</componentType>
</settings>
<container name="record" component="Magento_Ui/js/dynamic-rows/record">
Expand All @@ -96,8 +95,6 @@
<item name="isTemplate" xsi:type="boolean">true</item>
<item name="is_collection" xsi:type="boolean">true</item>
<item name="componentType" xsi:type="string">container</item>
<item name="positionProvider" xsi:type="string">text_swatch.position</item>
<item name="dataScope" xsi:type="string"/>
</item>
</argument>
<field name="defaulttext" component="Magento_Catalog/js/form/element/checkbox" sortOrder="0" formElement="checkbox">
Expand Down Expand Up @@ -183,15 +180,11 @@
</item>
</argument>
<settings>
<additionalClasses>
<class name="_hidden">true</class>
</additionalClasses>
<dataType>text</dataType>
<visible>false</visible>
<dataScope>position</dataScope>
</settings>
</field>
<actionDelete name="action_delete" component="Magento_Catalog/js/form/element/action-delete" template="Magento_Catalog/form/element/action-delete">
<actionDelete name="action_delete">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="fit" xsi:type="boolean">true</item>
Expand Down Expand Up @@ -227,7 +220,6 @@
<class name="swatch-visual-options-container">true</class>
<class name="admin__field-wide">true</class>
</additionalClasses>
<dataScope>visual_swatch</dataScope>
<componentType>dynamicRows</componentType>
</settings>
<container name="record" component="Magento_Ui/js/dynamic-rows/record">
Expand All @@ -236,8 +228,6 @@
<item name="isTemplate" xsi:type="boolean">true</item>
<item name="is_collection" xsi:type="boolean">true</item>
<item name="componentType" xsi:type="string">container</item>
<item name="positionProvider" xsi:type="string">text_swatch.position</item>
<item name="dataScope" xsi:type="string"/>
</item>
</argument>
<field name="defaultvisual" component="Magento_Catalog/js/form/element/checkbox" sortOrder="0" formElement="checkbox">
Expand Down Expand Up @@ -276,7 +266,6 @@
<class name="swatches-visual-col">true</class>
</additionalClasses>
<label translate="true">Swatch</label>
<dataScope>swatchvisual</dataScope>
</settings>
</field>
<field name="optionvisual_default_store_view" component="Magento_Catalog/js/form/element/input" template="Magento_Catalog/form/element/input" formElement="input">
Expand All @@ -290,7 +279,6 @@
<settings>
<dataType>text</dataType>
<label translate="true">Default Store View</label>
<dataScope>optionvisual_default_store_view</dataScope>
</settings>
</field>
<field name="optionvisual_admin" component="Magento_Catalog/js/form/element/input" template="Magento_Catalog/form/element/input" formElement="input">
Expand All @@ -304,7 +292,6 @@
<settings>
<dataType>text</dataType>
<label translate="true">Admin</label>
<dataScope>optionvisual_admin</dataScope>
</settings>
</field>
<field name="position" component="Magento_Catalog/js/form/element/input" formElement="input">
Expand All @@ -315,15 +302,10 @@
</item>
</argument>
<settings>
<additionalClasses>
<class name="_hidden">true</class>
</additionalClasses>
<dataType>text</dataType>
<visible>false</visible>
<dataScope>position</dataScope>
<visible>false</visible>
</settings>
</field>
<actionDelete name="action_delete" component="Magento_Catalog/js/form/element/action-delete" template="Magento_Catalog/form/element/action-delete">
<actionDelete name="action_delete">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="fit" xsi:type="boolean">true</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,18 +305,30 @@ define([
*/
initialize: function () {
this._super()
.initOldCode();
.initOldCode()
.on('value', this.onChangeColor.bind(this));

return this;
},

/**
* Handler function that execute when color changes.
*
* @param {String} data - color
*/
onChangeColor: function (data) {
if (!data) {
jQuery('.' + this.elementName).parent().removeClass('unavailable');
}
},

/**
* Initialize wrapped former implementation.
*
* @returns {Object} Chainable.
*/
initOldCode: function () {
jQuery.async('.' + this.elementName, function (elem) {
jQuery.async('.' + this.elementName, this.name, function (elem) {
oldCode(this.value(), elem.parentElement, this.uploadUrl, this.elementName);
}.bind(this));

Expand All @@ -336,9 +348,15 @@ define([
this.elementName = this.prefixElementName + recordId;

this.inputName = prefixName + '[' + this.elementName + ']';
this.dataScope = 'data.' + this.prefixName + '.' + this.elementName;
this.exportDataLink = 'data.' + this.prefixName + '.' + this.elementName;
this.exports.value = this.provider + ':' + this.exportDataLink;
},

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

this.links.value = this.provider + ':' + this.dataScope;
this.source.remove(this.exportDataLink);
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
value: value
"/>
<div data-bind="attr: {class: 'swatch_window ' + elementName}"></div>
<div attr="class: 'swatch_window ' + elementName" ko-style="backgroundColor: $data.value"></div>
<div class="swatch_sub-menu_container">
<div class="swatch_row position-relative">
<div class="swatch_row_name colorpicker_handler">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,14 @@ define([
return this;
},

/** @inheritdoc */
destroy: function () {
if (this.dnd()) {
this.dnd().destroy();
}
this._super();
},

/**
* Calls 'initObservable' of parent
*
Expand Down

0 comments on commit 6a11839

Please sign in to comment.