@crystaldesign/diva-backoffice 25.8.0-beta.13 → 25.8.0-beta.15

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.
@@ -17509,14 +17509,29 @@ function useSelectSimpleData (_ref) {
17509
17509
  });
17510
17510
  return selected.value;
17511
17511
  }, [selected]);
17512
+ var setLoadedOptions = function setLoadedOptions(options) {
17513
+ var _options$;
17514
+ setOptions(options);
17515
+ if (value && options) {
17516
+ LOG$a.debug('value changed', toJS(value), toJS(options));
17517
+ var _selected = findByValue(value, options, selectMapping);
17518
+ var selectedValues = Array.isArray(_selected) ? _selected.map(function (item) {
17519
+ return item.value;
17520
+ }) : _selected === null || _selected === void 0 ? void 0 : _selected.value;
17521
+ onSelectionChanged(selectedValues, _selected);
17522
+ } else if (options !== null && options !== void 0 && (_options$ = options[0]) !== null && _options$ !== void 0 && _options$.value && autoSelectFirst) {
17523
+ onSelectionChanged(options[0].value, options[0]);
17524
+ }
17525
+ };
17512
17526
  useEffect(function () {
17513
17527
  if (configuredOptions) {
17514
17528
  if (apiHandler.canReadList) LOG$a.warn('If options are provided, apiInterface will not be used');
17515
- setOptions(configuredOptions);
17529
+ setLoadedOptions(configuredOptions);
17516
17530
  setLoading(false);
17517
17531
  return;
17518
17532
  }
17519
- if (options) {
17533
+ if (sharedState !== null && sharedState !== void 0 && sharedState.options) {
17534
+ setLoadedOptions(sharedState.options);
17520
17535
  setLoading(false);
17521
17536
  return;
17522
17537
  }
@@ -17528,25 +17543,11 @@ function useSelectSimpleData (_ref) {
17528
17543
  var options = data.data.map(function (item) {
17529
17544
  return parseDataEntry(item, selectMapping);
17530
17545
  });
17531
- setOptions(options);
17546
+ setLoadedOptions(options);
17532
17547
  })["finally"](function () {
17533
17548
  setLoading(false);
17534
17549
  });
17535
17550
  }, []);
17536
- useEffect(function () {
17537
- var _options$;
17538
- // set the selected option only after the options are loaded
17539
- if (value && options) {
17540
- LOG$a.debug('value changed', value);
17541
- var _selected = findByValue(value, options, selectMapping);
17542
- var selectedValues = Array.isArray(_selected) ? _selected.map(function (item) {
17543
- return item.value;
17544
- }) : _selected === null || _selected === void 0 ? void 0 : _selected.value;
17545
- onSelectionChanged(selectedValues, _selected);
17546
- } else if (options !== null && options !== void 0 && (_options$ = options[0]) !== null && _options$ !== void 0 && _options$.value && autoSelectFirst) {
17547
- onSelectionChanged(options[0].value, options[0]);
17548
- }
17549
- }, [value, options]);
17550
17551
  var onSelectionChanged = function onSelectionChanged(value, option) {
17551
17552
  setSelected(option);
17552
17553
  onChange === null || onChange === void 0 || onChange(parseReturnData(option, selectMapping));
@@ -35910,24 +35911,34 @@ var useCatalogContext = function useCatalogContext() {
35910
35911
  root.contextStore.clearContext('catalog');
35911
35912
  }
35912
35913
 
35913
- // Only update if catalog changed
35914
- // initally ony the id is set so we need to update it again if we get the full catalog form the selector, so only checking for id is not enough
35914
+ // initally only the id is set so we need to update it again if we get the full catalog form the selector
35915
35915
  var currentCatalog = getContext().selectedCatalog;
35916
- if (currentCatalog._id === newCatalog._id && currentCatalog.name === newCatalog.name && JSON.stringify(currentCatalog.isoLanguageIds) === JSON.stringify(newCatalog.isoLanguageIds)) {
35917
- return; // No changes detected
35916
+ var catalogChanged = currentCatalog._id !== newCatalog._id;
35917
+ var catalogDataOnlyChanged = currentCatalog.name === newCatalog.name && JSON.stringify(currentCatalog.isoLanguageIds) === JSON.stringify(newCatalog.isoLanguageIds);
35918
+ if (!catalogChanged && !catalogDataOnlyChanged) {
35919
+ // No changes detected
35920
+ return;
35921
+ }
35922
+ if (!catalogChanged && catalogDataOnlyChanged) {
35923
+ // Only the data changed, so we only need to update the context of the catalog
35924
+ root.contextStore.updateContext('catalog', {
35925
+ selectedCatalog: newCatalog,
35926
+ catalogId: newCatalog._id
35927
+ });
35928
+ return;
35918
35929
  }
35930
+ if (catalogChanged) {
35931
+ // The catalog changed, so we need to rest the full context
35932
+ root.contextStore.updateContext('catalog', {
35933
+ selectedCatalog: newCatalog,
35934
+ catalogId: newCatalog._id,
35935
+ selectedSerie: undefined,
35936
+ selectedItem: undefined,
35937
+ selectedFeature: undefined,
35938
+ seriesSelectorState: createDefaultSelectState('seriesSelectorState'),
35939
+ featureSelectorState: createDefaultSelectState('featureSelectorState')
35940
+ });
35919
35941
 
35920
- // Update any field catalog changed
35921
- root.contextStore.updateContext('catalog', {
35922
- selectedCatalog: newCatalog,
35923
- catalogId: newCatalog._id,
35924
- selectedSerie: undefined,
35925
- selectedItem: undefined,
35926
- selectedFeature: undefined,
35927
- seriesSelectorState: createDefaultSelectState('seriesSelectorState'),
35928
- featureSelectorState: createDefaultSelectState('featureSelectorState')
35929
- });
35930
- if (currentCatalog._id !== newCatalog._id) {
35931
35942
  // Update URL only if the id changed
35932
35943
  navigate(path + newCatalog._id + (modules.length ? '/' + modules.join('/') : '') + (searchParams ? '?' + searchParams.toString() : ''));
35933
35944
  }
@@ -36756,27 +36767,22 @@ var CatalogSelector$1 = observer(CatalogSelector);
36756
36767
  var SeriesSelector = function SeriesSelector(_ref) {
36757
36768
  var modules = _ref.modules;
36758
36769
  var _useTranslation = useTranslation(),
36759
- t = _useTranslation.t,
36760
- i18n = _useTranslation.i18n;
36761
- var _useCatalogContext = useCatalogContext(modules),
36762
- catalogId = _useCatalogContext.catalogId,
36763
- idmService = _useCatalogContext.idmService,
36764
- selectedSerie = _useCatalogContext.selectedSerie,
36765
- setSelectedSerie = _useCatalogContext.setSelectedSerie,
36766
- seriesSelectorState = _useCatalogContext.seriesSelectorState;
36770
+ t = _useTranslation.t;
36771
+ var _useSeriesSelector = useSeriesSelector(modules),
36772
+ catalogId = _useSeriesSelector.catalogId,
36773
+ seriesSelectorState = _useSeriesSelector.seriesSelectorState,
36774
+ apiInterface = _useSeriesSelector.apiInterface,
36775
+ selectedSerie = _useSeriesSelector.selectedSerie,
36776
+ onChange = _useSeriesSelector.onChange,
36777
+ selectMapping = _useSeriesSelector.selectMapping;
36767
36778
  return /*#__PURE__*/jsx(SimpleSelect, {
36768
36779
  sharedState: seriesSelectorState,
36769
- apiInterface: {
36770
- read: idmService + '/v3.0/catalogs/' + catalogId + "/series?fields=seriesName[".concat(i18n.language.toLocaleUpperCase(), "];_id;serieNo;pricefeaturegroups;pricefeaturegroupsDisplayTexts;pricefeaturegroupsKeys;pricefeaturegroupsKeysDisplayTexts")
36771
- },
36772
- selectMapping: {
36773
- label: "${seriesName.".concat(i18n.language.toLocaleUpperCase(), "}"),
36774
- value: '${_id}'
36775
- },
36780
+ apiInterface: apiInterface,
36781
+ selectMapping: selectMapping,
36776
36782
  autoSelectFirst: true,
36777
36783
  title: t('backoffice.menu.items.label.IDMCatalogEditorTableSeries'),
36778
36784
  value: selectedSerie,
36779
- onChange: setSelectedSerie,
36785
+ onChange: onChange,
36780
36786
  search: true,
36781
36787
  style: {
36782
36788
  width: 200
@@ -36785,6 +36791,95 @@ var SeriesSelector = function SeriesSelector(_ref) {
36785
36791
  }, catalogId);
36786
36792
  };
36787
36793
  var SeriesSelector$1 = observer(SeriesSelector);
36794
+ var useSeriesSelector = function useSeriesSelector(modules) {
36795
+ var _useTranslation2 = useTranslation(),
36796
+ i18n = _useTranslation2.i18n;
36797
+ var root = useStore();
36798
+ var _useCatalogContext = useCatalogContext(modules),
36799
+ catalogId = _useCatalogContext.catalogId,
36800
+ idmService = _useCatalogContext.idmService,
36801
+ selectedSerie = _useCatalogContext.selectedSerie,
36802
+ setSelectedSerie = _useCatalogContext.setSelectedSerie,
36803
+ seriesSelectorState = _useCatalogContext.seriesSelectorState;
36804
+ var _useState = useState(selectedSerie),
36805
+ _useState2 = _slicedToArray(_useState, 2),
36806
+ selected = _useState2[0],
36807
+ setSelected = _useState2[1];
36808
+ var apiInterface = {
36809
+ read: idmService + "/v3.0/catalogs/".concat(catalogId, "/series?fields=seriesName[").concat(i18n.language.toLocaleUpperCase(), "];_id")
36810
+ };
36811
+ var selectMapping = {
36812
+ label: "${seriesName.".concat(i18n.language.toLocaleUpperCase(), "}"),
36813
+ value: '${_id}'
36814
+ };
36815
+ var fetchSerie = /*#__PURE__*/function () {
36816
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(newSerie) {
36817
+ var _seriesSelectorState$, _seriesSelectorState$2;
36818
+ var isLoaded, api, serie, option;
36819
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
36820
+ while (1) switch (_context.prev = _context.next) {
36821
+ case 0:
36822
+ if (newSerie) {
36823
+ _context.next = 2;
36824
+ break;
36825
+ }
36826
+ return _context.abrupt("return");
36827
+ case 2:
36828
+ // if the extend series data is already loaded, use it
36829
+ isLoaded = !!((_seriesSelectorState$ = seriesSelectorState.options) !== null && _seriesSelectorState$ !== void 0 && (_seriesSelectorState$ = _seriesSelectorState$.find(function (option) {
36830
+ return option.value === (newSerie === null || newSerie === void 0 ? void 0 : newSerie._id);
36831
+ })) !== null && _seriesSelectorState$ !== void 0 && (_seriesSelectorState$ = _seriesSelectorState$.data) !== null && _seriesSelectorState$ !== void 0 && _seriesSelectorState$.serieNo);
36832
+ if (!isLoaded) {
36833
+ _context.next = 6;
36834
+ break;
36835
+ }
36836
+ setSelectedSerie(newSerie);
36837
+ return _context.abrupt("return");
36838
+ case 6:
36839
+ //fetching of pricefeatruegroups is slow, so we can't fetch it in the list, but only for the selected serie
36840
+ seriesSelectorState.setLoading(true);
36841
+ api = new _default$d({
36842
+ type: 'SelectSimple',
36843
+ apiInterface: {
36844
+ read: idmService + "/v3.0/catalogs/".concat(catalogId, "/series/").concat(newSerie._id, "?fields=seriesName[").concat(i18n.language.toLocaleUpperCase(), "];_id;serieNo;pricefeaturegroups;pricefeaturegroupsDisplayTexts;pricefeaturegroupsKeys;pricefeaturegroupsKeysDisplayTexts")
36845
+ }
36846
+ }, root);
36847
+ _context.next = 10;
36848
+ return api.read();
36849
+ case 10:
36850
+ serie = _context.sent;
36851
+ //save the extended series data in the options, without triggering state change
36852
+ option = (_seriesSelectorState$2 = seriesSelectorState.options) === null || _seriesSelectorState$2 === void 0 ? void 0 : _seriesSelectorState$2.find(function (option) {
36853
+ return option.value === newSerie._id;
36854
+ });
36855
+ if (option) {
36856
+ option.data = serie;
36857
+ }
36858
+ setSelectedSerie(serie);
36859
+ seriesSelectorState.setLoading(false);
36860
+ case 15:
36861
+ case "end":
36862
+ return _context.stop();
36863
+ }
36864
+ }, _callee);
36865
+ }));
36866
+ return function fetchSerie(_x) {
36867
+ return _ref2.apply(this, arguments);
36868
+ };
36869
+ }();
36870
+ var onChange = function onChange(value) {
36871
+ setSelected(value);
36872
+ fetchSerie(value);
36873
+ };
36874
+ return {
36875
+ catalogId: catalogId,
36876
+ seriesSelectorState: seriesSelectorState,
36877
+ apiInterface: apiInterface,
36878
+ selectMapping: selectMapping,
36879
+ selectedSerie: selected,
36880
+ onChange: onChange
36881
+ };
36882
+ };
36788
36883
 
36789
36884
  function useModule (currentModules) {
36790
36885
  var root = useStore();
@@ -1 +1 @@
1
- {"version":3,"file":"SeriesSelector.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMCatalogEditor/components/PrefilterSelectors/SeriesSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;uCAMW;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE;;;AA8B1D,wBAAwC"}
1
+ {"version":3,"file":"SeriesSelector.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMCatalogEditor/components/PrefilterSelectors/SeriesSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;uCASH;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE;;;AAqB1D,wBAAwC"}
@@ -8,12 +8,12 @@ export declare const useCatalogContext: (currentModules?: string[]) => {
8
8
  selectedCatalog: any;
9
9
  idmService: string;
10
10
  organizationId: string;
11
- catalogSelectorState?: SharedSelectState;
11
+ catalogSelectorState: SharedSelectState;
12
12
  selectedSerie?: any;
13
- seriesSelectorState?: SharedSelectState;
13
+ seriesSelectorState: SharedSelectState;
14
14
  selectedItem?: any;
15
- itemSelectorState?: SharedSelectState;
15
+ itemSelectorState: SharedSelectState;
16
16
  selectedFeature?: any;
17
- featureSelectorState?: SharedSelectState;
17
+ featureSelectorState: SharedSelectState;
18
18
  };
19
19
  //# sourceMappingURL=useCatalogContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCatalogContext.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/IDMCatalogEditor/hooks/useCatalogContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAU,iBAAiB,EAAE,MAAM,sDAAsD,CAAC;AAiBjG,eAAO,MAAM,iBAAiB,oBAAoB,MAAM,EAAE;8BAqD9C,GAAG,GAAG,SAAS;4BAOhB,GAAG,GAAG,SAAS;kCAOZ,GAAG,GAAG,SAAS;kCAOf,GAAG,GAAG,MAAM,YAAW,MAAM,EAAE,SAAyB,MAAM,UAAiB,OAAO;eAvFvF,MAAM;qBACA,GAAG;gBACR,MAAM;oBACF,MAAM;2BACC,iBAAiB;oBACxB,GAAG;0BACG,iBAAiB;mBACxB,GAAG;wBACE,iBAAiB;sBACnB,GAAG;2BACE,iBAAiB;CAsIzC,CAAC"}
1
+ {"version":3,"file":"useCatalogContext.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/IDMCatalogEditor/hooks/useCatalogContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAU,iBAAiB,EAAE,MAAM,sDAAsD,CAAC;AAiBjG,eAAO,MAAM,iBAAiB,oBAAoB,MAAM,EAAE;8BAqD9C,GAAG,GAAG,SAAS;4BAOhB,GAAG,GAAG,SAAS;kCAOZ,GAAG,GAAG,SAAS;kCAOf,GAAG,GAAG,MAAM,YAAW,MAAM,EAAE,SAAyB,MAAM,UAAiB,OAAO;eAvFvF,MAAM;qBACA,GAAG;gBACR,MAAM;oBACF,MAAM;0BACA,iBAAiB;oBACvB,GAAG;yBACE,iBAAiB;mBACvB,GAAG;uBACC,iBAAiB;sBAClB,GAAG;0BACC,iBAAiB;CA+IxC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useSelectSimpleData.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/SelectSimple/useSelectSimpleData.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAiB,MAAM,SAAS,CAAC;AAMvE,MAAM,CAAC,OAAO,WAAW,EACvB,YAAY,EACZ,aAAa,EACb,UAAU,EACV,QAAQ,EACR,KAAK,EACL,OAAO,EAAE,iBAAiB,EAC1B,eAAe,EACf,WAAW,GACZ,EAAE,qBAAqB;;;;sBAsEa,GAAG,UAAU,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS;;EAiB9E"}
1
+ {"version":3,"file":"useSelectSimpleData.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/SelectSimple/useSelectSimpleData.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAiB,MAAM,SAAS,CAAC;AAOvE,MAAM,CAAC,OAAO,WAAW,EACvB,YAAY,EACZ,aAAa,EACb,UAAU,EACV,QAAQ,EACR,KAAK,EACL,OAAO,EAAE,iBAAiB,EAC1B,eAAe,EACf,WAAW,GACZ,EAAE,qBAAqB;;;;sBAuEa,GAAG,UAAU,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS;;EAiB9E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystaldesign/diva-backoffice",
3
- "version": "25.8.0-beta.13",
3
+ "version": "25.8.0-beta.15",
4
4
  "license": "COMMERCIAL",
5
5
  "devDependencies": {
6
6
  "@testing-library/jest-dom": "^6.5.0",
@@ -15,13 +15,13 @@
15
15
  "dependencies": {
16
16
  "@ant-design/icons": "5.4.0",
17
17
  "@babel/runtime": "7.24.7",
18
- "@crystaldesign/content-box": "25.8.0-beta.13",
19
- "@crystaldesign/content-item": "25.8.0-beta.13",
20
- "@crystaldesign/diva-core": "25.8.0-beta.13",
21
- "@crystaldesign/diva-utils": "25.8.0-beta.13",
22
- "@crystaldesign/media-upload": "25.8.0-beta.13",
23
- "@crystaldesign/rtf-editor": "25.8.0-beta.13",
24
- "@crystaldesign/spreadsheet": "25.8.0-beta.13",
18
+ "@crystaldesign/content-box": "25.8.0-beta.15",
19
+ "@crystaldesign/content-item": "25.8.0-beta.15",
20
+ "@crystaldesign/diva-core": "25.8.0-beta.15",
21
+ "@crystaldesign/diva-utils": "25.8.0-beta.15",
22
+ "@crystaldesign/media-upload": "25.8.0-beta.15",
23
+ "@crystaldesign/rtf-editor": "25.8.0-beta.15",
24
+ "@crystaldesign/spreadsheet": "25.8.0-beta.15",
25
25
  "@google/model-viewer": "3.5.0",
26
26
  "ag-charts-community": "^10.1.0",
27
27
  "ag-charts-react": "^10.1.0",
@@ -51,5 +51,5 @@
51
51
  },
52
52
  "module": "build/esm/index.js",
53
53
  "types": "./build/types/backoffice/src/index.d.ts",
54
- "gitHead": "1711631dd5429aa9ad629c4e77427e69e969a3c0"
54
+ "gitHead": "bf79de9df314c4ae32cd6d5f778cc9b4322aad95"
55
55
  }