From 290757e8fe6f304091d0b49f8226f425a62581ce Mon Sep 17 00:00:00 2001 From: Maksym Novik Date: Sat, 18 May 2019 21:20:07 +0300 Subject: [PATCH] Source Entity expansion with Pickup Location attributes #2182. Show/Hide the pickup location fieldset depending from `is_pickup_location_active` value --- .../ui_component/inventory_source_form.xml | 5 ++- .../web/js/form/components/fieldset.js | 38 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 InventoryInStorePickupAdminUi/view/adminhtml/web/js/form/components/fieldset.js diff --git a/InventoryInStorePickupAdminUi/view/adminhtml/ui_component/inventory_source_form.xml b/InventoryInStorePickupAdminUi/view/adminhtml/ui_component/inventory_source_form.xml index 22429152d806..cb45a1b99cc1 100644 --- a/InventoryInStorePickupAdminUi/view/adminhtml/ui_component/inventory_source_form.xml +++ b/InventoryInStorePickupAdminUi/view/adminhtml/ui_component/inventory_source_form.xml @@ -31,11 +31,14 @@ -
+
true general + + ${ $.provider }:data.general.extension_attributes.is_pickup_location_active + diff --git a/InventoryInStorePickupAdminUi/view/adminhtml/web/js/form/components/fieldset.js b/InventoryInStorePickupAdminUi/view/adminhtml/web/js/form/components/fieldset.js new file mode 100644 index 000000000000..3d1a4ec3f824 --- /dev/null +++ b/InventoryInStorePickupAdminUi/view/adminhtml/web/js/form/components/fieldset.js @@ -0,0 +1,38 @@ +/* + * 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'; + + /** + * @TODO Remove when issue will be resolved in core. + * @see Please check issue in core for more details: https://github.com/magento/magento2/issues/22067. + */ + 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()); + } + } + ); +});