@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.
@@ -3130,11 +3130,8 @@ var SearchInput = function SearchInput(_ref) {
3130
3130
  valueLabel = _useState[0],
3131
3131
  setValueLabel = _useState[1];
3132
3132
 
3133
- var _useState2 = useState(false),
3134
- setIsLoadingData = _useState2[1];
3135
-
3136
- var _useState3 = useState(generateUID('search_input')),
3137
- uid = _useState3[0];
3133
+ var _useState2 = useState(generateUID('search_input')),
3134
+ uid = _useState2[0];
3138
3135
 
3139
3136
  useClickAway(wrapperRef, function () {
3140
3137
  setIsOpen(false);
@@ -3160,7 +3157,6 @@ var SearchInput = function SearchInput(_ref) {
3160
3157
  try {
3161
3158
  var _temp2 = function () {
3162
3159
  if (labelProperty !== 'id' && value) {
3163
- setIsLoadingData(true);
3164
3160
  var searchTermQs = [];
3165
3161
  var searchTermParsed = ["id", value];
3166
3162
  var getSearch = traversal.registry.get;
@@ -3187,7 +3183,6 @@ var SearchInput = function SearchInput(_ref) {
3187
3183
  return result;
3188
3184
  }, {});
3189
3185
  setValueLabel(newValuesLabel);
3190
- setIsLoadingData(false);
3191
3186
  });
3192
3187
  }
3193
3188
  }();
@@ -3232,7 +3227,7 @@ var SearchInput = function SearchInput(_ref) {
3232
3227
  pageSize: PageSize,
3233
3228
  withDepth: false
3234
3229
  });
3235
- var sortParsed = parser("_sort_des=title");
3230
+ var sortParsed = parser("_sort_des=" + labelProperty);
3236
3231
  var typeNameParsed = [];
3237
3232
 
3238
3233
  if (typeNameQuery) {
@@ -3264,7 +3259,7 @@ var SearchInput = function SearchInput(_ref) {
3264
3259
  return renderTextItemOption(item);
3265
3260
  }
3266
3261
 
3267
- return item.title || item['@name'];
3262
+ return get$1(item, labelProperty, item.title) || item['@name'];
3268
3263
  };
3269
3264
 
3270
3265
  useEffect(function () {
@@ -3973,8 +3968,6 @@ var SearchRenderField = function SearchRenderField(_ref3) {
3973
3968
  }, [value]);
3974
3969
 
3975
3970
  var getRenderValue = function getRenderValue() {
3976
- console.log('get render values', value, valuesLabels);
3977
-
3978
3971
  if (value === undefined) {
3979
3972
  if (modifyContent) {
3980
3973
  return DEFAULT_VALUE_EDITABLE_FIELD;
@@ -4281,7 +4274,7 @@ var SearchInputList = function SearchInputList(_ref) {
4281
4274
  pageSize: PageSize,
4282
4275
  withDepth: false
4283
4276
  });
4284
- var sortParsed = parser("_sort_des=title");
4277
+ var sortParsed = parser("_sort_des=" + labelProperty);
4285
4278
  var typeNameParsed = [];
4286
4279
 
4287
4280
  if (typeNameQuery) {
@@ -4355,7 +4348,7 @@ var SearchInputList = function SearchInputList(_ref) {
4355
4348
  return renderTextItemOption(item);
4356
4349
  }
4357
4350
 
4358
- return item.title || item['@name'];
4351
+ return get$1(item, labelProperty, item.title) || item['@name'];
4359
4352
  };
4360
4353
 
4361
4354
  React.useEffect(function () {
@@ -6091,6 +6084,7 @@ function IWorkflow() {
6091
6084
  setWorkflowAction = _React$useState2[1];
6092
6085
 
6093
6086
  var model = new ItemModel(Ctx.context);
6087
+ var vocabulary = useVocabulary('workflow_states');
6094
6088
  var currentState = model.item['guillotina.contrib.workflows.interfaces.IWorkflowBehavior']['review_state'];
6095
6089
  React.useEffect(function () {
6096
6090
  loadDefinition();
@@ -6119,6 +6113,36 @@ function IWorkflow() {
6119
6113
  }
6120
6114
  };
6121
6115
 
6116
+ var getStateTitle = function getStateTitle() {
6117
+ var _vocabulary$data, _vocabulary$data$item;
6118
+
6119
+ console.log('getStateTitle', vocabulary);
6120
+
6121
+ if (((_vocabulary$data = vocabulary.data) == null ? void 0 : (_vocabulary$data$item = _vocabulary$data.items) == null ? void 0 : _vocabulary$data$item.length) > 0) {
6122
+ var vocabularyValue = vocabulary.data.items.find(function (item) {
6123
+ return item.token === currentState;
6124
+ });
6125
+ console.log('state title', vocabularyValue, intl.locale);
6126
+
6127
+ if (vocabularyValue) {
6128
+ var translatedValue = get$1(vocabularyValue, "title.translated_title." + intl.locale, null);
6129
+
6130
+ if (translatedValue !== null) {
6131
+ return translatedValue;
6132
+ }
6133
+
6134
+ var titleValue = get$1(vocabularyValue, "title.title." + intl.locale, null);
6135
+
6136
+ if (titleValue !== null) {
6137
+ return titleValue;
6138
+ }
6139
+ }
6140
+ }
6141
+
6142
+ return currentState;
6143
+ };
6144
+
6145
+ console.log('Workflow log');
6122
6146
  if (definition === undefined) return null;
6123
6147
  return /*#__PURE__*/React.createElement(React.Fragment, null, workflowAction && /*#__PURE__*/React.createElement(Confirm, {
6124
6148
  loading: loading,
@@ -6135,8 +6159,8 @@ function IWorkflow() {
6135
6159
  className: "has-text-weight-bold",
6136
6160
  "data-test": "textInfoStatus-" + currentState
6137
6161
  }, intl.formatMessage(messages$1.current_state, {
6138
- state: currentState
6139
- }))), modifyContent && /*#__PURE__*/React.createElement("div", {
6162
+ state: getStateTitle()
6163
+ }))), modifyContent && definition.transitions.length > 0 && /*#__PURE__*/React.createElement("div", {
6140
6164
  className: " is-flex is-align-items-center has-text-weight-bold",
6141
6165
  "data-test": "textInfoStatus-" + currentState
6142
6166
  }, /*#__PURE__*/React.createElement("label", null, intl.formatMessage(messages$1.actions)), "\xA0\xA0", definition.transitions.map(function (transition) {
@@ -6146,7 +6170,7 @@ function IWorkflow() {
6146
6170
  onClick: function onClick() {
6147
6171
  return setWorkflowAction(transition['@id'].split('@workflow')[1].slice(1));
6148
6172
  }
6149
- }, transition.title);
6173
+ }, get$1(transition, "metadata.translated_title." + intl.locale, transition.title));
6150
6174
  })));
6151
6175
  }
6152
6176