@guillotinaweb/react-gmi 0.25.1 → 0.26.0

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.
@@ -2499,7 +2499,6 @@ const SearchInput = ({
2499
2499
  SearchEngine
2500
2500
  } = useConfig();
2501
2501
  const [valueLabel, setValueLabel] = useState(undefined);
2502
- const [isLoadingData, setIsLoadingData] = useState(false);
2503
2502
  const [uid] = useState(generateUID('search_input'));
2504
2503
  useClickAway(wrapperRef, () => {
2505
2504
  setIsOpen(false);
@@ -2521,7 +2520,6 @@ const SearchInput = ({
2521
2520
 
2522
2521
  const inicializeLabels = async () => {
2523
2522
  if (_labelProperty !== 'id' && value) {
2524
- setIsLoadingData(true);
2525
2523
  let searchTermQs = [];
2526
2524
  const searchTermParsed = [`id`, value];
2527
2525
  const {
@@ -2552,7 +2550,6 @@ const SearchInput = ({
2552
2550
  return result;
2553
2551
  }, {});
2554
2552
  setValueLabel(newValuesLabel);
2555
- setIsLoadingData(false);
2556
2553
  }
2557
2554
  };
2558
2555
 
@@ -2581,7 +2578,7 @@ const SearchInput = ({
2581
2578
  withDepth: false
2582
2579
  });
2583
2580
 
2584
- let sortParsed = parser(`_sort_des=title`);
2581
+ let sortParsed = parser(`_sort_des=${_labelProperty}`);
2585
2582
  let typeNameParsed = [];
2586
2583
 
2587
2584
  if (_typeNameQuery) {
@@ -2607,7 +2604,7 @@ const SearchInput = ({
2607
2604
  return _renderTextItemOption(item);
2608
2605
  }
2609
2606
 
2610
- return item.title || item['@name'];
2607
+ return get$1(item, _labelProperty, item.title) || item['@name'];
2611
2608
  };
2612
2609
 
2613
2610
  useEffect(() => {
@@ -3228,8 +3225,6 @@ const SearchRenderField = ({
3228
3225
  }, [value]);
3229
3226
 
3230
3227
  const getRenderValue = () => {
3231
- console.log('get render values', value, valuesLabels);
3232
-
3233
3228
  if (value === undefined) {
3234
3229
  if (modifyContent) {
3235
3230
  return DEFAULT_VALUE_EDITABLE_FIELD;
@@ -3494,7 +3489,7 @@ const SearchInputList = ({
3494
3489
  withDepth: false
3495
3490
  });
3496
3491
 
3497
- let sortParsed = parser(`_sort_des=title`);
3492
+ let sortParsed = parser(`_sort_des=${_labelProperty}`);
3498
3493
  let typeNameParsed = [];
3499
3494
 
3500
3495
  if (_typeNameQuery) {
@@ -3557,7 +3552,7 @@ const SearchInputList = ({
3557
3552
  return _renderTextItemOption(item);
3558
3553
  }
3559
3554
 
3560
- return item.title || item['@name'];
3555
+ return get$1(item, _labelProperty, item.title) || item['@name'];
3561
3556
  };
3562
3557
 
3563
3558
  React.useEffect(() => {
@@ -4677,6 +4672,7 @@ function IWorkflow() {
4677
4672
  const [definition, setDefinition] = React.useState(undefined);
4678
4673
  const [workflowAction, setWorkflowAction] = React.useState(null);
4679
4674
  const model = new ItemModel(Ctx.context);
4675
+ const vocabulary = useVocabulary('workflow_states');
4680
4676
  const currentState = model.item['guillotina.contrib.workflows.interfaces.IWorkflowBehavior']['review_state'];
4681
4677
 
4682
4678
  async function loadDefinition() {
@@ -4708,6 +4704,34 @@ function IWorkflow() {
4708
4704
  setWorkflowAction(null);
4709
4705
  };
4710
4706
 
4707
+ const getStateTitle = () => {
4708
+ var _vocabulary$data, _vocabulary$data$item;
4709
+
4710
+ console.log('getStateTitle', vocabulary);
4711
+
4712
+ if (((_vocabulary$data = vocabulary.data) == null ? void 0 : (_vocabulary$data$item = _vocabulary$data.items) == null ? void 0 : _vocabulary$data$item.length) > 0) {
4713
+ const vocabularyValue = vocabulary.data.items.find(item => item.token === currentState);
4714
+ console.log('state title', vocabularyValue, intl.locale);
4715
+
4716
+ if (vocabularyValue) {
4717
+ const translatedValue = get$1(vocabularyValue, `title.translated_title.${intl.locale}`, null);
4718
+
4719
+ if (translatedValue !== null) {
4720
+ return translatedValue;
4721
+ }
4722
+
4723
+ const titleValue = get$1(vocabularyValue, `title.title.${intl.locale}`, null);
4724
+
4725
+ if (titleValue !== null) {
4726
+ return titleValue;
4727
+ }
4728
+ }
4729
+ }
4730
+
4731
+ return currentState;
4732
+ };
4733
+
4734
+ console.log('Workflow log');
4711
4735
  if (definition === undefined) return null;
4712
4736
  return /*#__PURE__*/React.createElement(React.Fragment, null, workflowAction && /*#__PURE__*/React.createElement(Confirm, {
4713
4737
  loading: loading,
@@ -4722,8 +4746,8 @@ function IWorkflow() {
4722
4746
  className: "has-text-weight-bold",
4723
4747
  "data-test": `textInfoStatus-${currentState}`
4724
4748
  }, intl.formatMessage(messages$1.current_state, {
4725
- state: currentState
4726
- }))), modifyContent && /*#__PURE__*/React.createElement("div", {
4749
+ state: getStateTitle()
4750
+ }))), modifyContent && definition.transitions.length > 0 && /*#__PURE__*/React.createElement("div", {
4727
4751
  className: " is-flex is-align-items-center has-text-weight-bold",
4728
4752
  "data-test": `textInfoStatus-${currentState}`
4729
4753
  }, /*#__PURE__*/React.createElement("label", null, intl.formatMessage(messages$1.actions)), "\xA0\xA0", definition.transitions.map(transition => {
@@ -4731,7 +4755,7 @@ function IWorkflow() {
4731
4755
  key: transition['@id'],
4732
4756
  className: "button mr-4",
4733
4757
  onClick: () => setWorkflowAction(transition['@id'].split('@workflow')[1].slice(1))
4734
- }, transition.title);
4758
+ }, get$1(transition, `metadata.translated_title.${intl.locale}`, transition.title));
4735
4759
  })));
4736
4760
  }
4737
4761