Skip to content

Commit

Permalink
Source Entity expansion with Pickup Location attributes #2182.
Browse files Browse the repository at this point in the history
Show/Hide the pickup location fieldset depending from `is_pickup_location_active` value
  • Loading branch information
novikor committed May 18, 2019
1 parent 748fd78 commit 0c974ba
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@
</formElements>
</field>
</fieldset>
<fieldset name="pickup_location" sortOrder="100">
<fieldset name="pickup_location" sortOrder="100" component="Magento_InventoryInStorePickupAdminUi/js/form/components/fieldset">
<settings>
<collapsible>true</collapsible>
<label translate="true">Pickup Location</label>
<dataScope>general</dataScope>
<imports>
<link name="visible">${ $.provider }:data.general.extension_attributes.is_pickup_location_active</link>
</imports>
</settings>
<field name="frontend_name">
<settings>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'Magento_Ui/js/form/components/fieldset',
'ko'
], function (Fieldset, ko) {
'use strict';

return Fieldset.extend(ko).extend(
{
/**
* Convert visible value from string ('1', '0') to bool (true, false)
*/
initialize: function () {
this._super();

let visible = ko.observable(this.visible());

this.visible = ko.computed({
read: function () {
return visible();
},
write: function (value) {
visible(Boolean(parseInt(value)));
},
owner: this
});
this.visible(visible());
}
}
);
});

0 comments on commit 0c974ba

Please sign in to comment.