Skip to content

Commit

Permalink
Merge pull request magento#945 from magento-engcom/MSI-896
Browse files Browse the repository at this point in the history
MSI-896: Disabled "Advanced Inventory" button.
  • Loading branch information
Valeriy Nayda authored May 3, 2018
2 parents 347df97 + a7204ab commit 46a2be5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
-->
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="sources" sortOrder="5" component="Magento_InventoryCatalogAdminUi/js/product/form/source-items">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="advancedInventoryButtonIndex" xsi:type="string">advanced_inventory_button</item>
</item>
</argument>
<settings>
<label translate="true">Sources</label>
<collapsible>true</collapsible>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
*/

define([
'Magento_Ui/js/form/components/fieldset'
], function (Fieldset) {
'Magento_Ui/js/form/components/fieldset',
'uiRegistry',
'underscore'
], function (Fieldset, registry, _) {
'use strict';

return Fieldset.extend({
defaults: {
advancedInventoryButtonIndex: '',
imports: {
onStockChange: '${ $.provider }:data.product.stock_data.manage_stock'
}
Expand All @@ -20,8 +23,16 @@ define([
* @param {Integer} canManageStock
*/
onStockChange: function (canManageStock) {
var advancedInventoryButton = registry.get('index = ' + this.advancedInventoryButtonIndex);

if (canManageStock === 0) {
this.delegate('disabled', true);
// "Advanced Inventory" button should stay active in any case.
if (!_.isUndefined(advancedInventoryButton)) {
advancedInventoryButton.disabled(false);
}
} else {
this.delegate('disabled', false);
}
}
});
Expand Down

0 comments on commit 46a2be5

Please sign in to comment.