@guillotinaweb/react-gmi 0.24.0 → 0.25.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/components/fields/renderField.d.ts +12 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/input/search_input.d.ts +14 -3
- package/dist/components/input/search_input_list.d.ts +35 -0
- package/dist/react-gmi.esm.js +948 -333
- package/dist/react-gmi.esm.js.map +1 -1
- package/dist/react-gmi.js +950 -332
- package/dist/react-gmi.js.map +1 -1
- package/dist/react-gmi.modern.js +846 -310
- package/dist/react-gmi.modern.js.map +1 -1
- package/dist/react-gmi.umd.js +950 -332
- package/dist/react-gmi.umd.js.map +1 -1
- package/package.json +2 -1
package/dist/react-gmi.esm.js
CHANGED
|
@@ -3017,6 +3017,45 @@ var Textarea = React.forwardRef(function (_ref, ref) {
|
|
|
3017
3017
|
}, error ? error : ''));
|
|
3018
3018
|
});
|
|
3019
3019
|
|
|
3020
|
+
var defaultEvents = ['mousedown', 'touchstart'];
|
|
3021
|
+
|
|
3022
|
+
var on = function on(obj) {
|
|
3023
|
+
return obj.addEventListener.apply(obj, [].slice.call(arguments, 1));
|
|
3024
|
+
};
|
|
3025
|
+
|
|
3026
|
+
var off = function off(obj) {
|
|
3027
|
+
return obj.removeEventListener.apply(obj, [].slice.call(arguments, 1));
|
|
3028
|
+
};
|
|
3029
|
+
|
|
3030
|
+
function useClickAway(ref, onClickAway, events) {
|
|
3031
|
+
if (events === void 0) {
|
|
3032
|
+
events = defaultEvents;
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
var savedCallback = useRef(onClickAway);
|
|
3036
|
+
useEffect(function () {
|
|
3037
|
+
savedCallback.current = onClickAway;
|
|
3038
|
+
}, [onClickAway]);
|
|
3039
|
+
useEffect(function () {
|
|
3040
|
+
var handler = function handler(event) {
|
|
3041
|
+
var el = ref.current;
|
|
3042
|
+
el && !el.contains(event.target) && savedCallback.current(event);
|
|
3043
|
+
};
|
|
3044
|
+
|
|
3045
|
+
for (var _iterator = _createForOfIteratorHelperLoose(events), _step; !(_step = _iterator()).done;) {
|
|
3046
|
+
var eventName = _step.value;
|
|
3047
|
+
on(document, eventName, handler);
|
|
3048
|
+
}
|
|
3049
|
+
|
|
3050
|
+
return function () {
|
|
3051
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(events), _step2; !(_step2 = _iterator2()).done;) {
|
|
3052
|
+
var eventName = _step2.value;
|
|
3053
|
+
off(document, eventName, handler);
|
|
3054
|
+
}
|
|
3055
|
+
};
|
|
3056
|
+
}, [events, ref]);
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3020
3059
|
function debounce(func, wait) {
|
|
3021
3060
|
var timeout;
|
|
3022
3061
|
return function () {
|
|
@@ -3061,7 +3100,11 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3061
3100
|
_ref$dataTestItem = _ref.dataTestItem,
|
|
3062
3101
|
dataTestItem = _ref$dataTestItem === void 0 ? 'searchInputItemTest' : _ref$dataTestItem,
|
|
3063
3102
|
_ref$renderTextItemOp = _ref.renderTextItemOption,
|
|
3064
|
-
renderTextItemOption = _ref$renderTextItemOp === void 0 ? null : _ref$renderTextItemOp
|
|
3103
|
+
renderTextItemOption = _ref$renderTextItemOp === void 0 ? null : _ref$renderTextItemOp,
|
|
3104
|
+
_ref$typeNameQuery = _ref.typeNameQuery,
|
|
3105
|
+
typeNameQuery = _ref$typeNameQuery === void 0 ? null : _ref$typeNameQuery,
|
|
3106
|
+
_ref$labelProperty = _ref.labelProperty,
|
|
3107
|
+
labelProperty = _ref$labelProperty === void 0 ? 'id' : _ref$labelProperty;
|
|
3065
3108
|
var intl = useIntl();
|
|
3066
3109
|
|
|
3067
3110
|
var _useSetState = useSetState(initialState),
|
|
@@ -3083,8 +3126,19 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3083
3126
|
PageSize = _useConfig.PageSize,
|
|
3084
3127
|
SearchEngine = _useConfig.SearchEngine;
|
|
3085
3128
|
|
|
3086
|
-
var _useState = useState(
|
|
3087
|
-
|
|
3129
|
+
var _useState = useState(undefined),
|
|
3130
|
+
valueLabel = _useState[0],
|
|
3131
|
+
setValueLabel = _useState[1];
|
|
3132
|
+
|
|
3133
|
+
var _useState2 = useState(false),
|
|
3134
|
+
setIsLoadingData = _useState2[1];
|
|
3135
|
+
|
|
3136
|
+
var _useState3 = useState(generateUID('search_input')),
|
|
3137
|
+
uid = _useState3[0];
|
|
3138
|
+
|
|
3139
|
+
useClickAway(wrapperRef, function () {
|
|
3140
|
+
setIsOpen(false);
|
|
3141
|
+
});
|
|
3088
3142
|
|
|
3089
3143
|
var getHeight = function getHeight() {
|
|
3090
3144
|
if (wrapperRef && wrapperRef.current) {
|
|
@@ -3098,10 +3152,52 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3098
3152
|
};
|
|
3099
3153
|
};
|
|
3100
3154
|
|
|
3101
|
-
var delayedQuery =
|
|
3155
|
+
var delayedQuery = useCallback(debounce(function (value) {
|
|
3102
3156
|
return handleSearch(0, false, value);
|
|
3103
3157
|
}, 500), []);
|
|
3104
3158
|
|
|
3159
|
+
var inicializeLabels = function inicializeLabels() {
|
|
3160
|
+
try {
|
|
3161
|
+
var _temp2 = function () {
|
|
3162
|
+
if (labelProperty !== 'id' && value) {
|
|
3163
|
+
setIsLoadingData(true);
|
|
3164
|
+
var searchTermQs = [];
|
|
3165
|
+
var searchTermParsed = ["id", value];
|
|
3166
|
+
var getSearch = traversal.registry.get;
|
|
3167
|
+
var fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
|
|
3168
|
+
var qsParsed = traversal.client[fnName]({
|
|
3169
|
+
path: traversal.path,
|
|
3170
|
+
start: 0,
|
|
3171
|
+
pageSize: PageSize,
|
|
3172
|
+
withDepth: false
|
|
3173
|
+
});
|
|
3174
|
+
var typeNameParsed = [];
|
|
3175
|
+
|
|
3176
|
+
if (typeNameQuery) {
|
|
3177
|
+
typeNameParsed = parser("type_name__in=" + typeNameQuery);
|
|
3178
|
+
}
|
|
3179
|
+
|
|
3180
|
+
if (qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
|
|
3181
|
+
searchTermQs = buildQs([].concat(qs, [searchTermParsed], qsParsed, typeNameParsed));
|
|
3182
|
+
}
|
|
3183
|
+
|
|
3184
|
+
return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false)).then(function (data) {
|
|
3185
|
+
var newValuesLabel = data.items.reduce(function (result, item) {
|
|
3186
|
+
result[item.id] = get$1(item, labelProperty, item.id);
|
|
3187
|
+
return result;
|
|
3188
|
+
}, {});
|
|
3189
|
+
setValueLabel(newValuesLabel);
|
|
3190
|
+
setIsLoadingData(false);
|
|
3191
|
+
});
|
|
3192
|
+
}
|
|
3193
|
+
}();
|
|
3194
|
+
|
|
3195
|
+
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
|
|
3196
|
+
} catch (e) {
|
|
3197
|
+
return Promise.reject(e);
|
|
3198
|
+
}
|
|
3199
|
+
};
|
|
3200
|
+
|
|
3105
3201
|
var handleSearch = function handleSearch(page, concat, value) {
|
|
3106
3202
|
if (page === void 0) {
|
|
3107
3203
|
page = 0;
|
|
@@ -3126,19 +3222,28 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3126
3222
|
searchTermParsed = parser(queryCondition + "=" + value);
|
|
3127
3223
|
}
|
|
3128
3224
|
|
|
3129
|
-
var
|
|
3130
|
-
|
|
3225
|
+
var _get = traversal.registry.get;
|
|
3226
|
+
|
|
3227
|
+
var fnName = _get('searchEngineQueryParamsFunction', SearchEngine);
|
|
3228
|
+
|
|
3131
3229
|
var qsParsed = traversal.client[fnName]({
|
|
3132
3230
|
path: traversal.path,
|
|
3133
3231
|
start: page * PageSize,
|
|
3134
|
-
pageSize: PageSize
|
|
3232
|
+
pageSize: PageSize,
|
|
3233
|
+
withDepth: false
|
|
3135
3234
|
});
|
|
3235
|
+
var sortParsed = parser("_sort_des=title");
|
|
3236
|
+
var typeNameParsed = [];
|
|
3237
|
+
|
|
3238
|
+
if (typeNameQuery) {
|
|
3239
|
+
typeNameParsed = parser("type_name__in=" + typeNameQuery);
|
|
3240
|
+
}
|
|
3136
3241
|
|
|
3137
|
-
if (qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0) {
|
|
3138
|
-
searchTermQs = buildQs([].concat(qs, searchTermParsed, qsParsed));
|
|
3242
|
+
if (qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
|
|
3243
|
+
searchTermQs = buildQs([].concat(qs, searchTermParsed, qsParsed, typeNameParsed, sortParsed));
|
|
3139
3244
|
}
|
|
3140
3245
|
|
|
3141
|
-
return Promise.resolve(traversal.client.search(path, searchTermQs, false, false
|
|
3246
|
+
return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false)).then(function (data) {
|
|
3142
3247
|
var _data$items_total;
|
|
3143
3248
|
|
|
3144
3249
|
var newItems = options.items && concat ? [].concat(options.items, data.items) : data.items;
|
|
@@ -3162,20 +3267,24 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3162
3267
|
return item.title || item['@name'];
|
|
3163
3268
|
};
|
|
3164
3269
|
|
|
3165
|
-
|
|
3166
|
-
if (
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
} catch (e) {
|
|
3171
|
-
Promise.reject(e);
|
|
3172
|
-
}
|
|
3270
|
+
useEffect(function () {
|
|
3271
|
+
if (value) {
|
|
3272
|
+
inicializeLabels();
|
|
3273
|
+
} else {
|
|
3274
|
+
setValueLabel({});
|
|
3173
3275
|
}
|
|
3174
|
-
}, [path,
|
|
3276
|
+
}, [path, value]);
|
|
3277
|
+
|
|
3278
|
+
if (valueLabel === undefined) {
|
|
3279
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
3280
|
+
className: "spinner"
|
|
3281
|
+
});
|
|
3282
|
+
}
|
|
3283
|
+
|
|
3175
3284
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
3176
3285
|
"data-test": dataTestWrapper,
|
|
3177
3286
|
ref: wrapperRef,
|
|
3178
|
-
className: "dropdown " + (isOpen ? 'is-active' : ''),
|
|
3287
|
+
className: "dropdown mb-2 " + (isOpen ? 'is-active' : ''),
|
|
3179
3288
|
onBlur: function onBlur(ev) {
|
|
3180
3289
|
if (!ev.currentTarget.contains(ev.relatedTarget)) {
|
|
3181
3290
|
if (searchTerm !== '') {
|
|
@@ -3183,7 +3292,7 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3183
3292
|
setOptions(initialState);
|
|
3184
3293
|
}
|
|
3185
3294
|
|
|
3186
|
-
setIsOpen(
|
|
3295
|
+
setIsOpen(false);
|
|
3187
3296
|
}
|
|
3188
3297
|
}
|
|
3189
3298
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -3191,12 +3300,16 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3191
3300
|
}, /*#__PURE__*/React.createElement("button", {
|
|
3192
3301
|
className: "button " + btnClass,
|
|
3193
3302
|
onClick: function onClick(ev) {
|
|
3194
|
-
ev.
|
|
3303
|
+
ev.target.blur();
|
|
3195
3304
|
setIsOpen(!isOpen);
|
|
3305
|
+
|
|
3306
|
+
if (!options.loading && !options.items) {
|
|
3307
|
+
handleSearch(options.page);
|
|
3308
|
+
}
|
|
3196
3309
|
},
|
|
3197
3310
|
"aria-haspopup": "true",
|
|
3198
3311
|
"aria-controls": "dropdown-menu"
|
|
3199
|
-
}, /*#__PURE__*/React.createElement("span", null, value
|
|
3312
|
+
}, /*#__PURE__*/React.createElement("span", null, value ? get$1(valueLabel, value, value) : intl.formatMessage(genericMessages.choose)), /*#__PURE__*/React.createElement("span", {
|
|
3200
3313
|
className: "icon"
|
|
3201
3314
|
}, /*#__PURE__*/React.createElement("i", {
|
|
3202
3315
|
className: "fas fa-angle-down",
|
|
@@ -3224,12 +3337,16 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3224
3337
|
})), /*#__PURE__*/React.createElement("hr", {
|
|
3225
3338
|
className: "dropdown-divider"
|
|
3226
3339
|
}), options.loading && /*#__PURE__*/React.createElement(Loading, null), options.items && options.items.map(function (item) {
|
|
3227
|
-
return /*#__PURE__*/React.createElement("
|
|
3228
|
-
|
|
3229
|
-
className: "dropdown-item editable " + (value && value.id === item.id ? 'is-active' : ''),
|
|
3340
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
3341
|
+
className: "dropdown-item editable " + (value === item.id ? 'is-active' : ''),
|
|
3230
3342
|
"data-test": dataTestItem + "-" + item.id,
|
|
3231
|
-
onMouseDown: function onMouseDown() {
|
|
3232
|
-
|
|
3343
|
+
onMouseDown: function onMouseDown(ev) {
|
|
3344
|
+
ev.preventDefault();
|
|
3345
|
+
|
|
3346
|
+
if (onChange) {
|
|
3347
|
+
onChange(item.id);
|
|
3348
|
+
}
|
|
3349
|
+
|
|
3233
3350
|
setIsOpen(false);
|
|
3234
3351
|
},
|
|
3235
3352
|
key: item.path
|
|
@@ -3252,11 +3369,20 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3252
3369
|
};
|
|
3253
3370
|
SearchInput.propTypes = {
|
|
3254
3371
|
onChange: PropTypes.func,
|
|
3255
|
-
value: PropTypes.
|
|
3256
|
-
client: PropTypes.object,
|
|
3372
|
+
value: PropTypes.string,
|
|
3257
3373
|
path: PropTypes.string,
|
|
3258
|
-
|
|
3259
|
-
|
|
3374
|
+
btnClass: PropTypes.string,
|
|
3375
|
+
error: PropTypes.string,
|
|
3376
|
+
errorZoneClassName: PropTypes.string,
|
|
3377
|
+
traversal: PropTypes.object,
|
|
3378
|
+
qs: PropTypes.array,
|
|
3379
|
+
queryCondition: PropTypes.string,
|
|
3380
|
+
dataTestWrapper: PropTypes.string,
|
|
3381
|
+
dataTestSearchInput: PropTypes.string,
|
|
3382
|
+
dataTestItem: PropTypes.string,
|
|
3383
|
+
renderTextItemOption: PropTypes.func,
|
|
3384
|
+
typeNameQuery: PropTypes.string,
|
|
3385
|
+
labelProperty: PropTypes.string
|
|
3260
3386
|
};
|
|
3261
3387
|
|
|
3262
3388
|
var InputList = forwardRef(function (_ref, ref) {
|
|
@@ -3315,45 +3441,6 @@ var InputList = forwardRef(function (_ref, ref) {
|
|
|
3315
3441
|
}));
|
|
3316
3442
|
});
|
|
3317
3443
|
|
|
3318
|
-
var defaultEvents = ['mousedown', 'touchstart'];
|
|
3319
|
-
|
|
3320
|
-
var on = function on(obj) {
|
|
3321
|
-
return obj.addEventListener.apply(obj, [].slice.call(arguments, 1));
|
|
3322
|
-
};
|
|
3323
|
-
|
|
3324
|
-
var off = function off(obj) {
|
|
3325
|
-
return obj.removeEventListener.apply(obj, [].slice.call(arguments, 1));
|
|
3326
|
-
};
|
|
3327
|
-
|
|
3328
|
-
function useClickAway(ref, onClickAway, events) {
|
|
3329
|
-
if (events === void 0) {
|
|
3330
|
-
events = defaultEvents;
|
|
3331
|
-
}
|
|
3332
|
-
|
|
3333
|
-
var savedCallback = useRef(onClickAway);
|
|
3334
|
-
useEffect(function () {
|
|
3335
|
-
savedCallback.current = onClickAway;
|
|
3336
|
-
}, [onClickAway]);
|
|
3337
|
-
useEffect(function () {
|
|
3338
|
-
var handler = function handler(event) {
|
|
3339
|
-
var el = ref.current;
|
|
3340
|
-
el && !el.contains(event.target) && savedCallback.current(event);
|
|
3341
|
-
};
|
|
3342
|
-
|
|
3343
|
-
for (var _iterator = _createForOfIteratorHelperLoose(events), _step; !(_step = _iterator()).done;) {
|
|
3344
|
-
var eventName = _step.value;
|
|
3345
|
-
on(document, eventName, handler);
|
|
3346
|
-
}
|
|
3347
|
-
|
|
3348
|
-
return function () {
|
|
3349
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose(events), _step2; !(_step2 = _iterator2()).done;) {
|
|
3350
|
-
var eventName = _step2.value;
|
|
3351
|
-
off(document, eventName, handler);
|
|
3352
|
-
}
|
|
3353
|
-
};
|
|
3354
|
-
}, [events, ref]);
|
|
3355
|
-
}
|
|
3356
|
-
|
|
3357
3444
|
function Dropdown(_ref) {
|
|
3358
3445
|
var children = _ref.children,
|
|
3359
3446
|
disabled = _ref.disabled,
|
|
@@ -3755,12 +3842,14 @@ function useVocabulary(vocabularyName, path) {
|
|
|
3755
3842
|
var plain = ['string', 'number', 'boolean'];
|
|
3756
3843
|
function RenderField(_ref) {
|
|
3757
3844
|
var value = _ref.value,
|
|
3758
|
-
Widget = _ref.Widget
|
|
3845
|
+
Widget = _ref.Widget,
|
|
3846
|
+
schema = _ref.schema;
|
|
3759
3847
|
if (value === null || value === undefined) return '';
|
|
3760
3848
|
|
|
3761
3849
|
if (Widget) {
|
|
3762
3850
|
return /*#__PURE__*/React.createElement(Widget, {
|
|
3763
|
-
value: value
|
|
3851
|
+
value: value,
|
|
3852
|
+
schema: schema
|
|
3764
3853
|
});
|
|
3765
3854
|
}
|
|
3766
3855
|
|
|
@@ -3807,23 +3896,154 @@ var FieldValue = function FieldValue(_ref2) {
|
|
|
3807
3896
|
})));
|
|
3808
3897
|
};
|
|
3809
3898
|
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
modifyContent = _ref3.modifyContent;
|
|
3815
|
-
var intl = useIntl();
|
|
3816
|
-
var DEFAULT_VALUE_EDITABLE_FIELD = intl.formatMessage({
|
|
3899
|
+
var DEFAULT_VALUE_NO_EDITABLE_FIELD = ' -- ';
|
|
3900
|
+
|
|
3901
|
+
var getDefaultValueEditableField = function getDefaultValueEditableField(intl) {
|
|
3902
|
+
return intl.formatMessage({
|
|
3817
3903
|
id: "default_value_editable_field",
|
|
3818
3904
|
defaultMessage: [{
|
|
3819
3905
|
"type": 0,
|
|
3820
3906
|
"value": "Click to edit"
|
|
3821
3907
|
}]
|
|
3822
3908
|
});
|
|
3823
|
-
|
|
3909
|
+
};
|
|
3910
|
+
|
|
3911
|
+
var SearchRenderField = function SearchRenderField(_ref3) {
|
|
3912
|
+
var schema = _ref3.schema,
|
|
3913
|
+
value = _ref3.value,
|
|
3914
|
+
modifyContent = _ref3.modifyContent;
|
|
3915
|
+
|
|
3916
|
+
var _useState = useState([]),
|
|
3917
|
+
valuesLabels = _useState[0],
|
|
3918
|
+
setValuesLabels = _useState[1];
|
|
3919
|
+
|
|
3920
|
+
var _useState2 = useState(false),
|
|
3921
|
+
isLoadingData = _useState2[0],
|
|
3922
|
+
setIsLoadingData = _useState2[1];
|
|
3923
|
+
|
|
3924
|
+
var traversal = useTraversal();
|
|
3925
|
+
|
|
3926
|
+
var _useConfig = useConfig(),
|
|
3927
|
+
SearchEngine = _useConfig.SearchEngine;
|
|
3928
|
+
|
|
3929
|
+
useEffect(function () {
|
|
3930
|
+
var fetchData = function fetchData(valuesToSearch) {
|
|
3931
|
+
try {
|
|
3932
|
+
setIsLoadingData(true);
|
|
3933
|
+
var searchTermQs = [];
|
|
3934
|
+
var searchTermParsed = ['__or', "id=" + valuesToSearch.join('%26id=')];
|
|
3935
|
+
var getSearch = traversal.registry.get;
|
|
3936
|
+
var fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
|
|
3937
|
+
var qsParsed = traversal.client[fnName]({
|
|
3938
|
+
path: traversal.path,
|
|
3939
|
+
start: 0,
|
|
3940
|
+
pageSize: 100,
|
|
3941
|
+
withDepth: false
|
|
3942
|
+
});
|
|
3943
|
+
|
|
3944
|
+
if (searchTermParsed.length > 0 || qsParsed.length > 0) {
|
|
3945
|
+
searchTermQs = buildQs([searchTermParsed].concat(qsParsed));
|
|
3946
|
+
}
|
|
3947
|
+
|
|
3948
|
+
return Promise.resolve(traversal.client.search(traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false, 0, 100)).then(function (data) {
|
|
3949
|
+
var newValuesLabel = data.items.map(function (item) {
|
|
3950
|
+
var _schema$labelProperty;
|
|
3951
|
+
|
|
3952
|
+
return get$1(item, (_schema$labelProperty = schema == null ? void 0 : schema.labelProperty) != null ? _schema$labelProperty : 'title', item.id);
|
|
3953
|
+
});
|
|
3954
|
+
setValuesLabels(newValuesLabel);
|
|
3955
|
+
setIsLoadingData(false);
|
|
3956
|
+
});
|
|
3957
|
+
} catch (e) {
|
|
3958
|
+
return Promise.reject(e);
|
|
3959
|
+
}
|
|
3960
|
+
};
|
|
3961
|
+
|
|
3962
|
+
var valuesToSearch = value;
|
|
3963
|
+
|
|
3964
|
+
if (typeof valuesToSearch === 'string') {
|
|
3965
|
+
valuesToSearch = [valuesToSearch];
|
|
3966
|
+
}
|
|
3967
|
+
|
|
3968
|
+
if (valuesToSearch !== undefined && valuesToSearch.length > 0) {
|
|
3969
|
+
fetchData(valuesToSearch);
|
|
3970
|
+
} else {
|
|
3971
|
+
setValuesLabels([]);
|
|
3972
|
+
}
|
|
3973
|
+
}, [value]);
|
|
3974
|
+
|
|
3975
|
+
var getRenderValue = function getRenderValue() {
|
|
3976
|
+
console.log('get render values', value, valuesLabels);
|
|
3977
|
+
|
|
3978
|
+
if (value === undefined) {
|
|
3979
|
+
if (modifyContent) {
|
|
3980
|
+
return DEFAULT_VALUE_EDITABLE_FIELD;
|
|
3981
|
+
}
|
|
3982
|
+
|
|
3983
|
+
return DEFAULT_VALUE_NO_EDITABLE_FIELD;
|
|
3984
|
+
}
|
|
3985
|
+
|
|
3986
|
+
if (isLoadingData) {
|
|
3987
|
+
return 'Loading...';
|
|
3988
|
+
}
|
|
3989
|
+
|
|
3990
|
+
return valuesLabels;
|
|
3991
|
+
};
|
|
3992
|
+
|
|
3993
|
+
return /*#__PURE__*/React.createElement(RenderField, {
|
|
3994
|
+
value: getRenderValue()
|
|
3995
|
+
});
|
|
3996
|
+
};
|
|
3997
|
+
var VocabularyRenderField = function VocabularyRenderField(_ref4) {
|
|
3998
|
+
var _schema$items;
|
|
3999
|
+
|
|
4000
|
+
var schema = _ref4.schema,
|
|
4001
|
+
value = _ref4.value,
|
|
4002
|
+
modifyContent = _ref4.modifyContent;
|
|
4003
|
+
var intl = useIntl();
|
|
4004
|
+
var DEFAULT_VALUE_EDITABLE_FIELD = getDefaultValueEditableField(intl);
|
|
4005
|
+
var vocabularyName = (schema == null ? void 0 : (_schema$items = schema.items) == null ? void 0 : _schema$items.vocabularyName) || (schema == null ? void 0 : schema.vocabularyName);
|
|
4006
|
+
var vocabulary = useVocabulary(vocabularyName);
|
|
4007
|
+
|
|
4008
|
+
var getRenderProps = function getRenderProps() {
|
|
4009
|
+
var renderProps = {
|
|
4010
|
+
value: value != null ? value : modifyContent ? DEFAULT_VALUE_EDITABLE_FIELD : DEFAULT_VALUE_NO_EDITABLE_FIELD
|
|
4011
|
+
};
|
|
4012
|
+
|
|
4013
|
+
if (schema != null && schema.vocabularyName) {
|
|
4014
|
+
var _vocabularyValue$titl;
|
|
4015
|
+
|
|
4016
|
+
var vocabularyValue = get$1(vocabulary, 'data.items', []).find(function (item) {
|
|
4017
|
+
return item.token === value;
|
|
4018
|
+
});
|
|
4019
|
+
renderProps['value'] = (_vocabularyValue$titl = vocabularyValue == null ? void 0 : vocabularyValue.title) != null ? _vocabularyValue$titl : '';
|
|
4020
|
+
} else {
|
|
4021
|
+
var _renderProps$value;
|
|
4022
|
+
|
|
4023
|
+
renderProps['value'] = ((_renderProps$value = renderProps['value']) != null ? _renderProps$value : []).map(function (value) {
|
|
4024
|
+
var _get$find$title, _get$find;
|
|
4025
|
+
|
|
4026
|
+
return (_get$find$title = (_get$find = get$1(vocabulary, 'data.items', []).find(function (item) {
|
|
4027
|
+
return item.token === value;
|
|
4028
|
+
})) == null ? void 0 : _get$find.title) != null ? _get$find$title : '';
|
|
4029
|
+
});
|
|
4030
|
+
}
|
|
4031
|
+
|
|
4032
|
+
return renderProps;
|
|
4033
|
+
};
|
|
4034
|
+
|
|
4035
|
+
return /*#__PURE__*/React.createElement(RenderField, getRenderProps());
|
|
4036
|
+
};
|
|
4037
|
+
function RenderFieldComponent(_ref5) {
|
|
4038
|
+
var schema = _ref5.schema,
|
|
4039
|
+
field = _ref5.field,
|
|
4040
|
+
val = _ref5.val,
|
|
4041
|
+
modifyContent = _ref5.modifyContent;
|
|
4042
|
+
var intl = useIntl();
|
|
4043
|
+
var DEFAULT_VALUE_EDITABLE_FIELD = getDefaultValueEditableField(intl);
|
|
3824
4044
|
|
|
3825
4045
|
var getRenderProps = function getRenderProps() {
|
|
3826
|
-
var _schema$
|
|
4046
|
+
var _schema$items2;
|
|
3827
4047
|
|
|
3828
4048
|
var renderProps = {
|
|
3829
4049
|
value: val != null ? val : modifyContent ? DEFAULT_VALUE_EDITABLE_FIELD : DEFAULT_VALUE_NO_EDITABLE_FIELD
|
|
@@ -3841,50 +4061,622 @@ function RenderFieldComponent(_ref3) {
|
|
|
3841
4061
|
renderProps['value'] = (_val$toString = val == null ? void 0 : val.toString()) != null ? _val$toString : renderProps['value'];
|
|
3842
4062
|
} else if (val && (schema == null ? void 0 : schema.type) === 'datetime') {
|
|
3843
4063
|
renderProps['value'] = new Date(val).toLocaleString();
|
|
3844
|
-
} else if (schema != null && (_schema$
|
|
3845
|
-
|
|
4064
|
+
} else if (schema != null && (_schema$items2 = schema.items) != null && _schema$items2.vocabularyName || schema != null && schema.vocabularyName) {
|
|
4065
|
+
renderProps['Widget'] = VocabularyRenderField;
|
|
4066
|
+
renderProps['schema'] = schema;
|
|
4067
|
+
} else if ((schema == null ? void 0 : schema.widget) === 'search' || (schema == null ? void 0 : schema.widget) === 'search_list') {
|
|
4068
|
+
renderProps['Widget'] = SearchRenderField;
|
|
4069
|
+
renderProps['value'] = val;
|
|
4070
|
+
renderProps['schema'] = schema;
|
|
4071
|
+
}
|
|
3846
4072
|
|
|
3847
|
-
|
|
3848
|
-
|
|
4073
|
+
return renderProps;
|
|
4074
|
+
};
|
|
3849
4075
|
|
|
3850
|
-
|
|
3851
|
-
|
|
4076
|
+
return /*#__PURE__*/React.createElement(RenderField, getRenderProps());
|
|
4077
|
+
}
|
|
3852
4078
|
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
4079
|
+
var SelectVocabulary = React.forwardRef(function (_ref, ref) {
|
|
4080
|
+
var vocabularyName = _ref.vocabularyName,
|
|
4081
|
+
className = _ref.className,
|
|
4082
|
+
classWrap = _ref.classWrap,
|
|
4083
|
+
val = _ref.val,
|
|
4084
|
+
dataTest = _ref.dataTest,
|
|
4085
|
+
multiple = _ref.multiple,
|
|
4086
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["vocabularyName", "className", "classWrap", "val", "dataTest", "multiple"]);
|
|
3859
4087
|
|
|
3860
|
-
|
|
3861
|
-
var _get$find$title, _get$find;
|
|
4088
|
+
var vocabulary = useVocabulary(vocabularyName);
|
|
3862
4089
|
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
4090
|
+
var getOptions = function getOptions() {
|
|
4091
|
+
if (get$1(vocabulary, 'data.items', null)) {
|
|
4092
|
+
var vocData = vocabulary.data.items.map(function (item) {
|
|
4093
|
+
var _item$title$default;
|
|
4094
|
+
|
|
4095
|
+
return {
|
|
4096
|
+
text: (_item$title$default = item.title.default) != null ? _item$title$default : item.title,
|
|
4097
|
+
value: item.token
|
|
4098
|
+
};
|
|
4099
|
+
});
|
|
4100
|
+
return vocData;
|
|
4101
|
+
}
|
|
4102
|
+
|
|
4103
|
+
return [];
|
|
4104
|
+
};
|
|
4105
|
+
|
|
4106
|
+
var getProps = function getProps() {
|
|
4107
|
+
if (multiple) {
|
|
4108
|
+
var currentValue = val || [];
|
|
4109
|
+
return {
|
|
4110
|
+
multiple: true,
|
|
4111
|
+
size: 5,
|
|
4112
|
+
value: currentValue,
|
|
4113
|
+
options: getOptions()
|
|
4114
|
+
};
|
|
3868
4115
|
}
|
|
3869
4116
|
|
|
3870
|
-
return
|
|
4117
|
+
return {
|
|
4118
|
+
value: val != null ? val : '',
|
|
4119
|
+
appendDefault: true,
|
|
4120
|
+
options: getOptions()
|
|
4121
|
+
};
|
|
4122
|
+
};
|
|
4123
|
+
|
|
4124
|
+
if (vocabulary.data === undefined || vocabulary.loading) {
|
|
4125
|
+
return /*#__PURE__*/React.createElement("div", null);
|
|
4126
|
+
}
|
|
4127
|
+
|
|
4128
|
+
return /*#__PURE__*/React.createElement(Select, _extends({}, getProps(), {
|
|
4129
|
+
className: className,
|
|
4130
|
+
classWrap: classWrap || 'is-fullwidth',
|
|
4131
|
+
dataTest: dataTest,
|
|
4132
|
+
ref: ref
|
|
4133
|
+
}, rest));
|
|
4134
|
+
});
|
|
4135
|
+
Select.propTypes = {
|
|
4136
|
+
error: PropTypes.string,
|
|
4137
|
+
disabled: PropTypes.bool,
|
|
4138
|
+
loading: PropTypes.bool,
|
|
4139
|
+
isSubmitted: PropTypes.bool,
|
|
4140
|
+
size: PropTypes.number,
|
|
4141
|
+
onChange: PropTypes.func,
|
|
4142
|
+
multiple: PropTypes.bool,
|
|
4143
|
+
className: PropTypes.string,
|
|
4144
|
+
vocabularyName: PropTypes.string
|
|
4145
|
+
};
|
|
4146
|
+
|
|
4147
|
+
var _SearchInputList$prop;
|
|
4148
|
+
|
|
4149
|
+
function debounce$1(func, wait) {
|
|
4150
|
+
var timeout;
|
|
4151
|
+
return function () {
|
|
4152
|
+
var context = this;
|
|
4153
|
+
var args = arguments;
|
|
4154
|
+
|
|
4155
|
+
var later = function later() {
|
|
4156
|
+
timeout = null;
|
|
4157
|
+
func.apply(context, args);
|
|
4158
|
+
};
|
|
4159
|
+
|
|
4160
|
+
clearTimeout(timeout);
|
|
4161
|
+
timeout = setTimeout(later, wait);
|
|
4162
|
+
};
|
|
4163
|
+
}
|
|
4164
|
+
|
|
4165
|
+
var initialState$1 = {
|
|
4166
|
+
page: 0,
|
|
4167
|
+
items: undefined,
|
|
4168
|
+
loading: false,
|
|
4169
|
+
items_total: 0
|
|
4170
|
+
};
|
|
4171
|
+
var SearchInputList = function SearchInputList(_ref) {
|
|
4172
|
+
var onChange = _ref.onChange,
|
|
4173
|
+
error = _ref.error,
|
|
4174
|
+
errorZoneClassName = _ref.errorZoneClassName,
|
|
4175
|
+
_ref$traversal = _ref.traversal,
|
|
4176
|
+
traversal = _ref$traversal === void 0 ? null : _ref$traversal,
|
|
4177
|
+
_ref$path = _ref.path,
|
|
4178
|
+
path = _ref$path === void 0 ? null : _ref$path,
|
|
4179
|
+
_ref$qs = _ref.qs,
|
|
4180
|
+
qs = _ref$qs === void 0 ? [] : _ref$qs,
|
|
4181
|
+
_ref$queryCondition = _ref.queryCondition,
|
|
4182
|
+
queryCondition = _ref$queryCondition === void 0 ? 'id__in' : _ref$queryCondition,
|
|
4183
|
+
value = _ref.value,
|
|
4184
|
+
_ref$btnClass = _ref.btnClass,
|
|
4185
|
+
btnClass = _ref$btnClass === void 0 ? '' : _ref$btnClass,
|
|
4186
|
+
_ref$dataTestWrapper = _ref.dataTestWrapper,
|
|
4187
|
+
dataTestWrapper = _ref$dataTestWrapper === void 0 ? 'wrapperSearchInputTest' : _ref$dataTestWrapper,
|
|
4188
|
+
_ref$dataTestSearchIn = _ref.dataTestSearchInput,
|
|
4189
|
+
dataTestSearchInput = _ref$dataTestSearchIn === void 0 ? 'searchInputTest' : _ref$dataTestSearchIn,
|
|
4190
|
+
_ref$dataTestItem = _ref.dataTestItem,
|
|
4191
|
+
dataTestItem = _ref$dataTestItem === void 0 ? 'searchInputItemTest' : _ref$dataTestItem,
|
|
4192
|
+
_ref$renderTextItemOp = _ref.renderTextItemOption,
|
|
4193
|
+
renderTextItemOption = _ref$renderTextItemOp === void 0 ? null : _ref$renderTextItemOp,
|
|
4194
|
+
_ref$typeNameQuery = _ref.typeNameQuery,
|
|
4195
|
+
typeNameQuery = _ref$typeNameQuery === void 0 ? null : _ref$typeNameQuery,
|
|
4196
|
+
_ref$labelProperty = _ref.labelProperty,
|
|
4197
|
+
labelProperty = _ref$labelProperty === void 0 ? 'id' : _ref$labelProperty;
|
|
4198
|
+
var intl = useIntl();
|
|
4199
|
+
|
|
4200
|
+
var _useSetState = useSetState(initialState$1),
|
|
4201
|
+
options = _useSetState[0],
|
|
4202
|
+
setOptions = _useSetState[1];
|
|
4203
|
+
|
|
4204
|
+
var _useState = useState(undefined),
|
|
4205
|
+
valuesLabel = _useState[0],
|
|
4206
|
+
setValuesLabels = _useState[1];
|
|
4207
|
+
|
|
4208
|
+
var _React$useState = React.useState(false),
|
|
4209
|
+
isOpen = _React$useState[0],
|
|
4210
|
+
setIsOpen = _React$useState[1];
|
|
4211
|
+
|
|
4212
|
+
var _React$useState2 = React.useState(''),
|
|
4213
|
+
searchTerm = _React$useState2[0],
|
|
4214
|
+
setSearchTerm = _React$useState2[1];
|
|
4215
|
+
|
|
4216
|
+
var inputRef = React.useRef(null);
|
|
4217
|
+
var wrapperRef = React.useRef(null);
|
|
4218
|
+
|
|
4219
|
+
var _useConfig = useConfig(),
|
|
4220
|
+
PageSize = _useConfig.PageSize,
|
|
4221
|
+
SearchEngine = _useConfig.SearchEngine;
|
|
4222
|
+
|
|
4223
|
+
var _useState2 = useState(false),
|
|
4224
|
+
isLoadingData = _useState2[0],
|
|
4225
|
+
setIsLoadingData = _useState2[1];
|
|
4226
|
+
|
|
4227
|
+
var _useState3 = useState(generateUID('search_input')),
|
|
4228
|
+
uid = _useState3[0];
|
|
4229
|
+
|
|
4230
|
+
useClickAway(wrapperRef, function () {
|
|
4231
|
+
setIsOpen(false);
|
|
4232
|
+
});
|
|
4233
|
+
|
|
4234
|
+
var getHeight = function getHeight() {
|
|
4235
|
+
if (wrapperRef && wrapperRef.current) {
|
|
4236
|
+
return {
|
|
4237
|
+
maxHeight: window.innerHeight - wrapperRef.current.getBoundingClientRect().top - 100 + "px"
|
|
4238
|
+
};
|
|
4239
|
+
}
|
|
4240
|
+
|
|
4241
|
+
return {
|
|
4242
|
+
maxHeight: 'auto'
|
|
4243
|
+
};
|
|
4244
|
+
};
|
|
4245
|
+
|
|
4246
|
+
var delayedQuery = useCallback(debounce$1(function (value) {
|
|
4247
|
+
return handleSearch(0, false, value);
|
|
4248
|
+
}, 500), []);
|
|
4249
|
+
|
|
4250
|
+
var handleSearch = function handleSearch(page, concat, value) {
|
|
4251
|
+
if (page === void 0) {
|
|
4252
|
+
page = 0;
|
|
4253
|
+
}
|
|
4254
|
+
|
|
4255
|
+
if (concat === void 0) {
|
|
4256
|
+
concat = false;
|
|
4257
|
+
}
|
|
4258
|
+
|
|
4259
|
+
if (value === void 0) {
|
|
4260
|
+
value = '';
|
|
4261
|
+
}
|
|
4262
|
+
|
|
4263
|
+
try {
|
|
4264
|
+
setOptions({
|
|
4265
|
+
loading: true
|
|
4266
|
+
});
|
|
4267
|
+
var searchTermQs = [];
|
|
4268
|
+
var searchTermParsed = [];
|
|
4269
|
+
|
|
4270
|
+
if (value !== '') {
|
|
4271
|
+
searchTermParsed = parser(queryCondition + "=" + value);
|
|
4272
|
+
}
|
|
4273
|
+
|
|
4274
|
+
var _get = traversal.registry.get;
|
|
4275
|
+
|
|
4276
|
+
var fnName = _get('searchEngineQueryParamsFunction', SearchEngine);
|
|
4277
|
+
|
|
4278
|
+
var qsParsed = traversal.client[fnName]({
|
|
4279
|
+
path: traversal.path,
|
|
4280
|
+
start: page * PageSize,
|
|
4281
|
+
pageSize: PageSize,
|
|
4282
|
+
withDepth: false
|
|
4283
|
+
});
|
|
4284
|
+
var sortParsed = parser("_sort_des=title");
|
|
4285
|
+
var typeNameParsed = [];
|
|
4286
|
+
|
|
4287
|
+
if (typeNameQuery) {
|
|
4288
|
+
typeNameParsed = parser("type_name__in=" + typeNameQuery);
|
|
4289
|
+
}
|
|
4290
|
+
|
|
4291
|
+
if (qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
|
|
4292
|
+
searchTermQs = buildQs([].concat(qs, searchTermParsed, qsParsed, typeNameParsed, sortParsed));
|
|
4293
|
+
}
|
|
4294
|
+
|
|
4295
|
+
return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false)).then(function (data) {
|
|
4296
|
+
var _data$items_total;
|
|
4297
|
+
|
|
4298
|
+
var newItems = options.items && concat ? [].concat(options.items, data.items) : data.items;
|
|
4299
|
+
setOptions({
|
|
4300
|
+
items: newItems != null ? newItems : [],
|
|
4301
|
+
loading: false,
|
|
4302
|
+
items_total: (_data$items_total = data.items_total) != null ? _data$items_total : 0,
|
|
4303
|
+
page: page
|
|
4304
|
+
});
|
|
4305
|
+
});
|
|
4306
|
+
} catch (e) {
|
|
4307
|
+
return Promise.reject(e);
|
|
4308
|
+
}
|
|
4309
|
+
};
|
|
4310
|
+
|
|
4311
|
+
var inicializeLabels = function inicializeLabels() {
|
|
4312
|
+
try {
|
|
4313
|
+
var _temp2 = function () {
|
|
4314
|
+
if (labelProperty !== 'id' && value.length > 0) {
|
|
4315
|
+
setIsLoadingData(true);
|
|
4316
|
+
var searchTermQs = [];
|
|
4317
|
+
var searchTermParsed = ['__or', "id=" + value.join('%26id=')];
|
|
4318
|
+
var getSearch = traversal.registry.get;
|
|
4319
|
+
var fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
|
|
4320
|
+
var qsParsed = traversal.client[fnName]({
|
|
4321
|
+
path: traversal.path,
|
|
4322
|
+
start: 0,
|
|
4323
|
+
pageSize: 100,
|
|
4324
|
+
withDepth: false
|
|
4325
|
+
});
|
|
4326
|
+
var typeNameParsed = [];
|
|
4327
|
+
|
|
4328
|
+
if (typeNameQuery) {
|
|
4329
|
+
typeNameParsed = parser("type_name__in=" + typeNameQuery);
|
|
4330
|
+
}
|
|
4331
|
+
|
|
4332
|
+
if (qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
|
|
4333
|
+
searchTermQs = buildQs([].concat(qs, [searchTermParsed], qsParsed, typeNameParsed));
|
|
4334
|
+
}
|
|
4335
|
+
|
|
4336
|
+
return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false, 0, 100)).then(function (data) {
|
|
4337
|
+
var newValuesLabel = data.items.reduce(function (result, item) {
|
|
4338
|
+
result[item.id] = get$1(item, labelProperty, item.id);
|
|
4339
|
+
return result;
|
|
4340
|
+
}, {});
|
|
4341
|
+
setValuesLabels(newValuesLabel);
|
|
4342
|
+
setIsLoadingData(false);
|
|
4343
|
+
});
|
|
4344
|
+
}
|
|
4345
|
+
}();
|
|
4346
|
+
|
|
4347
|
+
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
|
|
4348
|
+
} catch (e) {
|
|
4349
|
+
return Promise.reject(e);
|
|
4350
|
+
}
|
|
4351
|
+
};
|
|
4352
|
+
|
|
4353
|
+
var renderTextItemOptionFn = function renderTextItemOptionFn(item) {
|
|
4354
|
+
if (renderTextItemOption) {
|
|
4355
|
+
return renderTextItemOption(item);
|
|
4356
|
+
}
|
|
4357
|
+
|
|
4358
|
+
return item.title || item['@name'];
|
|
4359
|
+
};
|
|
4360
|
+
|
|
4361
|
+
React.useEffect(function () {
|
|
4362
|
+
if (!options.loading && !options.items && value.length > 0) {
|
|
4363
|
+
inicializeLabels();
|
|
4364
|
+
} else if (value.length === 0) {
|
|
4365
|
+
setValuesLabels({});
|
|
4366
|
+
}
|
|
4367
|
+
}, [path, options.loading, options.items]);
|
|
4368
|
+
|
|
4369
|
+
if (isLoadingData || valuesLabel === undefined) {
|
|
4370
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
4371
|
+
className: "spinner"
|
|
4372
|
+
});
|
|
4373
|
+
}
|
|
4374
|
+
|
|
4375
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
4376
|
+
className: "tags mb-2"
|
|
4377
|
+
}, value.map(function (tag, index) {
|
|
4378
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
4379
|
+
key: "input_list_" + tag + "_" + index,
|
|
4380
|
+
className: "tag is-info is-medium"
|
|
4381
|
+
}, get$1(valuesLabel, tag, tag), /*#__PURE__*/React.createElement("button", {
|
|
4382
|
+
className: "delete is-small",
|
|
4383
|
+
onClick: function onClick(ev) {
|
|
4384
|
+
ev.stopPropagation();
|
|
4385
|
+
ev.preventDefault();
|
|
4386
|
+
onChange([].concat(value.filter(function (tag) {
|
|
4387
|
+
return value.indexOf(tag) !== index;
|
|
4388
|
+
})));
|
|
4389
|
+
}
|
|
4390
|
+
}));
|
|
4391
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
4392
|
+
"data-test": dataTestWrapper,
|
|
4393
|
+
ref: wrapperRef,
|
|
4394
|
+
className: "dropdown mb-2 " + (isOpen ? 'is-active' : ''),
|
|
4395
|
+
onBlur: function onBlur(ev) {
|
|
4396
|
+
if (!ev.currentTarget.contains(ev.relatedTarget)) {
|
|
4397
|
+
if (searchTerm !== '') {
|
|
4398
|
+
setSearchTerm('');
|
|
4399
|
+
setOptions(initialState$1);
|
|
4400
|
+
}
|
|
4401
|
+
|
|
4402
|
+
setIsOpen(false);
|
|
4403
|
+
}
|
|
4404
|
+
}
|
|
4405
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4406
|
+
className: "dropdown-trigger"
|
|
4407
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
4408
|
+
className: "button " + btnClass,
|
|
4409
|
+
onClick: function onClick(ev) {
|
|
4410
|
+
ev.preventDefault();
|
|
4411
|
+
setIsOpen(!isOpen);
|
|
4412
|
+
|
|
4413
|
+
if (!options.loading && !options.items) {
|
|
4414
|
+
handleSearch(options.page);
|
|
4415
|
+
}
|
|
4416
|
+
},
|
|
4417
|
+
"aria-haspopup": "true",
|
|
4418
|
+
"aria-controls": "dropdown-menu"
|
|
4419
|
+
}, /*#__PURE__*/React.createElement("span", null, intl.formatMessage(genericMessages.choose)), /*#__PURE__*/React.createElement("span", {
|
|
4420
|
+
className: "icon"
|
|
4421
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
4422
|
+
className: "fas fa-angle-down",
|
|
4423
|
+
"aria-hidden": "true"
|
|
4424
|
+
})))), /*#__PURE__*/React.createElement("div", {
|
|
4425
|
+
className: "dropdown-menu",
|
|
4426
|
+
id: "dropdown-menu",
|
|
4427
|
+
role: "menu",
|
|
4428
|
+
style: getHeight()
|
|
4429
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4430
|
+
className: "dropdown-content"
|
|
4431
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4432
|
+
className: "dropdown-item"
|
|
4433
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
4434
|
+
ref: inputRef,
|
|
4435
|
+
"data-test": dataTestSearchInput,
|
|
4436
|
+
className: "input",
|
|
4437
|
+
type: "text",
|
|
4438
|
+
placeholder: intl.formatMessage(genericMessages.search),
|
|
4439
|
+
value: searchTerm,
|
|
4440
|
+
onChange: function onChange(ev) {
|
|
4441
|
+
delayedQuery(ev.target.value);
|
|
4442
|
+
setSearchTerm(ev.target.value);
|
|
4443
|
+
}
|
|
4444
|
+
})), /*#__PURE__*/React.createElement("hr", {
|
|
4445
|
+
className: "dropdown-divider"
|
|
4446
|
+
}), options.loading && /*#__PURE__*/React.createElement(Loading, null), options.items && options.items.map(function (item) {
|
|
4447
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
4448
|
+
className: "dropdown-item editable " + (value && value.id === item.id ? 'is-active' : ''),
|
|
4449
|
+
"data-test": dataTestItem + "-" + item.id,
|
|
4450
|
+
onMouseDown: function onMouseDown(ev) {
|
|
4451
|
+
ev.stopPropagation();
|
|
4452
|
+
ev.preventDefault();
|
|
4453
|
+
|
|
4454
|
+
if (onChange && !value.includes(item.id)) {
|
|
4455
|
+
var _extends2;
|
|
4456
|
+
|
|
4457
|
+
setValuesLabels(_extends({}, valuesLabel, (_extends2 = {}, _extends2[item.id] = get$1(item, labelProperty, item.id), _extends2)));
|
|
4458
|
+
onChange([].concat(value, [item.id]));
|
|
4459
|
+
}
|
|
4460
|
+
},
|
|
4461
|
+
key: item.path
|
|
4462
|
+
}, renderTextItemOptionFn(item));
|
|
4463
|
+
}), options.items && options.items.length === 0 && /*#__PURE__*/React.createElement("div", {
|
|
4464
|
+
className: "dropdown-item"
|
|
4465
|
+
}, intl.formatMessage(genericMessages.no_results)), options.items && options.items_total > options.items.length && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("hr", {
|
|
4466
|
+
className: "dropdown-divider"
|
|
4467
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
4468
|
+
className: "dropdown-item editable",
|
|
4469
|
+
onMouseDown: function onMouseDown(ev) {
|
|
4470
|
+
ev.stopPropagation();
|
|
4471
|
+
ev.preventDefault();
|
|
4472
|
+
handleSearch(options.page + 1, true);
|
|
4473
|
+
}
|
|
4474
|
+
}, intl.formatMessage(genericMessages.load_more)))))), error && /*#__PURE__*/React.createElement(ErrorZone, {
|
|
4475
|
+
className: errorZoneClassName,
|
|
4476
|
+
id: uid
|
|
4477
|
+
}, error ? error : ''));
|
|
4478
|
+
};
|
|
4479
|
+
SearchInputList.propTypes = (_SearchInputList$prop = {
|
|
4480
|
+
onChange: PropTypes.func,
|
|
4481
|
+
path: PropTypes.string,
|
|
4482
|
+
btnClass: PropTypes.string,
|
|
4483
|
+
dataTestWrapper: PropTypes.string,
|
|
4484
|
+
dataTestSearchInput: PropTypes.string,
|
|
4485
|
+
dataTestItem: PropTypes.string,
|
|
4486
|
+
renderTextItemOption: PropTypes.func,
|
|
4487
|
+
typeNameQuery: PropTypes.string,
|
|
4488
|
+
labelProperty: PropTypes.string,
|
|
4489
|
+
error: PropTypes.string,
|
|
4490
|
+
errorZoneClassName: PropTypes.string,
|
|
4491
|
+
traversal: PropTypes.object
|
|
4492
|
+
}, _SearchInputList$prop["path"] = PropTypes.string, _SearchInputList$prop.qs = PropTypes.array, _SearchInputList$prop.queryCondition = PropTypes.string, _SearchInputList$prop);
|
|
4493
|
+
|
|
4494
|
+
var EditComponent = React.forwardRef(function (_ref, ref) {
|
|
4495
|
+
var schema = _ref.schema,
|
|
4496
|
+
val = _ref.val,
|
|
4497
|
+
setValue = _ref.setValue,
|
|
4498
|
+
dataTest = _ref.dataTest,
|
|
4499
|
+
className = _ref.className,
|
|
4500
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["schema", "val", "setValue", "dataTest", "className"]);
|
|
4501
|
+
|
|
4502
|
+
var traversal = useTraversal();
|
|
4503
|
+
|
|
4504
|
+
if ((schema == null ? void 0 : schema.widget) === 'search_list') {
|
|
4505
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, rest.placeholder && /*#__PURE__*/React.createElement("label", {
|
|
4506
|
+
className: "label"
|
|
4507
|
+
}, rest.placeholder), /*#__PURE__*/React.createElement(SearchInputList, _extends({
|
|
4508
|
+
value: val || [],
|
|
4509
|
+
traversal: traversal,
|
|
4510
|
+
className: className,
|
|
4511
|
+
onChange: function onChange(ev) {
|
|
4512
|
+
return setValue(ev);
|
|
4513
|
+
},
|
|
4514
|
+
queryCondition: schema != null && schema.queryCondition ? schema.queryCondition : 'title__in',
|
|
4515
|
+
dataTest: dataTest,
|
|
4516
|
+
path: schema.queryPath,
|
|
4517
|
+
labelProperty: schema != null && schema.labelProperty ? schema.labelProperty : 'title',
|
|
4518
|
+
typeNameQuery: schema != null && schema.typeNameQuery ? schema.typeNameQuery : null
|
|
4519
|
+
}, rest)));
|
|
4520
|
+
} else if ((schema == null ? void 0 : schema.widget) === 'search') {
|
|
4521
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, rest.placeholder && /*#__PURE__*/React.createElement("label", {
|
|
4522
|
+
className: "label"
|
|
4523
|
+
}, rest.placeholder), /*#__PURE__*/React.createElement(SearchInput, _extends({
|
|
4524
|
+
value: val,
|
|
4525
|
+
traversal: traversal,
|
|
4526
|
+
className: className,
|
|
4527
|
+
onChange: function onChange(ev) {
|
|
4528
|
+
return setValue(ev);
|
|
4529
|
+
},
|
|
4530
|
+
queryCondition: schema != null && schema.queryCondition ? schema.queryCondition : 'title__in',
|
|
4531
|
+
dataTest: dataTest,
|
|
4532
|
+
path: schema.queryPath,
|
|
4533
|
+
labelProperty: schema != null && schema.labelProperty ? schema.labelProperty : 'title',
|
|
4534
|
+
typeNameQuery: schema != null && schema.typeNameQuery ? schema.typeNameQuery : null
|
|
4535
|
+
}, rest)));
|
|
4536
|
+
} else if ((schema == null ? void 0 : schema.widget) === 'textarea' || (schema == null ? void 0 : schema.widget) === 'richtext') {
|
|
4537
|
+
return /*#__PURE__*/React.createElement(Textarea, _extends({
|
|
4538
|
+
value: val || '',
|
|
4539
|
+
className: className,
|
|
4540
|
+
onChange: function onChange(ev) {
|
|
4541
|
+
return setValue(ev);
|
|
4542
|
+
},
|
|
4543
|
+
ref: ref,
|
|
4544
|
+
dataTest: dataTest
|
|
4545
|
+
}, rest));
|
|
4546
|
+
} else if ((schema == null ? void 0 : schema.type) === 'boolean') {
|
|
4547
|
+
return /*#__PURE__*/React.createElement(Checkbox, _extends({
|
|
4548
|
+
value: !!val,
|
|
4549
|
+
className: className,
|
|
4550
|
+
onChange: function onChange(ev) {
|
|
4551
|
+
return setValue(ev);
|
|
4552
|
+
},
|
|
4553
|
+
ref: ref,
|
|
4554
|
+
dataTest: dataTest
|
|
4555
|
+
}, rest));
|
|
4556
|
+
} else if ((schema == null ? void 0 : schema.type) === 'array') {
|
|
4557
|
+
if (schema.items && schema.items.type === 'string') {
|
|
4558
|
+
var _schema$items;
|
|
4559
|
+
|
|
4560
|
+
if (schema.items.vocabularyName) {
|
|
4561
|
+
return /*#__PURE__*/React.createElement(SelectVocabulary, _extends({
|
|
4562
|
+
vocabularyName: get$1(schema, 'items.vocabularyName', null),
|
|
4563
|
+
val: val || [],
|
|
4564
|
+
className: className,
|
|
4565
|
+
classWrap: "is-fullwidth",
|
|
4566
|
+
dataTest: dataTest
|
|
4567
|
+
}, rest, {
|
|
4568
|
+
onChange: setValue,
|
|
4569
|
+
multiple: true
|
|
4570
|
+
}));
|
|
4571
|
+
} else if (schema != null && (_schema$items = schema.items) != null && _schema$items.vocabulary) {
|
|
4572
|
+
return /*#__PURE__*/React.createElement(Select, _extends({
|
|
4573
|
+
value: val || [],
|
|
4574
|
+
className: className,
|
|
4575
|
+
classWrap: "is-fullwidth",
|
|
4576
|
+
dataTest: dataTest,
|
|
4577
|
+
options: schema == null ? void 0 : schema.items.vocabulary.map(function (item) {
|
|
4578
|
+
return {
|
|
4579
|
+
text: item,
|
|
4580
|
+
value: item
|
|
4581
|
+
};
|
|
4582
|
+
}),
|
|
4583
|
+
multiple: true,
|
|
4584
|
+
onChange: setValue
|
|
4585
|
+
}, rest));
|
|
4586
|
+
}
|
|
4587
|
+
}
|
|
4588
|
+
|
|
4589
|
+
return /*#__PURE__*/React.createElement(InputList, _extends({
|
|
4590
|
+
value: val || [],
|
|
4591
|
+
className: className,
|
|
4592
|
+
onChange: function onChange(ev) {
|
|
4593
|
+
return setValue(ev);
|
|
4594
|
+
},
|
|
4595
|
+
ref: ref,
|
|
4596
|
+
dataTest: dataTest
|
|
4597
|
+
}, rest));
|
|
4598
|
+
} else if ((schema == null ? void 0 : schema.widget) === 'file') {
|
|
4599
|
+
return /*#__PURE__*/React.createElement(FileUpload, _extends({
|
|
4600
|
+
onChange: function onChange(ev) {
|
|
4601
|
+
return setValue(ev);
|
|
4602
|
+
},
|
|
4603
|
+
label: get$1(val, 'filename', null),
|
|
4604
|
+
dataTest: dataTest
|
|
4605
|
+
}, rest));
|
|
4606
|
+
} else if ((schema == null ? void 0 : schema.widget) === 'select' && schema.type === 'string') {
|
|
4607
|
+
if (schema != null && schema.vocabularyName) {
|
|
4608
|
+
return /*#__PURE__*/React.createElement(SelectVocabulary, _extends({
|
|
4609
|
+
val: val || '',
|
|
4610
|
+
className: className,
|
|
4611
|
+
appendDefault: true,
|
|
4612
|
+
classWrap: "is-fullwidth",
|
|
4613
|
+
dataTest: dataTest,
|
|
4614
|
+
onChange: setValue,
|
|
4615
|
+
vocabularyName: get$1(schema, 'vocabularyName', null)
|
|
4616
|
+
}, rest));
|
|
4617
|
+
}
|
|
4618
|
+
|
|
4619
|
+
return /*#__PURE__*/React.createElement(Select, _extends({
|
|
4620
|
+
value: val || '',
|
|
4621
|
+
className: className,
|
|
4622
|
+
appendDefault: true,
|
|
4623
|
+
classWrap: "is-fullwidth",
|
|
4624
|
+
dataTest: dataTest,
|
|
4625
|
+
options: schema == null ? void 0 : schema.vocabulary.map(function (item) {
|
|
4626
|
+
return {
|
|
4627
|
+
text: item,
|
|
4628
|
+
value: item
|
|
4629
|
+
};
|
|
4630
|
+
}),
|
|
4631
|
+
onChange: setValue
|
|
4632
|
+
}, rest));
|
|
4633
|
+
}
|
|
4634
|
+
|
|
4635
|
+
var getInputType = function getInputType() {
|
|
4636
|
+
switch (schema == null ? void 0 : schema.type) {
|
|
4637
|
+
case 'integer':
|
|
4638
|
+
return 'number';
|
|
4639
|
+
|
|
4640
|
+
case 'date':
|
|
4641
|
+
return 'date';
|
|
4642
|
+
|
|
4643
|
+
case 'datetime':
|
|
4644
|
+
return 'datetime-local';
|
|
4645
|
+
|
|
4646
|
+
default:
|
|
4647
|
+
return 'text';
|
|
4648
|
+
}
|
|
3871
4649
|
};
|
|
3872
4650
|
|
|
3873
|
-
return /*#__PURE__*/React.createElement(
|
|
3874
|
-
|
|
4651
|
+
return /*#__PURE__*/React.createElement(Input, _extends({
|
|
4652
|
+
value: val || '',
|
|
4653
|
+
className: className,
|
|
4654
|
+
dataTest: dataTest,
|
|
4655
|
+
onChange: function onChange(ev) {
|
|
4656
|
+
return setValue(ev);
|
|
4657
|
+
},
|
|
4658
|
+
ref: ref,
|
|
4659
|
+
type: getInputType()
|
|
4660
|
+
}, rest));
|
|
4661
|
+
});
|
|
4662
|
+
EditComponent.displayName = 'EditComponent';
|
|
3875
4663
|
|
|
3876
4664
|
function IAttachment(_ref) {
|
|
3877
4665
|
var properties = _ref.properties,
|
|
3878
4666
|
values = _ref.values;
|
|
4667
|
+
var intl = useIntl();
|
|
3879
4668
|
var Ctx = useTraversal();
|
|
3880
4669
|
var modifyContent = Ctx.hasPerm('guillotina.ModifyContent');
|
|
3881
4670
|
return /*#__PURE__*/React.createElement(Table, {
|
|
3882
|
-
headers: [
|
|
4671
|
+
headers: [intl.formatMessage(genericMessages.property), intl.formatMessage(genericMessages.value)],
|
|
3883
4672
|
className: "is-striped is-fullwidth is-size-7"
|
|
3884
4673
|
}, Object.keys(properties).map(function (key) {
|
|
3885
4674
|
return /*#__PURE__*/React.createElement("tr", {
|
|
3886
4675
|
key: 'attachment_' + key
|
|
3887
4676
|
}, /*#__PURE__*/React.createElement("td", {
|
|
4677
|
+
style: {
|
|
4678
|
+
width: '150px'
|
|
4679
|
+
},
|
|
3888
4680
|
key: 1
|
|
3889
4681
|
}, key), /*#__PURE__*/React.createElement("td", {
|
|
3890
4682
|
key: 2
|
|
@@ -3980,7 +4772,7 @@ function IMultiAttachment(_ref) {
|
|
|
3980
4772
|
};
|
|
3981
4773
|
|
|
3982
4774
|
return /*#__PURE__*/React.createElement(Table, {
|
|
3983
|
-
headers: [
|
|
4775
|
+
headers: [intl.formatMessage(genericMessages.property), intl.formatMessage(genericMessages.value)],
|
|
3984
4776
|
className: "is-striped is-fullwidth is-size-7"
|
|
3985
4777
|
}, fileKeyToDelete && /*#__PURE__*/React.createElement(Confirm, {
|
|
3986
4778
|
loading: loading,
|
|
@@ -3997,7 +4789,10 @@ function IMultiAttachment(_ref) {
|
|
|
3997
4789
|
return /*#__PURE__*/React.createElement("tr", {
|
|
3998
4790
|
key: 'multiattachment_' + key
|
|
3999
4791
|
}, /*#__PURE__*/React.createElement("td", {
|
|
4000
|
-
key: 1
|
|
4792
|
+
key: 1,
|
|
4793
|
+
style: {
|
|
4794
|
+
width: '150px'
|
|
4795
|
+
}
|
|
4001
4796
|
}, key), /*#__PURE__*/React.createElement("td", {
|
|
4002
4797
|
key: 2
|
|
4003
4798
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -4285,7 +5080,7 @@ function IImageAttachment(_ref) {
|
|
|
4285
5080
|
};
|
|
4286
5081
|
|
|
4287
5082
|
return /*#__PURE__*/React.createElement(Table, {
|
|
4288
|
-
headers: [
|
|
5083
|
+
headers: [intl.formatMessage(genericMessages.property), intl.formatMessage(genericMessages.value)],
|
|
4289
5084
|
className: "is-striped is-fullwidth is-size-7"
|
|
4290
5085
|
}, showConfirmToDelete && /*#__PURE__*/React.createElement(Confirm, {
|
|
4291
5086
|
loading: loading,
|
|
@@ -4297,7 +5092,10 @@ function IImageAttachment(_ref) {
|
|
|
4297
5092
|
},
|
|
4298
5093
|
message: intl.formatMessage(genericFileMessages.confirm_message_delete_image)
|
|
4299
5094
|
}), values['image'] && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
4300
|
-
key: 1
|
|
5095
|
+
key: 1,
|
|
5096
|
+
style: {
|
|
5097
|
+
width: '150px'
|
|
5098
|
+
}
|
|
4301
5099
|
}, intl.formatMessage(genericMessages.image)), /*#__PURE__*/React.createElement("td", {
|
|
4302
5100
|
key: 2
|
|
4303
5101
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -4587,7 +5385,7 @@ function IMultiImageAttachment(_ref) {
|
|
|
4587
5385
|
};
|
|
4588
5386
|
|
|
4589
5387
|
return /*#__PURE__*/React.createElement(Table, {
|
|
4590
|
-
headers: [
|
|
5388
|
+
headers: [intl.formatMessage(genericMessages.property), intl.formatMessage(genericMessages.value)],
|
|
4591
5389
|
className: "is-striped is-fullwidth is-size-7"
|
|
4592
5390
|
}, fileKeyToDelete && /*#__PURE__*/React.createElement(Confirm, {
|
|
4593
5391
|
loading: loading,
|
|
@@ -4604,7 +5402,10 @@ function IMultiImageAttachment(_ref) {
|
|
|
4604
5402
|
return /*#__PURE__*/React.createElement("tr", {
|
|
4605
5403
|
key: "multiimageattachment_" + key
|
|
4606
5404
|
}, /*#__PURE__*/React.createElement("td", {
|
|
4607
|
-
key: 1
|
|
5405
|
+
key: 1,
|
|
5406
|
+
style: {
|
|
5407
|
+
width: '150px'
|
|
5408
|
+
}
|
|
4608
5409
|
}, key), /*#__PURE__*/React.createElement("td", {
|
|
4609
5410
|
key: 2
|
|
4610
5411
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -6085,75 +6886,7 @@ function SearchVocabularyLabels(props) {
|
|
|
6085
6886
|
return null;
|
|
6086
6887
|
}
|
|
6087
6888
|
|
|
6088
|
-
var
|
|
6089
|
-
var vocabularyName = _ref.vocabularyName,
|
|
6090
|
-
className = _ref.className,
|
|
6091
|
-
classWrap = _ref.classWrap,
|
|
6092
|
-
val = _ref.val,
|
|
6093
|
-
dataTest = _ref.dataTest,
|
|
6094
|
-
multiple = _ref.multiple,
|
|
6095
|
-
rest = _objectWithoutPropertiesLoose(_ref, ["vocabularyName", "className", "classWrap", "val", "dataTest", "multiple"]);
|
|
6096
|
-
|
|
6097
|
-
var vocabulary = useVocabulary(vocabularyName);
|
|
6098
|
-
|
|
6099
|
-
var getOptions = function getOptions() {
|
|
6100
|
-
if (get$1(vocabulary, 'data.items', null)) {
|
|
6101
|
-
var vocData = vocabulary.data.items.map(function (item) {
|
|
6102
|
-
var _item$title$default;
|
|
6103
|
-
|
|
6104
|
-
return {
|
|
6105
|
-
text: (_item$title$default = item.title.default) != null ? _item$title$default : item.title,
|
|
6106
|
-
value: item.token
|
|
6107
|
-
};
|
|
6108
|
-
});
|
|
6109
|
-
return vocData;
|
|
6110
|
-
}
|
|
6111
|
-
|
|
6112
|
-
return [];
|
|
6113
|
-
};
|
|
6114
|
-
|
|
6115
|
-
var getProps = function getProps() {
|
|
6116
|
-
if (multiple) {
|
|
6117
|
-
var currentValue = val || [];
|
|
6118
|
-
return {
|
|
6119
|
-
multiple: true,
|
|
6120
|
-
size: 5,
|
|
6121
|
-
value: currentValue,
|
|
6122
|
-
options: getOptions()
|
|
6123
|
-
};
|
|
6124
|
-
}
|
|
6125
|
-
|
|
6126
|
-
return {
|
|
6127
|
-
value: val != null ? val : '',
|
|
6128
|
-
appendDefault: true,
|
|
6129
|
-
options: getOptions()
|
|
6130
|
-
};
|
|
6131
|
-
};
|
|
6132
|
-
|
|
6133
|
-
if (vocabulary.data === undefined || vocabulary.loading) {
|
|
6134
|
-
return /*#__PURE__*/React.createElement("div", null);
|
|
6135
|
-
}
|
|
6136
|
-
|
|
6137
|
-
return /*#__PURE__*/React.createElement(Select, _extends({}, getProps(), {
|
|
6138
|
-
className: className,
|
|
6139
|
-
classWrap: classWrap || 'is-fullwidth',
|
|
6140
|
-
dataTest: dataTest,
|
|
6141
|
-
ref: ref
|
|
6142
|
-
}, rest));
|
|
6143
|
-
});
|
|
6144
|
-
Select.propTypes = {
|
|
6145
|
-
error: PropTypes.string,
|
|
6146
|
-
disabled: PropTypes.bool,
|
|
6147
|
-
loading: PropTypes.bool,
|
|
6148
|
-
isSubmitted: PropTypes.bool,
|
|
6149
|
-
size: PropTypes.number,
|
|
6150
|
-
onChange: PropTypes.func,
|
|
6151
|
-
multiple: PropTypes.bool,
|
|
6152
|
-
className: PropTypes.string,
|
|
6153
|
-
vocabularyName: PropTypes.string
|
|
6154
|
-
};
|
|
6155
|
-
|
|
6156
|
-
var initialState$1 = {
|
|
6889
|
+
var initialState$2 = {
|
|
6157
6890
|
page: 0,
|
|
6158
6891
|
items: [],
|
|
6159
6892
|
loading: true,
|
|
@@ -6172,7 +6905,7 @@ function PanelItems() {
|
|
|
6172
6905
|
var intl = useIntl();
|
|
6173
6906
|
var Ctx = useTraversal();
|
|
6174
6907
|
|
|
6175
|
-
var _useSetState = useSetState(initialState$
|
|
6908
|
+
var _useSetState = useSetState(initialState$2),
|
|
6176
6909
|
state = _useSetState[0],
|
|
6177
6910
|
setState = _useSetState[1];
|
|
6178
6911
|
|
|
@@ -6622,7 +7355,7 @@ function PanelProperties() {
|
|
|
6622
7355
|
icon: model.icon,
|
|
6623
7356
|
align: "is-left",
|
|
6624
7357
|
className: "has-text-grey"
|
|
6625
|
-
}),
|
|
7358
|
+
}), "\xA0", /*#__PURE__*/React.createElement("span", null, Ctx.context.title || Ctx.context['@name']))), /*#__PURE__*/React.createElement("div", {
|
|
6626
7359
|
className: "level-right"
|
|
6627
7360
|
}, /*#__PURE__*/React.createElement(PropertiesButtonView, null))), /*#__PURE__*/React.createElement("hr", null), schema && schema.data && !schema.loading && /*#__PURE__*/React.createElement("div", {
|
|
6628
7361
|
className: "columns"
|
|
@@ -6631,13 +7364,20 @@ function PanelProperties() {
|
|
|
6631
7364
|
}, /*#__PURE__*/React.createElement("table", {
|
|
6632
7365
|
className: "table is-striped is-fullwidth is-size-7"
|
|
6633
7366
|
}, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
7367
|
+
style: {
|
|
7368
|
+
width: '150px'
|
|
7369
|
+
},
|
|
6634
7370
|
className: "is-2"
|
|
6635
7371
|
}, intl.formatMessage(genericMessages.property)), /*#__PURE__*/React.createElement("th", {
|
|
6636
7372
|
className: "is-8"
|
|
6637
7373
|
}, intl.formatMessage(genericMessages.value)))), /*#__PURE__*/React.createElement("tbody", null, showProperties.map(function (prop) {
|
|
6638
7374
|
return /*#__PURE__*/React.createElement("tr", {
|
|
6639
7375
|
key: 'prop' + prop
|
|
6640
|
-
}, /*#__PURE__*/React.createElement("td",
|
|
7376
|
+
}, /*#__PURE__*/React.createElement("td", {
|
|
7377
|
+
style: {
|
|
7378
|
+
width: '150px'
|
|
7379
|
+
}
|
|
7380
|
+
}, prop), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(EditableField, {
|
|
6641
7381
|
field: prop,
|
|
6642
7382
|
value: Ctx.context[prop],
|
|
6643
7383
|
modifyContent: false
|
|
@@ -6645,6 +7385,9 @@ function PanelProperties() {
|
|
|
6645
7385
|
}))), properties.length > 0 && /*#__PURE__*/React.createElement("table", {
|
|
6646
7386
|
className: "table is-striped is-fullwidth is-size-7"
|
|
6647
7387
|
}, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
7388
|
+
style: {
|
|
7389
|
+
width: '150px'
|
|
7390
|
+
},
|
|
6648
7391
|
className: "is-2"
|
|
6649
7392
|
}, intl.formatMessage(genericMessages.property)), /*#__PURE__*/React.createElement("th", {
|
|
6650
7393
|
className: "is-8"
|
|
@@ -6653,7 +7396,11 @@ function PanelProperties() {
|
|
|
6653
7396
|
value = _ref.value;
|
|
6654
7397
|
return /*#__PURE__*/React.createElement("tr", {
|
|
6655
7398
|
key: 'prop' + key
|
|
6656
|
-
}, /*#__PURE__*/React.createElement("td",
|
|
7399
|
+
}, /*#__PURE__*/React.createElement("td", {
|
|
7400
|
+
style: {
|
|
7401
|
+
width: '150px'
|
|
7402
|
+
}
|
|
7403
|
+
}, value.title || key), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(EditableField, {
|
|
6657
7404
|
field: key,
|
|
6658
7405
|
value: Ctx.context[key],
|
|
6659
7406
|
schema: value,
|
|
@@ -7384,13 +8131,13 @@ function TagsWidget(_ref) {
|
|
|
7384
8131
|
|
|
7385
8132
|
/* eslint jsx-a11y/anchor-is-valid: "off" */
|
|
7386
8133
|
|
|
7387
|
-
var initialState$
|
|
8134
|
+
var initialState$3 = {
|
|
7388
8135
|
types: undefined
|
|
7389
8136
|
};
|
|
7390
8137
|
function CreateButton() {
|
|
7391
8138
|
var intl = useIntl();
|
|
7392
8139
|
|
|
7393
|
-
var _useSetState = useSetState(initialState$
|
|
8140
|
+
var _useSetState = useSetState(initialState$3),
|
|
7394
8141
|
state = _useSetState[0],
|
|
7395
8142
|
setState = _useSetState[1];
|
|
7396
8143
|
|
|
@@ -7476,7 +8223,7 @@ function ContextToolbar(_ref) {
|
|
|
7476
8223
|
|
|
7477
8224
|
var intl = useIntl();
|
|
7478
8225
|
|
|
7479
|
-
var _useSetState2 = useSetState(initialState$
|
|
8226
|
+
var _useSetState2 = useSetState(initialState$3),
|
|
7480
8227
|
state = _useSetState2[0],
|
|
7481
8228
|
setState = _useSetState2[1];
|
|
7482
8229
|
|
|
@@ -8671,15 +9418,19 @@ var editableFields = ['title', 'description', 'effective_date', 'expiration_date
|
|
|
8671
9418
|
function IDublinCore(_ref) {
|
|
8672
9419
|
var properties = _ref.properties,
|
|
8673
9420
|
values = _ref.values;
|
|
9421
|
+
var intl = useIntl();
|
|
8674
9422
|
var Ctx = useTraversal();
|
|
8675
9423
|
var modifyContent = Ctx.hasPerm('guillotina.ModifyContent');
|
|
8676
9424
|
return /*#__PURE__*/React.createElement(Table, {
|
|
8677
|
-
headers: [
|
|
9425
|
+
headers: [intl.formatMessage(genericMessages.property), intl.formatMessage(genericMessages.value)],
|
|
8678
9426
|
className: "is-striped is-fullwidth is-size-7"
|
|
8679
9427
|
}, Object.keys(properties).map(function (key) {
|
|
8680
9428
|
return /*#__PURE__*/React.createElement("tr", {
|
|
8681
9429
|
key: 'dublin_' + key
|
|
8682
9430
|
}, /*#__PURE__*/React.createElement("td", {
|
|
9431
|
+
style: {
|
|
9432
|
+
width: '150px'
|
|
9433
|
+
},
|
|
8683
9434
|
key: 1
|
|
8684
9435
|
}, key), /*#__PURE__*/React.createElement("td", {
|
|
8685
9436
|
key: 2
|
|
@@ -8890,13 +9641,13 @@ function GroupCtx() {
|
|
|
8890
9641
|
}
|
|
8891
9642
|
};
|
|
8892
9643
|
|
|
8893
|
-
var addUser = function addUser(
|
|
9644
|
+
var addUser = function addUser(newUserId) {
|
|
8894
9645
|
try {
|
|
8895
9646
|
var data = {};
|
|
8896
9647
|
Ctx.context.users.forEach(function (user) {
|
|
8897
9648
|
data[user] = true;
|
|
8898
9649
|
});
|
|
8899
|
-
data[
|
|
9650
|
+
data[newUserId] = true;
|
|
8900
9651
|
return Promise.resolve(Ctx.client.rest.patch(Ctx.containerPath + "@groups/" + Ctx.context['@name'], {
|
|
8901
9652
|
users: data
|
|
8902
9653
|
})).then(function (_ref3) {
|
|
@@ -8915,7 +9666,7 @@ function GroupCtx() {
|
|
|
8915
9666
|
"value": " added to group"
|
|
8916
9667
|
}]
|
|
8917
9668
|
}, {
|
|
8918
|
-
user:
|
|
9669
|
+
user: newUserId
|
|
8919
9670
|
}), errorMessage);
|
|
8920
9671
|
});
|
|
8921
9672
|
} catch (e) {
|
|
@@ -9208,142 +9959,6 @@ var buildPaths = function buildPaths(segments) {
|
|
|
9208
9959
|
return results;
|
|
9209
9960
|
};
|
|
9210
9961
|
|
|
9211
|
-
var EditComponent = React.forwardRef(function (_ref, ref) {
|
|
9212
|
-
var schema = _ref.schema,
|
|
9213
|
-
val = _ref.val,
|
|
9214
|
-
setValue = _ref.setValue,
|
|
9215
|
-
dataTest = _ref.dataTest,
|
|
9216
|
-
className = _ref.className,
|
|
9217
|
-
rest = _objectWithoutPropertiesLoose(_ref, ["schema", "val", "setValue", "dataTest", "className"]);
|
|
9218
|
-
|
|
9219
|
-
if ((schema == null ? void 0 : schema.widget) === 'textarea' || (schema == null ? void 0 : schema.widget) === 'richtext') {
|
|
9220
|
-
return /*#__PURE__*/React.createElement(Textarea, _extends({
|
|
9221
|
-
value: val || '',
|
|
9222
|
-
className: className,
|
|
9223
|
-
onChange: function onChange(ev) {
|
|
9224
|
-
return setValue(ev);
|
|
9225
|
-
},
|
|
9226
|
-
ref: ref,
|
|
9227
|
-
dataTest: dataTest
|
|
9228
|
-
}, rest));
|
|
9229
|
-
} else if ((schema == null ? void 0 : schema.type) === 'boolean') {
|
|
9230
|
-
return /*#__PURE__*/React.createElement(Checkbox, _extends({
|
|
9231
|
-
value: !!val,
|
|
9232
|
-
className: className,
|
|
9233
|
-
onChange: function onChange(ev) {
|
|
9234
|
-
return setValue(ev);
|
|
9235
|
-
},
|
|
9236
|
-
ref: ref,
|
|
9237
|
-
dataTest: dataTest
|
|
9238
|
-
}, rest));
|
|
9239
|
-
} else if ((schema == null ? void 0 : schema.type) === 'array') {
|
|
9240
|
-
if (schema.items && schema.items.type === 'string') {
|
|
9241
|
-
var _schema$items;
|
|
9242
|
-
|
|
9243
|
-
if (schema.items.vocabularyName) {
|
|
9244
|
-
return /*#__PURE__*/React.createElement(SelectVocabulary, _extends({
|
|
9245
|
-
vocabularyName: get$1(schema, 'items.vocabularyName', null),
|
|
9246
|
-
val: val || [],
|
|
9247
|
-
className: className,
|
|
9248
|
-
classWrap: "is-fullwidth",
|
|
9249
|
-
dataTest: dataTest
|
|
9250
|
-
}, rest, {
|
|
9251
|
-
onChange: setValue,
|
|
9252
|
-
multiple: true
|
|
9253
|
-
}));
|
|
9254
|
-
} else if (schema != null && (_schema$items = schema.items) != null && _schema$items.vocabulary) {
|
|
9255
|
-
return /*#__PURE__*/React.createElement(Select, _extends({
|
|
9256
|
-
value: val || [],
|
|
9257
|
-
className: className,
|
|
9258
|
-
classWrap: "is-fullwidth",
|
|
9259
|
-
dataTest: dataTest,
|
|
9260
|
-
options: schema == null ? void 0 : schema.items.vocabulary.map(function (item) {
|
|
9261
|
-
return {
|
|
9262
|
-
text: item,
|
|
9263
|
-
value: item
|
|
9264
|
-
};
|
|
9265
|
-
}),
|
|
9266
|
-
multiple: true,
|
|
9267
|
-
onChange: setValue
|
|
9268
|
-
}, rest));
|
|
9269
|
-
}
|
|
9270
|
-
}
|
|
9271
|
-
|
|
9272
|
-
return /*#__PURE__*/React.createElement(InputList, _extends({
|
|
9273
|
-
value: val || [],
|
|
9274
|
-
className: className,
|
|
9275
|
-
onChange: function onChange(ev) {
|
|
9276
|
-
return setValue(ev);
|
|
9277
|
-
},
|
|
9278
|
-
ref: ref,
|
|
9279
|
-
dataTest: dataTest
|
|
9280
|
-
}, rest));
|
|
9281
|
-
} else if ((schema == null ? void 0 : schema.widget) === 'file') {
|
|
9282
|
-
return /*#__PURE__*/React.createElement(FileUpload, _extends({
|
|
9283
|
-
onChange: function onChange(ev) {
|
|
9284
|
-
return setValue(ev);
|
|
9285
|
-
},
|
|
9286
|
-
label: get$1(val, 'filename', null),
|
|
9287
|
-
dataTest: dataTest
|
|
9288
|
-
}, rest));
|
|
9289
|
-
} else if ((schema == null ? void 0 : schema.widget) === 'select' && schema.type === 'string') {
|
|
9290
|
-
if (schema != null && schema.vocabularyName) {
|
|
9291
|
-
return /*#__PURE__*/React.createElement(SelectVocabulary, _extends({
|
|
9292
|
-
val: val || '',
|
|
9293
|
-
className: className,
|
|
9294
|
-
appendDefault: true,
|
|
9295
|
-
classWrap: "is-fullwidth",
|
|
9296
|
-
dataTest: dataTest,
|
|
9297
|
-
onChange: setValue,
|
|
9298
|
-
vocabularyName: get$1(schema, 'vocabularyName', null)
|
|
9299
|
-
}, rest));
|
|
9300
|
-
}
|
|
9301
|
-
|
|
9302
|
-
return /*#__PURE__*/React.createElement(Select, _extends({
|
|
9303
|
-
value: val || '',
|
|
9304
|
-
className: className,
|
|
9305
|
-
appendDefault: true,
|
|
9306
|
-
classWrap: "is-fullwidth",
|
|
9307
|
-
dataTest: dataTest,
|
|
9308
|
-
options: schema == null ? void 0 : schema.vocabulary.map(function (item) {
|
|
9309
|
-
return {
|
|
9310
|
-
text: item,
|
|
9311
|
-
value: item
|
|
9312
|
-
};
|
|
9313
|
-
}),
|
|
9314
|
-
onChange: setValue
|
|
9315
|
-
}, rest));
|
|
9316
|
-
}
|
|
9317
|
-
|
|
9318
|
-
var getInputType = function getInputType() {
|
|
9319
|
-
switch (schema == null ? void 0 : schema.type) {
|
|
9320
|
-
case 'integer':
|
|
9321
|
-
return 'number';
|
|
9322
|
-
|
|
9323
|
-
case 'date':
|
|
9324
|
-
return 'date';
|
|
9325
|
-
|
|
9326
|
-
case 'datetime':
|
|
9327
|
-
return 'datetime-local';
|
|
9328
|
-
|
|
9329
|
-
default:
|
|
9330
|
-
return 'text';
|
|
9331
|
-
}
|
|
9332
|
-
};
|
|
9333
|
-
|
|
9334
|
-
return /*#__PURE__*/React.createElement(Input, _extends({
|
|
9335
|
-
value: val || '',
|
|
9336
|
-
className: className,
|
|
9337
|
-
dataTest: dataTest,
|
|
9338
|
-
onChange: function onChange(ev) {
|
|
9339
|
-
return setValue(ev);
|
|
9340
|
-
},
|
|
9341
|
-
ref: ref,
|
|
9342
|
-
type: getInputType()
|
|
9343
|
-
}, rest));
|
|
9344
|
-
});
|
|
9345
|
-
EditComponent.displayName = 'EditComponent';
|
|
9346
|
-
|
|
9347
9962
|
var registry = {
|
|
9348
9963
|
paths: {},
|
|
9349
9964
|
views: {
|
|
@@ -9522,7 +10137,7 @@ const registry = {
|
|
|
9522
10137
|
|
|
9523
10138
|
*/
|
|
9524
10139
|
|
|
9525
|
-
var initialState$
|
|
10140
|
+
var initialState$4 = {
|
|
9526
10141
|
path: '',
|
|
9527
10142
|
loading: false,
|
|
9528
10143
|
context: undefined,
|
|
@@ -12425,10 +13040,10 @@ function Guillotina(_ref) {
|
|
|
12425
13040
|
var searchPath = location.get('path') || '/';
|
|
12426
13041
|
|
|
12427
13042
|
if (searchPath && searchPath !== '') {
|
|
12428
|
-
initialState$
|
|
13043
|
+
initialState$4.path = searchPath;
|
|
12429
13044
|
}
|
|
12430
13045
|
|
|
12431
|
-
var _useReducer = useReducer(guillotinaReducer, initialState$
|
|
13046
|
+
var _useReducer = useReducer(guillotinaReducer, initialState$4),
|
|
12432
13047
|
state = _useReducer[0],
|
|
12433
13048
|
dispatch = _useReducer[1];
|
|
12434
13049
|
|
|
@@ -12580,7 +13195,7 @@ var ERRORS = {
|
|
|
12580
13195
|
failed_to_fetch: 'Failed to fetch data: Backend not running?',
|
|
12581
13196
|
invalid_credentials: 'Failed! Invalid credentials'
|
|
12582
13197
|
};
|
|
12583
|
-
var initialState$
|
|
13198
|
+
var initialState$5 = {
|
|
12584
13199
|
username: '',
|
|
12585
13200
|
password: '',
|
|
12586
13201
|
loading: undefined,
|
|
@@ -12593,7 +13208,7 @@ var Login = function Login(_ref) {
|
|
|
12593
13208
|
auth = _ref.auth,
|
|
12594
13209
|
onLogin = _ref.onLogin;
|
|
12595
13210
|
|
|
12596
|
-
var _useSetState = useSetState(initialState$
|
|
13211
|
+
var _useSetState = useSetState(initialState$5),
|
|
12597
13212
|
state = _useSetState[0],
|
|
12598
13213
|
setState = _useSetState[1];
|
|
12599
13214
|
|
|
@@ -13074,5 +13689,5 @@ var Auth = /*#__PURE__*/function () {
|
|
|
13074
13689
|
return Auth;
|
|
13075
13690
|
}();
|
|
13076
13691
|
|
|
13077
|
-
export { AddItem, AddPermission, AllItemsCheckbox, ApplicationCtx, Auth, AuthContext, BaseForm, BehaviorNotImplemented, BehaviorsView, Button, Checkbox, ClientContext, ClientProvider, Config, Confirm, ContainerCtx, ContextToolbar, CreateButton, CreateContainer, DatabaseCtx, Delete, DownloadField, EditableField, EmailInput, FileUpload, Flash, FolderCtx, Form, FormBuilder, GroupCtx, GroupToolbar, GroupsCtx, Guillotina, GuillotinaClient, IAttachment, IImageAttachment, IMultiAttachment, IMultiImageAttachment, IMultiImageOrderedAttachment, IWorkflow, Icon, Input, InputList, Item, ItemCheckbox, ItemCtx, ItemModel, ItemTitle, ItemsActionsDropdown, ItemsActionsProvider, Layout, Link, Loading, Login, Modal, NotAllowed, Notification, Pagination, PanelActions, PanelAddons, PanelBehaviors, PanelItems, PanelNotImplemented, PanelPermissions, PanelProperties, PasswordInput, Path, PathTree, PermissionPrinperm, PermissionPrinrole, PermissionRoleperm, Permissions, PropertiesButtonView, PropertiesView, REGEX_EMAIL, REGEX_HEX_COLOR, REGEX_NUMBER, REGEX_URL, RItem, RemoveItems, RenderField, RenderFieldComponent, RequiredFieldsForm, RestClient, SearchInput, SearchLabels, SearchOptionsLabels, SearchVocabularyLabels, Select, Sharing, Table, TabsPanel, Tag, TagsWidget, TdLink, Textarea, TraversalContext, TraversalProvider, UserCtx, UserForm, UsersCtx, UsersToolbar, base64ToArrayBuffer, buildQs, classnames, defaultComponent, formatDate, generateUID, get$1 as get, getActionsObject, getClient, getNewId, isEmail, isEmpty, isHexColor, isNumber, isURL, lightFileReader, maxLength, messages$4 as messages, minLength, noop, notEmpty, parser, sleep, stringToSlug, toQueryString, useConfig, useCrudContext, useGuillotinaClient, useLocation, useRegistry, useRemoteField, useTraversal, useVocabulary };
|
|
13692
|
+
export { AddItem, AddPermission, AllItemsCheckbox, ApplicationCtx, Auth, AuthContext, BaseForm, BehaviorNotImplemented, BehaviorsView, Button, Checkbox, ClientContext, ClientProvider, Config, Confirm, ContainerCtx, ContextToolbar, CreateButton, CreateContainer, DatabaseCtx, Delete, DownloadField, EditComponent, EditableField, EmailInput, FileUpload, Flash, FolderCtx, Form, FormBuilder, GroupCtx, GroupToolbar, GroupsCtx, Guillotina, GuillotinaClient, IAttachment, IImageAttachment, IMultiAttachment, IMultiImageAttachment, IMultiImageOrderedAttachment, IWorkflow, Icon, Input, InputList, Item, ItemCheckbox, ItemCtx, ItemModel, ItemTitle, ItemsActionsDropdown, ItemsActionsProvider, Layout, Link, Loading, Login, Modal, NotAllowed, Notification, Pagination, PanelActions, PanelAddons, PanelBehaviors, PanelItems, PanelNotImplemented, PanelPermissions, PanelProperties, PasswordInput, Path, PathTree, PermissionPrinperm, PermissionPrinrole, PermissionRoleperm, Permissions, PropertiesButtonView, PropertiesView, REGEX_EMAIL, REGEX_HEX_COLOR, REGEX_NUMBER, REGEX_URL, RItem, RemoveItems, RenderField, RenderFieldComponent, RequiredFieldsForm, RestClient, SearchInput, SearchLabels, SearchOptionsLabels, SearchRenderField, SearchVocabularyLabels, Select, Sharing, Table, TabsPanel, Tag, TagsWidget, TdLink, Textarea, TraversalContext, TraversalProvider, UserCtx, UserForm, UsersCtx, UsersToolbar, VocabularyRenderField, base64ToArrayBuffer, buildQs, classnames, defaultComponent, formatDate, generateUID, get$1 as get, getActionsObject, getClient, getNewId, isEmail, isEmpty, isHexColor, isNumber, isURL, lightFileReader, maxLength, messages$4 as messages, minLength, noop, notEmpty, parser, sleep, stringToSlug, toQueryString, useConfig, useCrudContext, useGuillotinaClient, useLocation, useRegistry, useRemoteField, useTraversal, useVocabulary };
|
|
13078
13693
|
//# sourceMappingURL=react-gmi.esm.js.map
|