@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.
package/dist/react-gmi.js CHANGED
@@ -3137,11 +3137,8 @@ var SearchInput = function SearchInput(_ref) {
3137
3137
  valueLabel = _useState[0],
3138
3138
  setValueLabel = _useState[1];
3139
3139
 
3140
- var _useState2 = React.useState(false),
3141
- setIsLoadingData = _useState2[1];
3142
-
3143
- var _useState3 = React.useState(generateUID('search_input')),
3144
- uid = _useState3[0];
3140
+ var _useState2 = React.useState(generateUID('search_input')),
3141
+ uid = _useState2[0];
3145
3142
 
3146
3143
  useClickAway(wrapperRef, function () {
3147
3144
  setIsOpen(false);
@@ -3167,7 +3164,6 @@ var SearchInput = function SearchInput(_ref) {
3167
3164
  try {
3168
3165
  var _temp2 = function () {
3169
3166
  if (labelProperty !== 'id' && value) {
3170
- setIsLoadingData(true);
3171
3167
  var searchTermQs = [];
3172
3168
  var searchTermParsed = ["id", value];
3173
3169
  var getSearch = traversal.registry.get;
@@ -3194,7 +3190,6 @@ var SearchInput = function SearchInput(_ref) {
3194
3190
  return result;
3195
3191
  }, {});
3196
3192
  setValueLabel(newValuesLabel);
3197
- setIsLoadingData(false);
3198
3193
  });
3199
3194
  }
3200
3195
  }();
@@ -3239,7 +3234,7 @@ var SearchInput = function SearchInput(_ref) {
3239
3234
  pageSize: PageSize,
3240
3235
  withDepth: false
3241
3236
  });
3242
- var sortParsed = parser("_sort_des=title");
3237
+ var sortParsed = parser("_sort_des=" + labelProperty);
3243
3238
  var typeNameParsed = [];
3244
3239
 
3245
3240
  if (typeNameQuery) {
@@ -3271,7 +3266,7 @@ var SearchInput = function SearchInput(_ref) {
3271
3266
  return renderTextItemOption(item);
3272
3267
  }
3273
3268
 
3274
- return item.title || item['@name'];
3269
+ return get$1(item, labelProperty, item.title) || item['@name'];
3275
3270
  };
3276
3271
 
3277
3272
  React.useEffect(function () {
@@ -3980,8 +3975,6 @@ var SearchRenderField = function SearchRenderField(_ref3) {
3980
3975
  }, [value]);
3981
3976
 
3982
3977
  var getRenderValue = function getRenderValue() {
3983
- console.log('get render values', value, valuesLabels);
3984
-
3985
3978
  if (value === undefined) {
3986
3979
  if (modifyContent) {
3987
3980
  return DEFAULT_VALUE_EDITABLE_FIELD;
@@ -4288,7 +4281,7 @@ var SearchInputList = function SearchInputList(_ref) {
4288
4281
  pageSize: PageSize,
4289
4282
  withDepth: false
4290
4283
  });
4291
- var sortParsed = parser("_sort_des=title");
4284
+ var sortParsed = parser("_sort_des=" + labelProperty);
4292
4285
  var typeNameParsed = [];
4293
4286
 
4294
4287
  if (typeNameQuery) {
@@ -4362,7 +4355,7 @@ var SearchInputList = function SearchInputList(_ref) {
4362
4355
  return renderTextItemOption(item);
4363
4356
  }
4364
4357
 
4365
- return item.title || item['@name'];
4358
+ return get$1(item, labelProperty, item.title) || item['@name'];
4366
4359
  };
4367
4360
 
4368
4361
  React__default['default'].useEffect(function () {
@@ -6098,6 +6091,7 @@ function IWorkflow() {
6098
6091
  setWorkflowAction = _React$useState2[1];
6099
6092
 
6100
6093
  var model = new ItemModel(Ctx.context);
6094
+ var vocabulary = useVocabulary('workflow_states');
6101
6095
  var currentState = model.item['guillotina.contrib.workflows.interfaces.IWorkflowBehavior']['review_state'];
6102
6096
  React__default['default'].useEffect(function () {
6103
6097
  loadDefinition();
@@ -6126,6 +6120,36 @@ function IWorkflow() {
6126
6120
  }
6127
6121
  };
6128
6122
 
6123
+ var getStateTitle = function getStateTitle() {
6124
+ var _vocabulary$data, _vocabulary$data$item;
6125
+
6126
+ console.log('getStateTitle', vocabulary);
6127
+
6128
+ if (((_vocabulary$data = vocabulary.data) == null ? void 0 : (_vocabulary$data$item = _vocabulary$data.items) == null ? void 0 : _vocabulary$data$item.length) > 0) {
6129
+ var vocabularyValue = vocabulary.data.items.find(function (item) {
6130
+ return item.token === currentState;
6131
+ });
6132
+ console.log('state title', vocabularyValue, intl.locale);
6133
+
6134
+ if (vocabularyValue) {
6135
+ var translatedValue = get$1(vocabularyValue, "title.translated_title." + intl.locale, null);
6136
+
6137
+ if (translatedValue !== null) {
6138
+ return translatedValue;
6139
+ }
6140
+
6141
+ var titleValue = get$1(vocabularyValue, "title.title." + intl.locale, null);
6142
+
6143
+ if (titleValue !== null) {
6144
+ return titleValue;
6145
+ }
6146
+ }
6147
+ }
6148
+
6149
+ return currentState;
6150
+ };
6151
+
6152
+ console.log('Workflow log');
6129
6153
  if (definition === undefined) return null;
6130
6154
  return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, workflowAction && /*#__PURE__*/React__default['default'].createElement(Confirm, {
6131
6155
  loading: loading,
@@ -6142,8 +6166,8 @@ function IWorkflow() {
6142
6166
  className: "has-text-weight-bold",
6143
6167
  "data-test": "textInfoStatus-" + currentState
6144
6168
  }, intl.formatMessage(messages$1.current_state, {
6145
- state: currentState
6146
- }))), modifyContent && /*#__PURE__*/React__default['default'].createElement("div", {
6169
+ state: getStateTitle()
6170
+ }))), modifyContent && definition.transitions.length > 0 && /*#__PURE__*/React__default['default'].createElement("div", {
6147
6171
  className: " is-flex is-align-items-center has-text-weight-bold",
6148
6172
  "data-test": "textInfoStatus-" + currentState
6149
6173
  }, /*#__PURE__*/React__default['default'].createElement("label", null, intl.formatMessage(messages$1.actions)), "\xA0\xA0", definition.transitions.map(function (transition) {
@@ -6153,7 +6177,7 @@ function IWorkflow() {
6153
6177
  onClick: function onClick() {
6154
6178
  return setWorkflowAction(transition['@id'].split('@workflow')[1].slice(1));
6155
6179
  }
6156
- }, transition.title);
6180
+ }, get$1(transition, "metadata.translated_title." + intl.locale, transition.title));
6157
6181
  })));
6158
6182
  }
6159
6183