@bigbinary/neeto-fields-frontend 1.3.18 → 1.3.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -204,8 +204,8 @@ default, but you can customize its behavior by passing optional props.
204
204
  12. `headerTitle`: Specify the header title explicitly. Default is 'fields'
205
205
  13. `resources`: For owner-based field categorization, provide an array of
206
206
  objects with `id` and `name` properties for each owner. For resource
207
- type-based categorization, use an array of strings representing resource
208
- types.
207
+ type-based categorization, use an array of objects with `label` and `value`
208
+ properties representing each resource types.
209
209
 
210
210
  > If no resources are provided, for resource type-based categorization, the
211
211
  > menu bar will fetch all resource types. For owner-based categorization, it
@@ -491,7 +491,7 @@ the following props:
491
491
  3. `resourceType`: The type of resource.
492
492
  4. `resourceId`: The ID of the resource.
493
493
  5. `ownerId`: The ID of the owner in case the owner is not an organization.
494
- 6. `onMutate`: The callback function which is triggered on the mutations
494
+ 6. `onMutate`: The callback function which is triggered on the mutations
495
495
  7. `onMutationSuccess`: The callback function which is triggered on the success
496
496
  of mutation functions of field value.
497
497
 
package/dist/index.cjs.js CHANGED
@@ -10,9 +10,9 @@ var ramda = require('ramda');
10
10
  var formik = require('formik');
11
11
  var i18next = require('i18next');
12
12
  var yup = require('yup');
13
+ var formik$1 = require('@bigbinary/neetoui/formik');
13
14
  var utils = require('@bigbinary/neeto-commons-frontend/utils');
14
15
  var neetoIcons = require('@bigbinary/neeto-icons');
15
- var formik$1 = require('@bigbinary/neetoui/formik');
16
16
  var reactI18next = require('react-i18next');
17
17
  var constants = require('@bigbinary/neeto-commons-frontend/constants');
18
18
  var Container = require('@bigbinary/neeto-molecules/Container');
@@ -993,7 +993,7 @@ var MultiOption = function MultiOption(props) {
993
993
  var _useFormikFields = useFormikFields(props),
994
994
  handleSubmit = _useFormikFields.handleSubmit,
995
995
  fieldProps = _useFormikFields.fieldProps;
996
- return /*#__PURE__*/React__default["default"].createElement(neetoui.Select, _extends({
996
+ return /*#__PURE__*/React__default["default"].createElement(formik$1.Select, _extends({
997
997
  isMulti: true,
998
998
  isSearchable: true,
999
999
  strategy: "fixed"
@@ -2542,29 +2542,31 @@ var renderMenuBarItems = function renderMenuBarItems(_ref3) {
2542
2542
  });
2543
2543
  });
2544
2544
  }
2545
- return items.length > 1 && items.map(function (item) {
2546
- var label = nameAliases[item] || neetoCist.humanize(item);
2545
+ return items.length > 1 && items.map(function (_ref4) {
2546
+ var label = _ref4.label,
2547
+ value = _ref4.value;
2548
+ var itemLabel = nameAliases[label] || neetoCist.humanize(label);
2547
2549
  return /*#__PURE__*/React__default["default"].createElement(MenuBar__default["default"].Item, {
2548
- label: label,
2549
- active: selectedMenu === item,
2550
- "data-cy": "neeto-fields-".concat(neetoCist.slugify(label), "-menu-item"),
2551
- key: item,
2550
+ active: selectedMenu === value,
2551
+ "data-cy": "neeto-fields-".concat(neetoCist.slugify(itemLabel), "-menu-item"),
2552
+ key: label,
2553
+ label: itemLabel,
2552
2554
  description: i18next.t("neetoFields.messages.manageTitleForResource", {
2553
2555
  title: title,
2554
- resource: neetoCist.humanize(item).toLocaleLowerCase()
2556
+ resource: itemLabel.toLocaleLowerCase()
2555
2557
  }),
2556
2558
  onClick: handleBlockClick({
2557
- resource: item
2559
+ resource: value
2558
2560
  })
2559
2561
  });
2560
2562
  });
2561
2563
  };
2562
- var renderStateFilterTabs = function renderStateFilterTabs(_ref4) {
2563
- var selectedState = _ref4.selectedState,
2564
- fieldStatesTaxonomy = _ref4.fieldStatesTaxonomy,
2565
- activeFieldsCount = _ref4.activeFieldsCount,
2566
- inactiveFieldsCount = _ref4.inactiveFieldsCount,
2567
- handleBlockClick = _ref4.handleBlockClick;
2564
+ var renderStateFilterTabs = function renderStateFilterTabs(_ref5) {
2565
+ var selectedState = _ref5.selectedState,
2566
+ fieldStatesTaxonomy = _ref5.fieldStatesTaxonomy,
2567
+ activeFieldsCount = _ref5.activeFieldsCount,
2568
+ inactiveFieldsCount = _ref5.inactiveFieldsCount,
2569
+ handleBlockClick = _ref5.handleBlockClick;
2568
2570
  return /*#__PURE__*/React__default["default"].createElement(neetoui.Tab, {
2569
2571
  className: "mb-4"
2570
2572
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Tab.Item, {
@@ -2581,23 +2583,27 @@ var renderStateFilterTabs = function renderStateFilterTabs(_ref4) {
2581
2583
  })
2582
2584
  }, fieldStatesTaxonomy.inactive, "(", inactiveFieldsCount, ")"));
2583
2585
  };
2584
- var getResourceName = function getResourceName(_ref5) {
2585
- var isOwnerBased = _ref5.isOwnerBased,
2586
- owners = _ref5.owners,
2587
- selectedVal = _ref5.selectedVal,
2588
- nameAliases = _ref5.nameAliases;
2586
+ var getResourceName = function getResourceName(_ref6) {
2587
+ var _findBy2;
2588
+ var isOwnerBased = _ref6.isOwnerBased,
2589
+ menuItems = _ref6.menuItems,
2590
+ selectedVal = _ref6.selectedVal,
2591
+ nameAliases = _ref6.nameAliases;
2589
2592
  if (isOwnerBased) {
2590
2593
  var _findBy;
2591
2594
  return (_findBy = neetoCist.findBy({
2592
2595
  id: selectedVal
2593
- }, owners)) === null || _findBy === void 0 ? void 0 : _findBy.name;
2596
+ }, menuItems)) === null || _findBy === void 0 ? void 0 : _findBy.name;
2594
2597
  }
2595
- return nameAliases[selectedVal] || selectedVal;
2598
+ var selectedName = (_findBy2 = neetoCist.findBy({
2599
+ value: selectedVal
2600
+ }, menuItems)) === null || _findBy2 === void 0 ? void 0 : _findBy2.label;
2601
+ return nameAliases[selectedName] || selectedName;
2596
2602
  };
2597
- var getDashBoardTitle = function getDashBoardTitle(_ref6) {
2598
- var resourceName = _ref6.resourceName,
2599
- isSingleResource = _ref6.isSingleResource,
2600
- title = _ref6.title;
2603
+ var getDashBoardTitle = function getDashBoardTitle(_ref7) {
2604
+ var resourceName = _ref7.resourceName,
2605
+ isSingleResource = _ref7.isSingleResource,
2606
+ title = _ref7.title;
2601
2607
  var displayTitle = isSingleResource ? title : i18next.t("neetoFields.messages.titleForResource", {
2602
2608
  title: title,
2603
2609
  resource: resourceName
@@ -2622,10 +2628,10 @@ var renderNoDataHelpText = function renderNoDataHelpText(title, url) {
2622
2628
  }
2623
2629
  });
2624
2630
  };
2625
- var getDeletionConfirmationMessage = function getDeletionConfirmationMessage(_ref7) {
2626
- var resource = _ref7.resource,
2627
- fieldName = _ref7.fieldName,
2628
- affectedResourcesCount = _ref7.affectedResourcesCount;
2631
+ var getDeletionConfirmationMessage = function getDeletionConfirmationMessage(_ref8) {
2632
+ var resource = _ref8.resource,
2633
+ fieldName = _ref8.fieldName,
2634
+ affectedResourcesCount = _ref8.affectedResourcesCount;
2629
2635
  return affectedResourcesCount > 0 ? /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
2630
2636
  i18nKey: "neetoFields.messages.confirmDeleteWithCount",
2631
2637
  values: {
@@ -2785,8 +2791,8 @@ var useFieldsDashboard = function useFieldsDashboard(_ref) {
2785
2791
  state: state
2786
2792
  };
2787
2793
  if (!isConfigsLoading && ramda.isNil(resource)) {
2788
- var _menuItems$;
2789
- queryParams.resource = isOwnerBased ? menuItems === null || menuItems === void 0 ? void 0 : (_menuItems$ = menuItems[0]) === null || _menuItems$ === void 0 ? void 0 : _menuItems$.id : menuItems === null || menuItems === void 0 ? void 0 : menuItems[0];
2794
+ var _menuItems$, _menuItems$2;
2795
+ queryParams.resource = isOwnerBased ? menuItems === null || menuItems === void 0 ? void 0 : (_menuItems$ = menuItems[0]) === null || _menuItems$ === void 0 ? void 0 : _menuItems$.id : menuItems === null || menuItems === void 0 ? void 0 : (_menuItems$2 = menuItems[0]) === null || _menuItems$2 === void 0 ? void 0 : _menuItems$2.value;
2790
2796
  }
2791
2797
  if (!isConfigsLoading && ramda.isNil(state)) {
2792
2798
  queryParams.state = FIELD_STATES.active;
@@ -2807,7 +2813,7 @@ var useFieldsDashboard = function useFieldsDashboard(_ref) {
2807
2813
  return getResourceName({
2808
2814
  isOwnerBased: isOwnerBased,
2809
2815
  nameAliases: nameAliases,
2810
- owners: menuItems,
2816
+ menuItems: menuItems,
2811
2817
  selectedVal: resource
2812
2818
  });
2813
2819
  }, [menuItems, resource]);