@guillotinaweb/react-gmi 0.25.2 → 0.27.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 () {
@@ -3408,7 +3403,7 @@
3408
3403
 
3409
3404
  return /*#__PURE__*/React.createElement("div", {
3410
3405
  className: "control"
3411
- }, /*#__PURE__*/React.createElement("div", {
3406
+ }, (value != null ? value : []).length > 0 && /*#__PURE__*/React.createElement("div", {
3412
3407
  className: "tags"
3413
3408
  }, value.map(function (tag, index) {
3414
3409
  return /*#__PURE__*/React.createElement("div", {
@@ -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 () {
@@ -4590,7 +4583,9 @@
4590
4583
  }
4591
4584
  }
4592
4585
 
4593
- return /*#__PURE__*/React__default['default'].createElement(InputList, _extends({
4586
+ return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, rest.placeholder && /*#__PURE__*/React__default['default'].createElement("label", {
4587
+ className: "label"
4588
+ }, rest.placeholder), /*#__PURE__*/React__default['default'].createElement(InputList, _extends({
4594
4589
  value: val || [],
4595
4590
  className: className,
4596
4591
  onChange: function onChange(ev) {
@@ -4598,7 +4593,7 @@
4598
4593
  },
4599
4594
  ref: ref,
4600
4595
  dataTest: dataTest
4601
- }, rest));
4596
+ }, rest)));
4602
4597
  } else if ((schema == null ? void 0 : schema.widget) === 'file') {
4603
4598
  return /*#__PURE__*/React__default['default'].createElement(FileUpload, _extends({
4604
4599
  onChange: function onChange(ev) {
@@ -6095,6 +6090,7 @@
6095
6090
  setWorkflowAction = _React$useState2[1];
6096
6091
 
6097
6092
  var model = new ItemModel(Ctx.context);
6093
+ var vocabulary = useVocabulary('workflow_states');
6098
6094
  var currentState = model.item['guillotina.contrib.workflows.interfaces.IWorkflowBehavior']['review_state'];
6099
6095
  React__default['default'].useEffect(function () {
6100
6096
  loadDefinition();
@@ -6123,6 +6119,32 @@
6123
6119
  }
6124
6120
  };
6125
6121
 
6122
+ var getStateTitle = function getStateTitle() {
6123
+ var _vocabulary$data, _vocabulary$data$item;
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
+
6130
+ if (vocabularyValue) {
6131
+ var translatedValue = get$1(vocabularyValue, "title.translated_title." + intl.locale, null);
6132
+
6133
+ if (translatedValue !== null) {
6134
+ return translatedValue;
6135
+ }
6136
+
6137
+ var titleValue = get$1(vocabularyValue, "title.title." + intl.locale, null);
6138
+
6139
+ if (titleValue !== null) {
6140
+ return titleValue;
6141
+ }
6142
+ }
6143
+ }
6144
+
6145
+ return currentState;
6146
+ };
6147
+
6126
6148
  if (definition === undefined) return null;
6127
6149
  return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, workflowAction && /*#__PURE__*/React__default['default'].createElement(Confirm, {
6128
6150
  loading: loading,
@@ -6139,8 +6161,8 @@
6139
6161
  className: "has-text-weight-bold",
6140
6162
  "data-test": "textInfoStatus-" + currentState
6141
6163
  }, intl.formatMessage(messages$1.current_state, {
6142
- state: currentState
6143
- }))), modifyContent && /*#__PURE__*/React__default['default'].createElement("div", {
6164
+ state: getStateTitle()
6165
+ }))), modifyContent && definition.transitions.length > 0 && /*#__PURE__*/React__default['default'].createElement("div", {
6144
6166
  className: " is-flex is-align-items-center has-text-weight-bold",
6145
6167
  "data-test": "textInfoStatus-" + currentState
6146
6168
  }, /*#__PURE__*/React__default['default'].createElement("label", null, intl.formatMessage(messages$1.actions)), "\xA0\xA0", definition.transitions.map(function (transition) {
@@ -6150,7 +6172,7 @@
6150
6172
  onClick: function onClick() {
6151
6173
  return setWorkflowAction(transition['@id'].split('@workflow')[1].slice(1));
6152
6174
  }
6153
- }, transition.title);
6175
+ }, get$1(transition, "metadata.translated_title." + intl.locale, transition.title));
6154
6176
  })));
6155
6177
  }
6156
6178