@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.
@@ -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 () {
@@ -3404,7 +3399,7 @@ var InputList = forwardRef(function (_ref, ref) {
3404
3399
 
3405
3400
  return /*#__PURE__*/createElement("div", {
3406
3401
  className: "control"
3407
- }, /*#__PURE__*/createElement("div", {
3402
+ }, (value != null ? value : []).length > 0 && /*#__PURE__*/createElement("div", {
3408
3403
  className: "tags"
3409
3404
  }, value.map(function (tag, index) {
3410
3405
  return /*#__PURE__*/createElement("div", {
@@ -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 () {
@@ -4586,7 +4579,9 @@ var EditComponent = React.forwardRef(function (_ref, ref) {
4586
4579
  }
4587
4580
  }
4588
4581
 
4589
- return /*#__PURE__*/React.createElement(InputList, _extends({
4582
+ return /*#__PURE__*/React.createElement(React.Fragment, null, rest.placeholder && /*#__PURE__*/React.createElement("label", {
4583
+ className: "label"
4584
+ }, rest.placeholder), /*#__PURE__*/React.createElement(InputList, _extends({
4590
4585
  value: val || [],
4591
4586
  className: className,
4592
4587
  onChange: function onChange(ev) {
@@ -4594,7 +4589,7 @@ var EditComponent = React.forwardRef(function (_ref, ref) {
4594
4589
  },
4595
4590
  ref: ref,
4596
4591
  dataTest: dataTest
4597
- }, rest));
4592
+ }, rest)));
4598
4593
  } else if ((schema == null ? void 0 : schema.widget) === 'file') {
4599
4594
  return /*#__PURE__*/React.createElement(FileUpload, _extends({
4600
4595
  onChange: function onChange(ev) {
@@ -6091,6 +6086,7 @@ function IWorkflow() {
6091
6086
  setWorkflowAction = _React$useState2[1];
6092
6087
 
6093
6088
  var model = new ItemModel(Ctx.context);
6089
+ var vocabulary = useVocabulary('workflow_states');
6094
6090
  var currentState = model.item['guillotina.contrib.workflows.interfaces.IWorkflowBehavior']['review_state'];
6095
6091
  React.useEffect(function () {
6096
6092
  loadDefinition();
@@ -6119,6 +6115,32 @@ function IWorkflow() {
6119
6115
  }
6120
6116
  };
6121
6117
 
6118
+ var getStateTitle = function getStateTitle() {
6119
+ var _vocabulary$data, _vocabulary$data$item;
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
+
6126
+ if (vocabularyValue) {
6127
+ var translatedValue = get$1(vocabularyValue, "title.translated_title." + intl.locale, null);
6128
+
6129
+ if (translatedValue !== null) {
6130
+ return translatedValue;
6131
+ }
6132
+
6133
+ var titleValue = get$1(vocabularyValue, "title.title." + intl.locale, null);
6134
+
6135
+ if (titleValue !== null) {
6136
+ return titleValue;
6137
+ }
6138
+ }
6139
+ }
6140
+
6141
+ return currentState;
6142
+ };
6143
+
6122
6144
  if (definition === undefined) return null;
6123
6145
  return /*#__PURE__*/React.createElement(React.Fragment, null, workflowAction && /*#__PURE__*/React.createElement(Confirm, {
6124
6146
  loading: loading,
@@ -6135,8 +6157,8 @@ function IWorkflow() {
6135
6157
  className: "has-text-weight-bold",
6136
6158
  "data-test": "textInfoStatus-" + currentState
6137
6159
  }, intl.formatMessage(messages$1.current_state, {
6138
- state: currentState
6139
- }))), modifyContent && /*#__PURE__*/React.createElement("div", {
6160
+ state: getStateTitle()
6161
+ }))), modifyContent && definition.transitions.length > 0 && /*#__PURE__*/React.createElement("div", {
6140
6162
  className: " is-flex is-align-items-center has-text-weight-bold",
6141
6163
  "data-test": "textInfoStatus-" + currentState
6142
6164
  }, /*#__PURE__*/React.createElement("label", null, intl.formatMessage(messages$1.actions)), "\xA0\xA0", definition.transitions.map(function (transition) {
@@ -6146,7 +6168,7 @@ function IWorkflow() {
6146
6168
  onClick: function onClick() {
6147
6169
  return setWorkflowAction(transition['@id'].split('@workflow')[1].slice(1));
6148
6170
  }
6149
- }, transition.title);
6171
+ }, get$1(transition, "metadata.translated_title." + intl.locale, transition.title));
6150
6172
  })));
6151
6173
  }
6152
6174