@guillotinaweb/react-gmi 0.25.2 → 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.
@@ -3134,11 +3134,8 @@
3134
3134
  valueLabel = _useState[0],
3135
3135
  setValueLabel = _useState[1];
3136
3136
 
3137
- var _useState2 = React.useState(false),
3138
- setIsLoadingData = _useState2[1];
3139
-
3140
- var _useState3 = React.useState(generateUID('search_input')),
3141
- uid = _useState3[0];
3137
+ var _useState2 = React.useState(generateUID('search_input')),
3138
+ uid = _useState2[0];
3142
3139
 
3143
3140
  useClickAway(wrapperRef, function () {
3144
3141
  setIsOpen(false);
@@ -3164,7 +3161,6 @@
3164
3161
  try {
3165
3162
  var _temp2 = function () {
3166
3163
  if (labelProperty !== 'id' && value) {
3167
- setIsLoadingData(true);
3168
3164
  var searchTermQs = [];
3169
3165
  var searchTermParsed = ["id", value];
3170
3166
  var getSearch = traversal.registry.get;
@@ -3191,7 +3187,6 @@
3191
3187
  return result;
3192
3188
  }, {});
3193
3189
  setValueLabel(newValuesLabel);
3194
- setIsLoadingData(false);
3195
3190
  });
3196
3191
  }
3197
3192
  }();
@@ -3236,7 +3231,7 @@
3236
3231
  pageSize: PageSize,
3237
3232
  withDepth: false
3238
3233
  });
3239
- var sortParsed = parser("_sort_des=title");
3234
+ var sortParsed = parser("_sort_des=" + labelProperty);
3240
3235
  var typeNameParsed = [];
3241
3236
 
3242
3237
  if (typeNameQuery) {
@@ -3268,7 +3263,7 @@
3268
3263
  return renderTextItemOption(item);
3269
3264
  }
3270
3265
 
3271
- return item.title || item['@name'];
3266
+ return get$1(item, labelProperty, item.title) || item['@name'];
3272
3267
  };
3273
3268
 
3274
3269
  React.useEffect(function () {
@@ -3977,8 +3972,6 @@
3977
3972
  }, [value]);
3978
3973
 
3979
3974
  var getRenderValue = function getRenderValue() {
3980
- console.log('get render values', value, valuesLabels);
3981
-
3982
3975
  if (value === undefined) {
3983
3976
  if (modifyContent) {
3984
3977
  return DEFAULT_VALUE_EDITABLE_FIELD;
@@ -4285,7 +4278,7 @@
4285
4278
  pageSize: PageSize,
4286
4279
  withDepth: false
4287
4280
  });
4288
- var sortParsed = parser("_sort_des=title");
4281
+ var sortParsed = parser("_sort_des=" + labelProperty);
4289
4282
  var typeNameParsed = [];
4290
4283
 
4291
4284
  if (typeNameQuery) {
@@ -4359,7 +4352,7 @@
4359
4352
  return renderTextItemOption(item);
4360
4353
  }
4361
4354
 
4362
- return item.title || item['@name'];
4355
+ return get$1(item, labelProperty, item.title) || item['@name'];
4363
4356
  };
4364
4357
 
4365
4358
  React__default['default'].useEffect(function () {
@@ -6095,6 +6088,7 @@
6095
6088
  setWorkflowAction = _React$useState2[1];
6096
6089
 
6097
6090
  var model = new ItemModel(Ctx.context);
6091
+ var vocabulary = useVocabulary('workflow_states');
6098
6092
  var currentState = model.item['guillotina.contrib.workflows.interfaces.IWorkflowBehavior']['review_state'];
6099
6093
  React__default['default'].useEffect(function () {
6100
6094
  loadDefinition();
@@ -6123,6 +6117,36 @@
6123
6117
  }
6124
6118
  };
6125
6119
 
6120
+ var getStateTitle = function getStateTitle() {
6121
+ var _vocabulary$data, _vocabulary$data$item;
6122
+
6123
+ console.log('getStateTitle', vocabulary);
6124
+
6125
+ if (((_vocabulary$data = vocabulary.data) == null ? void 0 : (_vocabulary$data$item = _vocabulary$data.items) == null ? void 0 : _vocabulary$data$item.length) > 0) {
6126
+ var vocabularyValue = vocabulary.data.items.find(function (item) {
6127
+ return item.token === currentState;
6128
+ });
6129
+ console.log('state title', vocabularyValue, intl.locale);
6130
+
6131
+ if (vocabularyValue) {
6132
+ var translatedValue = get$1(vocabularyValue, "title.translated_title." + intl.locale, null);
6133
+
6134
+ if (translatedValue !== null) {
6135
+ return translatedValue;
6136
+ }
6137
+
6138
+ var titleValue = get$1(vocabularyValue, "title.title." + intl.locale, null);
6139
+
6140
+ if (titleValue !== null) {
6141
+ return titleValue;
6142
+ }
6143
+ }
6144
+ }
6145
+
6146
+ return currentState;
6147
+ };
6148
+
6149
+ console.log('Workflow log');
6126
6150
  if (definition === undefined) return null;
6127
6151
  return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, workflowAction && /*#__PURE__*/React__default['default'].createElement(Confirm, {
6128
6152
  loading: loading,
@@ -6139,8 +6163,8 @@
6139
6163
  className: "has-text-weight-bold",
6140
6164
  "data-test": "textInfoStatus-" + currentState
6141
6165
  }, intl.formatMessage(messages$1.current_state, {
6142
- state: currentState
6143
- }))), modifyContent && /*#__PURE__*/React__default['default'].createElement("div", {
6166
+ state: getStateTitle()
6167
+ }))), modifyContent && definition.transitions.length > 0 && /*#__PURE__*/React__default['default'].createElement("div", {
6144
6168
  className: " is-flex is-align-items-center has-text-weight-bold",
6145
6169
  "data-test": "textInfoStatus-" + currentState
6146
6170
  }, /*#__PURE__*/React__default['default'].createElement("label", null, intl.formatMessage(messages$1.actions)), "\xA0\xA0", definition.transitions.map(function (transition) {
@@ -6150,7 +6174,7 @@
6150
6174
  onClick: function onClick() {
6151
6175
  return setWorkflowAction(transition['@id'].split('@workflow')[1].slice(1));
6152
6176
  }
6153
- }, transition.title);
6177
+ }, get$1(transition, "metadata.translated_title." + intl.locale, transition.title));
6154
6178
  })));
6155
6179
  }
6156
6180