@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.modern.js
CHANGED
|
@@ -2418,6 +2418,37 @@ const Textarea = React.forwardRef((_ref, ref) => {
|
|
|
2418
2418
|
}, error ? error : ''));
|
|
2419
2419
|
});
|
|
2420
2420
|
|
|
2421
|
+
const defaultEvents = ['mousedown', 'touchstart'];
|
|
2422
|
+
|
|
2423
|
+
const on = (obj, ...args) => obj.addEventListener(...args);
|
|
2424
|
+
|
|
2425
|
+
const off = (obj, ...args) => obj.removeEventListener(...args);
|
|
2426
|
+
|
|
2427
|
+
function useClickAway(ref, onClickAway, events = defaultEvents) {
|
|
2428
|
+
const savedCallback = useRef(onClickAway);
|
|
2429
|
+
useEffect(() => {
|
|
2430
|
+
savedCallback.current = onClickAway;
|
|
2431
|
+
}, [onClickAway]);
|
|
2432
|
+
useEffect(() => {
|
|
2433
|
+
const handler = event => {
|
|
2434
|
+
const {
|
|
2435
|
+
current: el
|
|
2436
|
+
} = ref;
|
|
2437
|
+
el && !el.contains(event.target) && savedCallback.current(event);
|
|
2438
|
+
};
|
|
2439
|
+
|
|
2440
|
+
for (const eventName of events) {
|
|
2441
|
+
on(document, eventName, handler);
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
return () => {
|
|
2445
|
+
for (const eventName of events) {
|
|
2446
|
+
off(document, eventName, handler);
|
|
2447
|
+
}
|
|
2448
|
+
};
|
|
2449
|
+
}, [events, ref]);
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2421
2452
|
function debounce(func, wait) {
|
|
2422
2453
|
let timeout;
|
|
2423
2454
|
return function () {
|
|
@@ -2453,7 +2484,9 @@ const SearchInput = ({
|
|
|
2453
2484
|
dataTestWrapper: _dataTestWrapper = 'wrapperSearchInputTest',
|
|
2454
2485
|
dataTestSearchInput: _dataTestSearchInput = 'searchInputTest',
|
|
2455
2486
|
dataTestItem: _dataTestItem = 'searchInputItemTest',
|
|
2456
|
-
renderTextItemOption: _renderTextItemOption = null
|
|
2487
|
+
renderTextItemOption: _renderTextItemOption = null,
|
|
2488
|
+
typeNameQuery: _typeNameQuery = null,
|
|
2489
|
+
labelProperty: _labelProperty = 'id'
|
|
2457
2490
|
}) => {
|
|
2458
2491
|
const intl = useIntl();
|
|
2459
2492
|
const [options, setOptions] = useSetState(initialState);
|
|
@@ -2465,7 +2498,12 @@ const SearchInput = ({
|
|
|
2465
2498
|
PageSize,
|
|
2466
2499
|
SearchEngine
|
|
2467
2500
|
} = useConfig();
|
|
2501
|
+
const [valueLabel, setValueLabel] = useState(undefined);
|
|
2502
|
+
const [isLoadingData, setIsLoadingData] = useState(false);
|
|
2468
2503
|
const [uid] = useState(generateUID('search_input'));
|
|
2504
|
+
useClickAway(wrapperRef, () => {
|
|
2505
|
+
setIsOpen(false);
|
|
2506
|
+
});
|
|
2469
2507
|
|
|
2470
2508
|
const getHeight = () => {
|
|
2471
2509
|
if (wrapperRef && wrapperRef.current) {
|
|
@@ -2479,7 +2517,44 @@ const SearchInput = ({
|
|
|
2479
2517
|
};
|
|
2480
2518
|
};
|
|
2481
2519
|
|
|
2482
|
-
const delayedQuery =
|
|
2520
|
+
const delayedQuery = useCallback(debounce(value => handleSearch(0, false, value), 500), []);
|
|
2521
|
+
|
|
2522
|
+
const inicializeLabels = async () => {
|
|
2523
|
+
if (_labelProperty !== 'id' && value) {
|
|
2524
|
+
setIsLoadingData(true);
|
|
2525
|
+
let searchTermQs = [];
|
|
2526
|
+
const searchTermParsed = [`id`, value];
|
|
2527
|
+
const {
|
|
2528
|
+
get: getSearch
|
|
2529
|
+
} = _traversal.registry;
|
|
2530
|
+
const fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
|
|
2531
|
+
|
|
2532
|
+
const qsParsed = _traversal.client[fnName]({
|
|
2533
|
+
path: _traversal.path,
|
|
2534
|
+
start: 0,
|
|
2535
|
+
pageSize: PageSize,
|
|
2536
|
+
withDepth: false
|
|
2537
|
+
});
|
|
2538
|
+
|
|
2539
|
+
let typeNameParsed = [];
|
|
2540
|
+
|
|
2541
|
+
if (_typeNameQuery) {
|
|
2542
|
+
typeNameParsed = parser(`type_name__in=${_typeNameQuery}`);
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
if (_qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
|
|
2546
|
+
searchTermQs = buildQs([..._qs, searchTermParsed, ...qsParsed, ...typeNameParsed]);
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
const data = await _traversal.client.search(_path ? _path : _traversal.client.getContainerFromPath(_traversal.path), searchTermQs, false, false);
|
|
2550
|
+
const newValuesLabel = data.items.reduce((result, item) => {
|
|
2551
|
+
result[item.id] = get$1(item, _labelProperty, item.id);
|
|
2552
|
+
return result;
|
|
2553
|
+
}, {});
|
|
2554
|
+
setValueLabel(newValuesLabel);
|
|
2555
|
+
setIsLoadingData(false);
|
|
2556
|
+
}
|
|
2557
|
+
};
|
|
2483
2558
|
|
|
2484
2559
|
const handleSearch = async (page = 0, concat = false, value = '') => {
|
|
2485
2560
|
var _data$items_total;
|
|
@@ -2502,14 +2577,22 @@ const SearchInput = ({
|
|
|
2502
2577
|
let qsParsed = _traversal.client[fnName]({
|
|
2503
2578
|
path: _traversal.path,
|
|
2504
2579
|
start: page * PageSize,
|
|
2505
|
-
pageSize: PageSize
|
|
2580
|
+
pageSize: PageSize,
|
|
2581
|
+
withDepth: false
|
|
2506
2582
|
});
|
|
2507
2583
|
|
|
2508
|
-
|
|
2509
|
-
|
|
2584
|
+
let sortParsed = parser(`_sort_des=title`);
|
|
2585
|
+
let typeNameParsed = [];
|
|
2586
|
+
|
|
2587
|
+
if (_typeNameQuery) {
|
|
2588
|
+
typeNameParsed = parser(`type_name__in=${_typeNameQuery}`);
|
|
2510
2589
|
}
|
|
2511
2590
|
|
|
2512
|
-
|
|
2591
|
+
if (_qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
|
|
2592
|
+
searchTermQs = buildQs([..._qs, ...searchTermParsed, ...qsParsed, ...typeNameParsed, ...sortParsed]);
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
const data = await _traversal.client.search(_path ? _path : _traversal.client.getContainerFromPath(_traversal.path), searchTermQs, false, false);
|
|
2513
2596
|
const newItems = options.items && concat ? [...options.items, ...data.items] : data.items;
|
|
2514
2597
|
setOptions({
|
|
2515
2598
|
items: newItems != null ? newItems : [],
|
|
@@ -2527,18 +2610,24 @@ const SearchInput = ({
|
|
|
2527
2610
|
return item.title || item['@name'];
|
|
2528
2611
|
};
|
|
2529
2612
|
|
|
2530
|
-
|
|
2531
|
-
if (
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
})();
|
|
2613
|
+
useEffect(() => {
|
|
2614
|
+
if (value) {
|
|
2615
|
+
inicializeLabels();
|
|
2616
|
+
} else {
|
|
2617
|
+
setValueLabel({});
|
|
2536
2618
|
}
|
|
2537
|
-
}, [_path,
|
|
2619
|
+
}, [_path, value]);
|
|
2620
|
+
|
|
2621
|
+
if (valueLabel === undefined) {
|
|
2622
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2623
|
+
className: "spinner"
|
|
2624
|
+
});
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2538
2627
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
2539
2628
|
"data-test": _dataTestWrapper,
|
|
2540
2629
|
ref: wrapperRef,
|
|
2541
|
-
className: `dropdown ${isOpen ? 'is-active' : ''}`,
|
|
2630
|
+
className: `dropdown mb-2 ${isOpen ? 'is-active' : ''}`,
|
|
2542
2631
|
onBlur: ev => {
|
|
2543
2632
|
if (!ev.currentTarget.contains(ev.relatedTarget)) {
|
|
2544
2633
|
if (searchTerm !== '') {
|
|
@@ -2546,7 +2635,7 @@ const SearchInput = ({
|
|
|
2546
2635
|
setOptions(initialState);
|
|
2547
2636
|
}
|
|
2548
2637
|
|
|
2549
|
-
setIsOpen(
|
|
2638
|
+
setIsOpen(false);
|
|
2550
2639
|
}
|
|
2551
2640
|
}
|
|
2552
2641
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -2554,12 +2643,16 @@ const SearchInput = ({
|
|
|
2554
2643
|
}, /*#__PURE__*/React.createElement("button", {
|
|
2555
2644
|
className: `button ${_btnClass}`,
|
|
2556
2645
|
onClick: ev => {
|
|
2557
|
-
ev.
|
|
2646
|
+
ev.target.blur();
|
|
2558
2647
|
setIsOpen(!isOpen);
|
|
2648
|
+
|
|
2649
|
+
if (!options.loading && !options.items) {
|
|
2650
|
+
handleSearch(options.page);
|
|
2651
|
+
}
|
|
2559
2652
|
},
|
|
2560
2653
|
"aria-haspopup": "true",
|
|
2561
2654
|
"aria-controls": "dropdown-menu"
|
|
2562
|
-
}, /*#__PURE__*/React.createElement("span", null, value
|
|
2655
|
+
}, /*#__PURE__*/React.createElement("span", null, value ? get$1(valueLabel, value, value) : intl.formatMessage(genericMessages.choose)), /*#__PURE__*/React.createElement("span", {
|
|
2563
2656
|
className: "icon"
|
|
2564
2657
|
}, /*#__PURE__*/React.createElement("i", {
|
|
2565
2658
|
className: "fas fa-angle-down",
|
|
@@ -2587,12 +2680,16 @@ const SearchInput = ({
|
|
|
2587
2680
|
})), /*#__PURE__*/React.createElement("hr", {
|
|
2588
2681
|
className: "dropdown-divider"
|
|
2589
2682
|
}), options.loading && /*#__PURE__*/React.createElement(Loading, null), options.items && options.items.map(item => {
|
|
2590
|
-
return /*#__PURE__*/React.createElement("
|
|
2591
|
-
|
|
2592
|
-
className: `dropdown-item editable ${value && value.id === item.id ? 'is-active' : ''}`,
|
|
2683
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2684
|
+
className: `dropdown-item editable ${value === item.id ? 'is-active' : ''}`,
|
|
2593
2685
|
"data-test": `${_dataTestItem}-${item.id}`,
|
|
2594
|
-
onMouseDown:
|
|
2595
|
-
|
|
2686
|
+
onMouseDown: ev => {
|
|
2687
|
+
ev.preventDefault();
|
|
2688
|
+
|
|
2689
|
+
if (onChange) {
|
|
2690
|
+
onChange(item.id);
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2596
2693
|
setIsOpen(false);
|
|
2597
2694
|
},
|
|
2598
2695
|
key: item.path
|
|
@@ -2615,11 +2712,20 @@ const SearchInput = ({
|
|
|
2615
2712
|
};
|
|
2616
2713
|
SearchInput.propTypes = {
|
|
2617
2714
|
onChange: PropTypes.func,
|
|
2618
|
-
value: PropTypes.
|
|
2619
|
-
client: PropTypes.object,
|
|
2715
|
+
value: PropTypes.string,
|
|
2620
2716
|
path: PropTypes.string,
|
|
2621
|
-
|
|
2622
|
-
|
|
2717
|
+
btnClass: PropTypes.string,
|
|
2718
|
+
error: PropTypes.string,
|
|
2719
|
+
errorZoneClassName: PropTypes.string,
|
|
2720
|
+
traversal: PropTypes.object,
|
|
2721
|
+
qs: PropTypes.array,
|
|
2722
|
+
queryCondition: PropTypes.string,
|
|
2723
|
+
dataTestWrapper: PropTypes.string,
|
|
2724
|
+
dataTestSearchInput: PropTypes.string,
|
|
2725
|
+
dataTestItem: PropTypes.string,
|
|
2726
|
+
renderTextItemOption: PropTypes.func,
|
|
2727
|
+
typeNameQuery: PropTypes.string,
|
|
2728
|
+
labelProperty: PropTypes.string
|
|
2623
2729
|
};
|
|
2624
2730
|
|
|
2625
2731
|
const InputList = forwardRef(({
|
|
@@ -2668,37 +2774,6 @@ const InputList = forwardRef(({
|
|
|
2668
2774
|
}));
|
|
2669
2775
|
});
|
|
2670
2776
|
|
|
2671
|
-
const defaultEvents = ['mousedown', 'touchstart'];
|
|
2672
|
-
|
|
2673
|
-
const on = (obj, ...args) => obj.addEventListener(...args);
|
|
2674
|
-
|
|
2675
|
-
const off = (obj, ...args) => obj.removeEventListener(...args);
|
|
2676
|
-
|
|
2677
|
-
function useClickAway(ref, onClickAway, events = defaultEvents) {
|
|
2678
|
-
const savedCallback = useRef(onClickAway);
|
|
2679
|
-
useEffect(() => {
|
|
2680
|
-
savedCallback.current = onClickAway;
|
|
2681
|
-
}, [onClickAway]);
|
|
2682
|
-
useEffect(() => {
|
|
2683
|
-
const handler = event => {
|
|
2684
|
-
const {
|
|
2685
|
-
current: el
|
|
2686
|
-
} = ref;
|
|
2687
|
-
el && !el.contains(event.target) && savedCallback.current(event);
|
|
2688
|
-
};
|
|
2689
|
-
|
|
2690
|
-
for (const eventName of events) {
|
|
2691
|
-
on(document, eventName, handler);
|
|
2692
|
-
}
|
|
2693
|
-
|
|
2694
|
-
return () => {
|
|
2695
|
-
for (const eventName of events) {
|
|
2696
|
-
off(document, eventName, handler);
|
|
2697
|
-
}
|
|
2698
|
-
};
|
|
2699
|
-
}, [events, ref]);
|
|
2700
|
-
}
|
|
2701
|
-
|
|
2702
2777
|
function Dropdown(_ref) {
|
|
2703
2778
|
let {
|
|
2704
2779
|
children,
|
|
@@ -3036,13 +3111,15 @@ function useVocabulary(vocabularyName, path) {
|
|
|
3036
3111
|
const plain = ['string', 'number', 'boolean'];
|
|
3037
3112
|
function RenderField({
|
|
3038
3113
|
value,
|
|
3039
|
-
Widget
|
|
3114
|
+
Widget,
|
|
3115
|
+
schema
|
|
3040
3116
|
}) {
|
|
3041
3117
|
if (value === null || value === undefined) return '';
|
|
3042
3118
|
|
|
3043
3119
|
if (Widget) {
|
|
3044
3120
|
return /*#__PURE__*/React.createElement(Widget, {
|
|
3045
|
-
value: value
|
|
3121
|
+
value: value,
|
|
3122
|
+
schema: schema
|
|
3046
3123
|
});
|
|
3047
3124
|
}
|
|
3048
3125
|
|
|
@@ -3084,6 +3161,131 @@ const FieldValue = ({
|
|
|
3084
3161
|
value: value
|
|
3085
3162
|
})));
|
|
3086
3163
|
|
|
3164
|
+
const DEFAULT_VALUE_NO_EDITABLE_FIELD = ' -- ';
|
|
3165
|
+
|
|
3166
|
+
const getDefaultValueEditableField = intl => {
|
|
3167
|
+
return intl.formatMessage({
|
|
3168
|
+
id: "default_value_editable_field",
|
|
3169
|
+
defaultMessage: [{
|
|
3170
|
+
"type": 0,
|
|
3171
|
+
"value": "Click to edit"
|
|
3172
|
+
}]
|
|
3173
|
+
});
|
|
3174
|
+
};
|
|
3175
|
+
|
|
3176
|
+
const SearchRenderField = ({
|
|
3177
|
+
schema,
|
|
3178
|
+
value,
|
|
3179
|
+
modifyContent
|
|
3180
|
+
}) => {
|
|
3181
|
+
const [valuesLabels, setValuesLabels] = useState([]);
|
|
3182
|
+
const [isLoadingData, setIsLoadingData] = useState(false);
|
|
3183
|
+
const traversal = useTraversal();
|
|
3184
|
+
const {
|
|
3185
|
+
SearchEngine
|
|
3186
|
+
} = useConfig();
|
|
3187
|
+
useEffect(() => {
|
|
3188
|
+
const fetchData = async valuesToSearch => {
|
|
3189
|
+
setIsLoadingData(true);
|
|
3190
|
+
let searchTermQs = [];
|
|
3191
|
+
const searchTermParsed = ['__or', `id=${valuesToSearch.join('%26id=')}`];
|
|
3192
|
+
const {
|
|
3193
|
+
get: getSearch
|
|
3194
|
+
} = traversal.registry;
|
|
3195
|
+
const fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
|
|
3196
|
+
const qsParsed = traversal.client[fnName]({
|
|
3197
|
+
path: traversal.path,
|
|
3198
|
+
start: 0,
|
|
3199
|
+
pageSize: 100,
|
|
3200
|
+
withDepth: false
|
|
3201
|
+
});
|
|
3202
|
+
|
|
3203
|
+
if (searchTermParsed.length > 0 || qsParsed.length > 0) {
|
|
3204
|
+
searchTermQs = buildQs([searchTermParsed, ...qsParsed]);
|
|
3205
|
+
}
|
|
3206
|
+
|
|
3207
|
+
const data = await traversal.client.search(traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false, 0, 100);
|
|
3208
|
+
const newValuesLabel = data.items.map(item => {
|
|
3209
|
+
var _schema$labelProperty;
|
|
3210
|
+
|
|
3211
|
+
return get$1(item, (_schema$labelProperty = schema == null ? void 0 : schema.labelProperty) != null ? _schema$labelProperty : 'title', item.id);
|
|
3212
|
+
});
|
|
3213
|
+
setValuesLabels(newValuesLabel);
|
|
3214
|
+
setIsLoadingData(false);
|
|
3215
|
+
};
|
|
3216
|
+
|
|
3217
|
+
let valuesToSearch = value;
|
|
3218
|
+
|
|
3219
|
+
if (typeof valuesToSearch === 'string') {
|
|
3220
|
+
valuesToSearch = [valuesToSearch];
|
|
3221
|
+
}
|
|
3222
|
+
|
|
3223
|
+
if (valuesToSearch !== undefined && valuesToSearch.length > 0) {
|
|
3224
|
+
fetchData(valuesToSearch);
|
|
3225
|
+
} else {
|
|
3226
|
+
setValuesLabels([]);
|
|
3227
|
+
}
|
|
3228
|
+
}, [value]);
|
|
3229
|
+
|
|
3230
|
+
const getRenderValue = () => {
|
|
3231
|
+
console.log('get render values', value, valuesLabels);
|
|
3232
|
+
|
|
3233
|
+
if (value === undefined) {
|
|
3234
|
+
if (modifyContent) {
|
|
3235
|
+
return DEFAULT_VALUE_EDITABLE_FIELD;
|
|
3236
|
+
}
|
|
3237
|
+
|
|
3238
|
+
return DEFAULT_VALUE_NO_EDITABLE_FIELD;
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3241
|
+
if (isLoadingData) {
|
|
3242
|
+
return 'Loading...';
|
|
3243
|
+
}
|
|
3244
|
+
|
|
3245
|
+
return valuesLabels;
|
|
3246
|
+
};
|
|
3247
|
+
|
|
3248
|
+
return /*#__PURE__*/React.createElement(RenderField, {
|
|
3249
|
+
value: getRenderValue()
|
|
3250
|
+
});
|
|
3251
|
+
};
|
|
3252
|
+
const VocabularyRenderField = ({
|
|
3253
|
+
schema,
|
|
3254
|
+
value,
|
|
3255
|
+
modifyContent
|
|
3256
|
+
}) => {
|
|
3257
|
+
var _schema$items;
|
|
3258
|
+
|
|
3259
|
+
const intl = useIntl();
|
|
3260
|
+
const DEFAULT_VALUE_EDITABLE_FIELD = getDefaultValueEditableField(intl);
|
|
3261
|
+
const vocabularyName = (schema == null ? void 0 : (_schema$items = schema.items) == null ? void 0 : _schema$items.vocabularyName) || (schema == null ? void 0 : schema.vocabularyName);
|
|
3262
|
+
const vocabulary = useVocabulary(vocabularyName);
|
|
3263
|
+
|
|
3264
|
+
const getRenderProps = () => {
|
|
3265
|
+
const renderProps = {
|
|
3266
|
+
value: value != null ? value : modifyContent ? DEFAULT_VALUE_EDITABLE_FIELD : DEFAULT_VALUE_NO_EDITABLE_FIELD
|
|
3267
|
+
};
|
|
3268
|
+
|
|
3269
|
+
if (schema != null && schema.vocabularyName) {
|
|
3270
|
+
var _vocabularyValue$titl;
|
|
3271
|
+
|
|
3272
|
+
const vocabularyValue = get$1(vocabulary, 'data.items', []).find(item => item.token === value);
|
|
3273
|
+
renderProps['value'] = (_vocabularyValue$titl = vocabularyValue == null ? void 0 : vocabularyValue.title) != null ? _vocabularyValue$titl : '';
|
|
3274
|
+
} else {
|
|
3275
|
+
var _renderProps$value;
|
|
3276
|
+
|
|
3277
|
+
renderProps['value'] = ((_renderProps$value = renderProps['value']) != null ? _renderProps$value : []).map(value => {
|
|
3278
|
+
var _get$find$title, _get$find;
|
|
3279
|
+
|
|
3280
|
+
return (_get$find$title = (_get$find = get$1(vocabulary, 'data.items', []).find(item => item.token === value)) == null ? void 0 : _get$find.title) != null ? _get$find$title : '';
|
|
3281
|
+
});
|
|
3282
|
+
}
|
|
3283
|
+
|
|
3284
|
+
return renderProps;
|
|
3285
|
+
};
|
|
3286
|
+
|
|
3287
|
+
return /*#__PURE__*/React.createElement(RenderField, getRenderProps());
|
|
3288
|
+
};
|
|
3087
3289
|
function RenderFieldComponent({
|
|
3088
3290
|
schema,
|
|
3089
3291
|
field,
|
|
@@ -3091,17 +3293,10 @@ function RenderFieldComponent({
|
|
|
3091
3293
|
modifyContent
|
|
3092
3294
|
}) {
|
|
3093
3295
|
const intl = useIntl();
|
|
3094
|
-
const DEFAULT_VALUE_EDITABLE_FIELD = intl
|
|
3095
|
-
id: "default_value_editable_field",
|
|
3096
|
-
defaultMessage: [{
|
|
3097
|
-
"type": 0,
|
|
3098
|
-
"value": "Click to edit"
|
|
3099
|
-
}]
|
|
3100
|
-
});
|
|
3101
|
-
const DEFAULT_VALUE_NO_EDITABLE_FIELD = ' -- ';
|
|
3296
|
+
const DEFAULT_VALUE_EDITABLE_FIELD = getDefaultValueEditableField(intl);
|
|
3102
3297
|
|
|
3103
3298
|
const getRenderProps = () => {
|
|
3104
|
-
var _schema$
|
|
3299
|
+
var _schema$items2;
|
|
3105
3300
|
|
|
3106
3301
|
const renderProps = {
|
|
3107
3302
|
value: val != null ? val : modifyContent ? DEFAULT_VALUE_EDITABLE_FIELD : DEFAULT_VALUE_NO_EDITABLE_FIELD
|
|
@@ -3119,46 +3314,558 @@ function RenderFieldComponent({
|
|
|
3119
3314
|
renderProps['value'] = (_val$toString = val == null ? void 0 : val.toString()) != null ? _val$toString : renderProps['value'];
|
|
3120
3315
|
} else if (val && (schema == null ? void 0 : schema.type) === 'datetime') {
|
|
3121
3316
|
renderProps['value'] = new Date(val).toLocaleString();
|
|
3122
|
-
} else if (schema != null && (_schema$
|
|
3123
|
-
|
|
3317
|
+
} else if (schema != null && (_schema$items2 = schema.items) != null && _schema$items2.vocabularyName || schema != null && schema.vocabularyName) {
|
|
3318
|
+
renderProps['Widget'] = VocabularyRenderField;
|
|
3319
|
+
renderProps['schema'] = schema;
|
|
3320
|
+
} else if ((schema == null ? void 0 : schema.widget) === 'search' || (schema == null ? void 0 : schema.widget) === 'search_list') {
|
|
3321
|
+
renderProps['Widget'] = SearchRenderField;
|
|
3322
|
+
renderProps['value'] = val;
|
|
3323
|
+
renderProps['schema'] = schema;
|
|
3324
|
+
}
|
|
3325
|
+
|
|
3326
|
+
return renderProps;
|
|
3327
|
+
};
|
|
3328
|
+
|
|
3329
|
+
return /*#__PURE__*/React.createElement(RenderField, getRenderProps());
|
|
3330
|
+
}
|
|
3331
|
+
|
|
3332
|
+
const SelectVocabulary = React.forwardRef((_ref, ref) => {
|
|
3333
|
+
let {
|
|
3334
|
+
vocabularyName,
|
|
3335
|
+
className,
|
|
3336
|
+
classWrap,
|
|
3337
|
+
val,
|
|
3338
|
+
dataTest,
|
|
3339
|
+
multiple
|
|
3340
|
+
} = _ref,
|
|
3341
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["vocabularyName", "className", "classWrap", "val", "dataTest", "multiple"]);
|
|
3342
|
+
|
|
3343
|
+
const vocabulary = useVocabulary(vocabularyName);
|
|
3344
|
+
|
|
3345
|
+
const getOptions = () => {
|
|
3346
|
+
if (get$1(vocabulary, 'data.items', null)) {
|
|
3347
|
+
const vocData = vocabulary.data.items.map(item => {
|
|
3348
|
+
var _item$title$default;
|
|
3349
|
+
|
|
3350
|
+
return {
|
|
3351
|
+
text: (_item$title$default = item.title.default) != null ? _item$title$default : item.title,
|
|
3352
|
+
value: item.token
|
|
3353
|
+
};
|
|
3354
|
+
});
|
|
3355
|
+
return vocData;
|
|
3356
|
+
}
|
|
3357
|
+
|
|
3358
|
+
return [];
|
|
3359
|
+
};
|
|
3360
|
+
|
|
3361
|
+
const getProps = () => {
|
|
3362
|
+
if (multiple) {
|
|
3363
|
+
const currentValue = val || [];
|
|
3364
|
+
return {
|
|
3365
|
+
multiple: true,
|
|
3366
|
+
size: 5,
|
|
3367
|
+
value: currentValue,
|
|
3368
|
+
options: getOptions()
|
|
3369
|
+
};
|
|
3370
|
+
}
|
|
3371
|
+
|
|
3372
|
+
return {
|
|
3373
|
+
value: val != null ? val : '',
|
|
3374
|
+
appendDefault: true,
|
|
3375
|
+
options: getOptions()
|
|
3376
|
+
};
|
|
3377
|
+
};
|
|
3378
|
+
|
|
3379
|
+
if (vocabulary.data === undefined || vocabulary.loading) {
|
|
3380
|
+
return /*#__PURE__*/React.createElement("div", null);
|
|
3381
|
+
}
|
|
3124
3382
|
|
|
3125
|
-
|
|
3126
|
-
|
|
3383
|
+
return /*#__PURE__*/React.createElement(Select, _extends({}, getProps(), {
|
|
3384
|
+
className: className,
|
|
3385
|
+
classWrap: classWrap || 'is-fullwidth',
|
|
3386
|
+
dataTest: dataTest,
|
|
3387
|
+
ref: ref
|
|
3388
|
+
}, rest));
|
|
3389
|
+
});
|
|
3390
|
+
Select.propTypes = {
|
|
3391
|
+
error: PropTypes.string,
|
|
3392
|
+
disabled: PropTypes.bool,
|
|
3393
|
+
loading: PropTypes.bool,
|
|
3394
|
+
isSubmitted: PropTypes.bool,
|
|
3395
|
+
size: PropTypes.number,
|
|
3396
|
+
onChange: PropTypes.func,
|
|
3397
|
+
multiple: PropTypes.bool,
|
|
3398
|
+
className: PropTypes.string,
|
|
3399
|
+
vocabularyName: PropTypes.string
|
|
3400
|
+
};
|
|
3127
3401
|
|
|
3128
|
-
|
|
3129
|
-
|
|
3402
|
+
function debounce$1(func, wait) {
|
|
3403
|
+
let timeout;
|
|
3404
|
+
return function () {
|
|
3405
|
+
const context = this;
|
|
3406
|
+
const args = arguments;
|
|
3407
|
+
|
|
3408
|
+
const later = function later() {
|
|
3409
|
+
timeout = null;
|
|
3410
|
+
func.apply(context, args);
|
|
3411
|
+
};
|
|
3412
|
+
|
|
3413
|
+
clearTimeout(timeout);
|
|
3414
|
+
timeout = setTimeout(later, wait);
|
|
3415
|
+
};
|
|
3416
|
+
}
|
|
3417
|
+
|
|
3418
|
+
const initialState$1 = {
|
|
3419
|
+
page: 0,
|
|
3420
|
+
items: undefined,
|
|
3421
|
+
loading: false,
|
|
3422
|
+
items_total: 0
|
|
3423
|
+
};
|
|
3424
|
+
const SearchInputList = ({
|
|
3425
|
+
onChange,
|
|
3426
|
+
error,
|
|
3427
|
+
errorZoneClassName,
|
|
3428
|
+
traversal: _traversal = null,
|
|
3429
|
+
path: _path = null,
|
|
3430
|
+
qs: _qs = [],
|
|
3431
|
+
queryCondition: _queryCondition = 'id__in',
|
|
3432
|
+
value,
|
|
3433
|
+
btnClass: _btnClass = '',
|
|
3434
|
+
dataTestWrapper: _dataTestWrapper = 'wrapperSearchInputTest',
|
|
3435
|
+
dataTestSearchInput: _dataTestSearchInput = 'searchInputTest',
|
|
3436
|
+
dataTestItem: _dataTestItem = 'searchInputItemTest',
|
|
3437
|
+
renderTextItemOption: _renderTextItemOption = null,
|
|
3438
|
+
typeNameQuery: _typeNameQuery = null,
|
|
3439
|
+
labelProperty: _labelProperty = 'id'
|
|
3440
|
+
}) => {
|
|
3441
|
+
const intl = useIntl();
|
|
3442
|
+
const [options, setOptions] = useSetState(initialState$1);
|
|
3443
|
+
const [valuesLabel, setValuesLabels] = useState(undefined);
|
|
3444
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
3445
|
+
const [searchTerm, setSearchTerm] = React.useState('');
|
|
3446
|
+
const inputRef = React.useRef(null);
|
|
3447
|
+
const wrapperRef = React.useRef(null);
|
|
3448
|
+
const {
|
|
3449
|
+
PageSize,
|
|
3450
|
+
SearchEngine
|
|
3451
|
+
} = useConfig();
|
|
3452
|
+
const [isLoadingData, setIsLoadingData] = useState(false);
|
|
3453
|
+
const [uid] = useState(generateUID('search_input'));
|
|
3454
|
+
useClickAway(wrapperRef, () => {
|
|
3455
|
+
setIsOpen(false);
|
|
3456
|
+
});
|
|
3457
|
+
|
|
3458
|
+
const getHeight = () => {
|
|
3459
|
+
if (wrapperRef && wrapperRef.current) {
|
|
3460
|
+
return {
|
|
3461
|
+
maxHeight: `${window.innerHeight - wrapperRef.current.getBoundingClientRect().top - 100}px`
|
|
3462
|
+
};
|
|
3463
|
+
}
|
|
3464
|
+
|
|
3465
|
+
return {
|
|
3466
|
+
maxHeight: 'auto'
|
|
3467
|
+
};
|
|
3468
|
+
};
|
|
3469
|
+
|
|
3470
|
+
const delayedQuery = useCallback(debounce$1(value => handleSearch(0, false, value), 500), []);
|
|
3471
|
+
|
|
3472
|
+
const handleSearch = async (page = 0, concat = false, value = '') => {
|
|
3473
|
+
var _data$items_total;
|
|
3474
|
+
|
|
3475
|
+
setOptions({
|
|
3476
|
+
loading: true
|
|
3477
|
+
});
|
|
3478
|
+
let searchTermQs = [];
|
|
3479
|
+
let searchTermParsed = [];
|
|
3480
|
+
|
|
3481
|
+
if (value !== '') {
|
|
3482
|
+
searchTermParsed = parser(`${_queryCondition}=${value}`);
|
|
3483
|
+
}
|
|
3484
|
+
|
|
3485
|
+
const {
|
|
3486
|
+
get
|
|
3487
|
+
} = _traversal.registry;
|
|
3488
|
+
const fnName = get('searchEngineQueryParamsFunction', SearchEngine);
|
|
3489
|
+
|
|
3490
|
+
let qsParsed = _traversal.client[fnName]({
|
|
3491
|
+
path: _traversal.path,
|
|
3492
|
+
start: page * PageSize,
|
|
3493
|
+
pageSize: PageSize,
|
|
3494
|
+
withDepth: false
|
|
3495
|
+
});
|
|
3496
|
+
|
|
3497
|
+
let sortParsed = parser(`_sort_des=title`);
|
|
3498
|
+
let typeNameParsed = [];
|
|
3499
|
+
|
|
3500
|
+
if (_typeNameQuery) {
|
|
3501
|
+
typeNameParsed = parser(`type_name__in=${_typeNameQuery}`);
|
|
3502
|
+
}
|
|
3503
|
+
|
|
3504
|
+
if (_qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
|
|
3505
|
+
searchTermQs = buildQs([..._qs, ...searchTermParsed, ...qsParsed, ...typeNameParsed, ...sortParsed]);
|
|
3506
|
+
}
|
|
3507
|
+
|
|
3508
|
+
const data = await _traversal.client.search(_path ? _path : _traversal.client.getContainerFromPath(_traversal.path), searchTermQs, false, false);
|
|
3509
|
+
const newItems = options.items && concat ? [...options.items, ...data.items] : data.items;
|
|
3510
|
+
setOptions({
|
|
3511
|
+
items: newItems != null ? newItems : [],
|
|
3512
|
+
loading: false,
|
|
3513
|
+
items_total: (_data$items_total = data.items_total) != null ? _data$items_total : 0,
|
|
3514
|
+
page: page
|
|
3515
|
+
});
|
|
3516
|
+
};
|
|
3517
|
+
|
|
3518
|
+
const inicializeLabels = async () => {
|
|
3519
|
+
if (_labelProperty !== 'id' && value.length > 0) {
|
|
3520
|
+
setIsLoadingData(true);
|
|
3521
|
+
let searchTermQs = [];
|
|
3522
|
+
const searchTermParsed = ['__or', `id=${value.join('%26id=')}`];
|
|
3523
|
+
const {
|
|
3524
|
+
get: getSearch
|
|
3525
|
+
} = _traversal.registry;
|
|
3526
|
+
const fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
|
|
3527
|
+
|
|
3528
|
+
const qsParsed = _traversal.client[fnName]({
|
|
3529
|
+
path: _traversal.path,
|
|
3530
|
+
start: 0,
|
|
3531
|
+
pageSize: 100,
|
|
3532
|
+
withDepth: false
|
|
3533
|
+
});
|
|
3534
|
+
|
|
3535
|
+
let typeNameParsed = [];
|
|
3536
|
+
|
|
3537
|
+
if (_typeNameQuery) {
|
|
3538
|
+
typeNameParsed = parser(`type_name__in=${_typeNameQuery}`);
|
|
3539
|
+
}
|
|
3540
|
+
|
|
3541
|
+
if (_qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
|
|
3542
|
+
searchTermQs = buildQs([..._qs, searchTermParsed, ...qsParsed, ...typeNameParsed]);
|
|
3543
|
+
}
|
|
3544
|
+
|
|
3545
|
+
const data = await _traversal.client.search(_path ? _path : _traversal.client.getContainerFromPath(_traversal.path), searchTermQs, false, false, 0, 100);
|
|
3546
|
+
const newValuesLabel = data.items.reduce((result, item) => {
|
|
3547
|
+
result[item.id] = get$1(item, _labelProperty, item.id);
|
|
3548
|
+
return result;
|
|
3549
|
+
}, {});
|
|
3550
|
+
setValuesLabels(newValuesLabel);
|
|
3551
|
+
setIsLoadingData(false);
|
|
3552
|
+
}
|
|
3553
|
+
};
|
|
3554
|
+
|
|
3555
|
+
const renderTextItemOptionFn = item => {
|
|
3556
|
+
if (_renderTextItemOption) {
|
|
3557
|
+
return _renderTextItemOption(item);
|
|
3558
|
+
}
|
|
3559
|
+
|
|
3560
|
+
return item.title || item['@name'];
|
|
3561
|
+
};
|
|
3562
|
+
|
|
3563
|
+
React.useEffect(() => {
|
|
3564
|
+
if (!options.loading && !options.items && value.length > 0) {
|
|
3565
|
+
inicializeLabels();
|
|
3566
|
+
} else if (value.length === 0) {
|
|
3567
|
+
setValuesLabels({});
|
|
3568
|
+
}
|
|
3569
|
+
}, [_path, options.loading, options.items]);
|
|
3570
|
+
|
|
3571
|
+
if (isLoadingData || valuesLabel === undefined) {
|
|
3572
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
3573
|
+
className: "spinner"
|
|
3574
|
+
});
|
|
3575
|
+
}
|
|
3576
|
+
|
|
3577
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
3578
|
+
className: "tags mb-2"
|
|
3579
|
+
}, value.map((tag, index) => /*#__PURE__*/React.createElement("div", {
|
|
3580
|
+
key: `input_list_${tag}_${index}`,
|
|
3581
|
+
className: "tag is-info is-medium"
|
|
3582
|
+
}, get$1(valuesLabel, tag, tag), /*#__PURE__*/React.createElement("button", {
|
|
3583
|
+
className: "delete is-small",
|
|
3584
|
+
onClick: ev => {
|
|
3585
|
+
ev.stopPropagation();
|
|
3586
|
+
ev.preventDefault();
|
|
3587
|
+
onChange([...value.filter(tag => value.indexOf(tag) !== index)]);
|
|
3588
|
+
}
|
|
3589
|
+
})))), /*#__PURE__*/React.createElement("div", {
|
|
3590
|
+
"data-test": _dataTestWrapper,
|
|
3591
|
+
ref: wrapperRef,
|
|
3592
|
+
className: `dropdown mb-2 ${isOpen ? 'is-active' : ''}`,
|
|
3593
|
+
onBlur: ev => {
|
|
3594
|
+
if (!ev.currentTarget.contains(ev.relatedTarget)) {
|
|
3595
|
+
if (searchTerm !== '') {
|
|
3596
|
+
setSearchTerm('');
|
|
3597
|
+
setOptions(initialState$1);
|
|
3598
|
+
}
|
|
3599
|
+
|
|
3600
|
+
setIsOpen(false);
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
3604
|
+
className: "dropdown-trigger"
|
|
3605
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
3606
|
+
className: `button ${_btnClass}`,
|
|
3607
|
+
onClick: ev => {
|
|
3608
|
+
ev.preventDefault();
|
|
3609
|
+
setIsOpen(!isOpen);
|
|
3610
|
+
|
|
3611
|
+
if (!options.loading && !options.items) {
|
|
3612
|
+
handleSearch(options.page);
|
|
3613
|
+
}
|
|
3614
|
+
},
|
|
3615
|
+
"aria-haspopup": "true",
|
|
3616
|
+
"aria-controls": "dropdown-menu"
|
|
3617
|
+
}, /*#__PURE__*/React.createElement("span", null, intl.formatMessage(genericMessages.choose)), /*#__PURE__*/React.createElement("span", {
|
|
3618
|
+
className: "icon"
|
|
3619
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
3620
|
+
className: "fas fa-angle-down",
|
|
3621
|
+
"aria-hidden": "true"
|
|
3622
|
+
})))), /*#__PURE__*/React.createElement("div", {
|
|
3623
|
+
className: "dropdown-menu",
|
|
3624
|
+
id: "dropdown-menu",
|
|
3625
|
+
role: "menu",
|
|
3626
|
+
style: getHeight()
|
|
3627
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
3628
|
+
className: "dropdown-content"
|
|
3629
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
3630
|
+
className: "dropdown-item"
|
|
3631
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
3632
|
+
ref: inputRef,
|
|
3633
|
+
"data-test": _dataTestSearchInput,
|
|
3634
|
+
className: "input",
|
|
3635
|
+
type: "text",
|
|
3636
|
+
placeholder: intl.formatMessage(genericMessages.search),
|
|
3637
|
+
value: searchTerm,
|
|
3638
|
+
onChange: ev => {
|
|
3639
|
+
delayedQuery(ev.target.value);
|
|
3640
|
+
setSearchTerm(ev.target.value);
|
|
3641
|
+
}
|
|
3642
|
+
})), /*#__PURE__*/React.createElement("hr", {
|
|
3643
|
+
className: "dropdown-divider"
|
|
3644
|
+
}), options.loading && /*#__PURE__*/React.createElement(Loading, null), options.items && options.items.map(item => {
|
|
3645
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
3646
|
+
className: `dropdown-item editable ${value && value.id === item.id ? 'is-active' : ''}`,
|
|
3647
|
+
"data-test": `${_dataTestItem}-${item.id}`,
|
|
3648
|
+
onMouseDown: ev => {
|
|
3649
|
+
ev.stopPropagation();
|
|
3650
|
+
ev.preventDefault();
|
|
3651
|
+
|
|
3652
|
+
if (onChange && !value.includes(item.id)) {
|
|
3653
|
+
setValuesLabels(_extends({}, valuesLabel, {
|
|
3654
|
+
[item.id]: get$1(item, _labelProperty, item.id)
|
|
3655
|
+
}));
|
|
3656
|
+
onChange([...value, item.id]);
|
|
3657
|
+
}
|
|
3658
|
+
},
|
|
3659
|
+
key: item.path
|
|
3660
|
+
}, renderTextItemOptionFn(item));
|
|
3661
|
+
}), options.items && options.items.length === 0 && /*#__PURE__*/React.createElement("div", {
|
|
3662
|
+
className: "dropdown-item"
|
|
3663
|
+
}, intl.formatMessage(genericMessages.no_results)), options.items && options.items_total > options.items.length && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("hr", {
|
|
3664
|
+
className: "dropdown-divider"
|
|
3665
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
3666
|
+
className: "dropdown-item editable",
|
|
3667
|
+
onMouseDown: ev => {
|
|
3668
|
+
ev.stopPropagation();
|
|
3669
|
+
ev.preventDefault();
|
|
3670
|
+
handleSearch(options.page + 1, true);
|
|
3671
|
+
}
|
|
3672
|
+
}, intl.formatMessage(genericMessages.load_more)))))), error && /*#__PURE__*/React.createElement(ErrorZone, {
|
|
3673
|
+
className: errorZoneClassName,
|
|
3674
|
+
id: uid
|
|
3675
|
+
}, error ? error : ''));
|
|
3676
|
+
};
|
|
3677
|
+
SearchInputList.propTypes = {
|
|
3678
|
+
onChange: PropTypes.func,
|
|
3679
|
+
path: PropTypes.string,
|
|
3680
|
+
btnClass: PropTypes.string,
|
|
3681
|
+
dataTestWrapper: PropTypes.string,
|
|
3682
|
+
dataTestSearchInput: PropTypes.string,
|
|
3683
|
+
dataTestItem: PropTypes.string,
|
|
3684
|
+
renderTextItemOption: PropTypes.func,
|
|
3685
|
+
typeNameQuery: PropTypes.string,
|
|
3686
|
+
labelProperty: PropTypes.string,
|
|
3687
|
+
error: PropTypes.string,
|
|
3688
|
+
errorZoneClassName: PropTypes.string,
|
|
3689
|
+
traversal: PropTypes.object,
|
|
3690
|
+
path: PropTypes.string,
|
|
3691
|
+
qs: PropTypes.array,
|
|
3692
|
+
queryCondition: PropTypes.string
|
|
3693
|
+
};
|
|
3694
|
+
|
|
3695
|
+
const EditComponent = React.forwardRef((_ref, ref) => {
|
|
3696
|
+
let {
|
|
3697
|
+
schema,
|
|
3698
|
+
val,
|
|
3699
|
+
setValue,
|
|
3700
|
+
dataTest,
|
|
3701
|
+
className
|
|
3702
|
+
} = _ref,
|
|
3703
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["schema", "val", "setValue", "dataTest", "className"]);
|
|
3704
|
+
|
|
3705
|
+
const traversal = useTraversal();
|
|
3706
|
+
|
|
3707
|
+
if ((schema == null ? void 0 : schema.widget) === 'search_list') {
|
|
3708
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, rest.placeholder && /*#__PURE__*/React.createElement("label", {
|
|
3709
|
+
className: "label"
|
|
3710
|
+
}, rest.placeholder), /*#__PURE__*/React.createElement(SearchInputList, _extends({
|
|
3711
|
+
value: val || [],
|
|
3712
|
+
traversal: traversal,
|
|
3713
|
+
className: className,
|
|
3714
|
+
onChange: ev => setValue(ev),
|
|
3715
|
+
queryCondition: schema != null && schema.queryCondition ? schema.queryCondition : 'title__in',
|
|
3716
|
+
dataTest: dataTest,
|
|
3717
|
+
path: schema.queryPath,
|
|
3718
|
+
labelProperty: schema != null && schema.labelProperty ? schema.labelProperty : 'title',
|
|
3719
|
+
typeNameQuery: schema != null && schema.typeNameQuery ? schema.typeNameQuery : null
|
|
3720
|
+
}, rest)));
|
|
3721
|
+
} else if ((schema == null ? void 0 : schema.widget) === 'search') {
|
|
3722
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, rest.placeholder && /*#__PURE__*/React.createElement("label", {
|
|
3723
|
+
className: "label"
|
|
3724
|
+
}, rest.placeholder), /*#__PURE__*/React.createElement(SearchInput, _extends({
|
|
3725
|
+
value: val,
|
|
3726
|
+
traversal: traversal,
|
|
3727
|
+
className: className,
|
|
3728
|
+
onChange: ev => setValue(ev),
|
|
3729
|
+
queryCondition: schema != null && schema.queryCondition ? schema.queryCondition : 'title__in',
|
|
3730
|
+
dataTest: dataTest,
|
|
3731
|
+
path: schema.queryPath,
|
|
3732
|
+
labelProperty: schema != null && schema.labelProperty ? schema.labelProperty : 'title',
|
|
3733
|
+
typeNameQuery: schema != null && schema.typeNameQuery ? schema.typeNameQuery : null
|
|
3734
|
+
}, rest)));
|
|
3735
|
+
} else if ((schema == null ? void 0 : schema.widget) === 'textarea' || (schema == null ? void 0 : schema.widget) === 'richtext') {
|
|
3736
|
+
return /*#__PURE__*/React.createElement(Textarea, _extends({
|
|
3737
|
+
value: val || '',
|
|
3738
|
+
className: className,
|
|
3739
|
+
onChange: ev => setValue(ev),
|
|
3740
|
+
ref: ref,
|
|
3741
|
+
dataTest: dataTest
|
|
3742
|
+
}, rest));
|
|
3743
|
+
} else if ((schema == null ? void 0 : schema.type) === 'boolean') {
|
|
3744
|
+
return /*#__PURE__*/React.createElement(Checkbox, _extends({
|
|
3745
|
+
value: !!val,
|
|
3746
|
+
className: className,
|
|
3747
|
+
onChange: ev => setValue(ev),
|
|
3748
|
+
ref: ref,
|
|
3749
|
+
dataTest: dataTest
|
|
3750
|
+
}, rest));
|
|
3751
|
+
} else if ((schema == null ? void 0 : schema.type) === 'array') {
|
|
3752
|
+
if (schema.items && schema.items.type === 'string') {
|
|
3753
|
+
var _schema$items;
|
|
3754
|
+
|
|
3755
|
+
if (schema.items.vocabularyName) {
|
|
3756
|
+
return /*#__PURE__*/React.createElement(SelectVocabulary, _extends({
|
|
3757
|
+
vocabularyName: get$1(schema, 'items.vocabularyName', null),
|
|
3758
|
+
val: val || [],
|
|
3759
|
+
className: className,
|
|
3760
|
+
classWrap: "is-fullwidth",
|
|
3761
|
+
dataTest: dataTest
|
|
3762
|
+
}, rest, {
|
|
3763
|
+
onChange: setValue,
|
|
3764
|
+
multiple: true
|
|
3765
|
+
}));
|
|
3766
|
+
} else if (schema != null && (_schema$items = schema.items) != null && _schema$items.vocabulary) {
|
|
3767
|
+
return /*#__PURE__*/React.createElement(Select, _extends({
|
|
3768
|
+
value: val || [],
|
|
3769
|
+
className: className,
|
|
3770
|
+
classWrap: "is-fullwidth",
|
|
3771
|
+
dataTest: dataTest,
|
|
3772
|
+
options: schema == null ? void 0 : schema.items.vocabulary.map(item => {
|
|
3773
|
+
return {
|
|
3774
|
+
text: item,
|
|
3775
|
+
value: item
|
|
3776
|
+
};
|
|
3777
|
+
}),
|
|
3778
|
+
multiple: true,
|
|
3779
|
+
onChange: setValue
|
|
3780
|
+
}, rest));
|
|
3781
|
+
}
|
|
3782
|
+
}
|
|
3783
|
+
|
|
3784
|
+
return /*#__PURE__*/React.createElement(InputList, _extends({
|
|
3785
|
+
value: val || [],
|
|
3786
|
+
className: className,
|
|
3787
|
+
onChange: ev => setValue(ev),
|
|
3788
|
+
ref: ref,
|
|
3789
|
+
dataTest: dataTest
|
|
3790
|
+
}, rest));
|
|
3791
|
+
} else if ((schema == null ? void 0 : schema.widget) === 'file') {
|
|
3792
|
+
return /*#__PURE__*/React.createElement(FileUpload, _extends({
|
|
3793
|
+
onChange: ev => setValue(ev),
|
|
3794
|
+
label: get$1(val, 'filename', null),
|
|
3795
|
+
dataTest: dataTest
|
|
3796
|
+
}, rest));
|
|
3797
|
+
} else if ((schema == null ? void 0 : schema.widget) === 'select' && schema.type === 'string') {
|
|
3798
|
+
if (schema != null && schema.vocabularyName) {
|
|
3799
|
+
return /*#__PURE__*/React.createElement(SelectVocabulary, _extends({
|
|
3800
|
+
val: val || '',
|
|
3801
|
+
className: className,
|
|
3802
|
+
appendDefault: true,
|
|
3803
|
+
classWrap: "is-fullwidth",
|
|
3804
|
+
dataTest: dataTest,
|
|
3805
|
+
onChange: setValue,
|
|
3806
|
+
vocabularyName: get$1(schema, 'vocabularyName', null)
|
|
3807
|
+
}, rest));
|
|
3808
|
+
}
|
|
3809
|
+
|
|
3810
|
+
return /*#__PURE__*/React.createElement(Select, _extends({
|
|
3811
|
+
value: val || '',
|
|
3812
|
+
className: className,
|
|
3813
|
+
appendDefault: true,
|
|
3814
|
+
classWrap: "is-fullwidth",
|
|
3815
|
+
dataTest: dataTest,
|
|
3816
|
+
options: schema == null ? void 0 : schema.vocabulary.map(item => {
|
|
3817
|
+
return {
|
|
3818
|
+
text: item,
|
|
3819
|
+
value: item
|
|
3820
|
+
};
|
|
3821
|
+
}),
|
|
3822
|
+
onChange: setValue
|
|
3823
|
+
}, rest));
|
|
3824
|
+
}
|
|
3825
|
+
|
|
3826
|
+
const getInputType = () => {
|
|
3827
|
+
switch (schema == null ? void 0 : schema.type) {
|
|
3828
|
+
case 'integer':
|
|
3829
|
+
return 'number';
|
|
3130
3830
|
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
} else {
|
|
3134
|
-
var _renderProps$value;
|
|
3831
|
+
case 'date':
|
|
3832
|
+
return 'date';
|
|
3135
3833
|
|
|
3136
|
-
|
|
3137
|
-
|
|
3834
|
+
case 'datetime':
|
|
3835
|
+
return 'datetime-local';
|
|
3138
3836
|
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
}
|
|
3837
|
+
default:
|
|
3838
|
+
return 'text';
|
|
3142
3839
|
}
|
|
3143
|
-
|
|
3144
|
-
return renderProps;
|
|
3145
3840
|
};
|
|
3146
3841
|
|
|
3147
|
-
return /*#__PURE__*/React.createElement(
|
|
3148
|
-
|
|
3842
|
+
return /*#__PURE__*/React.createElement(Input, _extends({
|
|
3843
|
+
value: val || '',
|
|
3844
|
+
className: className,
|
|
3845
|
+
dataTest: dataTest,
|
|
3846
|
+
onChange: ev => setValue(ev),
|
|
3847
|
+
ref: ref,
|
|
3848
|
+
type: getInputType()
|
|
3849
|
+
}, rest));
|
|
3850
|
+
});
|
|
3851
|
+
EditComponent.displayName = 'EditComponent';
|
|
3149
3852
|
|
|
3150
3853
|
function IAttachment({
|
|
3151
3854
|
properties,
|
|
3152
3855
|
values
|
|
3153
3856
|
}) {
|
|
3857
|
+
const intl = useIntl();
|
|
3154
3858
|
const Ctx = useTraversal();
|
|
3155
3859
|
const modifyContent = Ctx.hasPerm('guillotina.ModifyContent');
|
|
3156
3860
|
return /*#__PURE__*/React.createElement(Table, {
|
|
3157
|
-
headers: [
|
|
3861
|
+
headers: [intl.formatMessage(genericMessages.property), intl.formatMessage(genericMessages.value)],
|
|
3158
3862
|
className: "is-striped is-fullwidth is-size-7"
|
|
3159
3863
|
}, Object.keys(properties).map(key => /*#__PURE__*/React.createElement("tr", {
|
|
3160
3864
|
key: 'attachment_' + key
|
|
3161
3865
|
}, /*#__PURE__*/React.createElement("td", {
|
|
3866
|
+
style: {
|
|
3867
|
+
width: '150px'
|
|
3868
|
+
},
|
|
3162
3869
|
key: 1
|
|
3163
3870
|
}, key), /*#__PURE__*/React.createElement("td", {
|
|
3164
3871
|
key: 2
|
|
@@ -3230,7 +3937,7 @@ function IMultiAttachment({
|
|
|
3230
3937
|
};
|
|
3231
3938
|
|
|
3232
3939
|
return /*#__PURE__*/React.createElement(Table, {
|
|
3233
|
-
headers: [
|
|
3940
|
+
headers: [intl.formatMessage(genericMessages.property), intl.formatMessage(genericMessages.value)],
|
|
3234
3941
|
className: "is-striped is-fullwidth is-size-7"
|
|
3235
3942
|
}, fileKeyToDelete && /*#__PURE__*/React.createElement(Confirm, {
|
|
3236
3943
|
loading: loading,
|
|
@@ -3242,7 +3949,10 @@ function IMultiAttachment({
|
|
|
3242
3949
|
}), Object.keys(values['files']).map(key => /*#__PURE__*/React.createElement("tr", {
|
|
3243
3950
|
key: 'multiattachment_' + key
|
|
3244
3951
|
}, /*#__PURE__*/React.createElement("td", {
|
|
3245
|
-
key: 1
|
|
3952
|
+
key: 1,
|
|
3953
|
+
style: {
|
|
3954
|
+
width: '150px'
|
|
3955
|
+
}
|
|
3246
3956
|
}, key), /*#__PURE__*/React.createElement("td", {
|
|
3247
3957
|
key: 2
|
|
3248
3958
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -3364,7 +4074,7 @@ function IImageAttachment({
|
|
|
3364
4074
|
};
|
|
3365
4075
|
|
|
3366
4076
|
return /*#__PURE__*/React.createElement(Table, {
|
|
3367
|
-
headers: [
|
|
4077
|
+
headers: [intl.formatMessage(genericMessages.property), intl.formatMessage(genericMessages.value)],
|
|
3368
4078
|
className: "is-striped is-fullwidth is-size-7"
|
|
3369
4079
|
}, showConfirmToDelete && /*#__PURE__*/React.createElement(Confirm, {
|
|
3370
4080
|
loading: loading,
|
|
@@ -3372,7 +4082,10 @@ function IImageAttachment({
|
|
|
3372
4082
|
onConfirm: () => deleteFile(),
|
|
3373
4083
|
message: intl.formatMessage(genericFileMessages.confirm_message_delete_image)
|
|
3374
4084
|
}), values['image'] && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
3375
|
-
key: 1
|
|
4085
|
+
key: 1,
|
|
4086
|
+
style: {
|
|
4087
|
+
width: '150px'
|
|
4088
|
+
}
|
|
3376
4089
|
}, intl.formatMessage(genericMessages.image)), /*#__PURE__*/React.createElement("td", {
|
|
3377
4090
|
key: 2
|
|
3378
4091
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -3495,7 +4208,7 @@ function IMultiImageAttachment({
|
|
|
3495
4208
|
};
|
|
3496
4209
|
|
|
3497
4210
|
return /*#__PURE__*/React.createElement(Table, {
|
|
3498
|
-
headers: [
|
|
4211
|
+
headers: [intl.formatMessage(genericMessages.property), intl.formatMessage(genericMessages.value)],
|
|
3499
4212
|
className: "is-striped is-fullwidth is-size-7"
|
|
3500
4213
|
}, fileKeyToDelete && /*#__PURE__*/React.createElement(Confirm, {
|
|
3501
4214
|
loading: loading,
|
|
@@ -3507,7 +4220,10 @@ function IMultiImageAttachment({
|
|
|
3507
4220
|
}), Object.keys(values['images']).map(key => /*#__PURE__*/React.createElement("tr", {
|
|
3508
4221
|
key: `multiimageattachment_${key}`
|
|
3509
4222
|
}, /*#__PURE__*/React.createElement("td", {
|
|
3510
|
-
key: 1
|
|
4223
|
+
key: 1,
|
|
4224
|
+
style: {
|
|
4225
|
+
width: '150px'
|
|
4226
|
+
}
|
|
3511
4227
|
}, key), /*#__PURE__*/React.createElement("td", {
|
|
3512
4228
|
key: 2
|
|
3513
4229
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -4620,77 +5336,7 @@ function SearchVocabularyLabels(props) {
|
|
|
4620
5336
|
return null;
|
|
4621
5337
|
}
|
|
4622
5338
|
|
|
4623
|
-
const
|
|
4624
|
-
let {
|
|
4625
|
-
vocabularyName,
|
|
4626
|
-
className,
|
|
4627
|
-
classWrap,
|
|
4628
|
-
val,
|
|
4629
|
-
dataTest,
|
|
4630
|
-
multiple
|
|
4631
|
-
} = _ref,
|
|
4632
|
-
rest = _objectWithoutPropertiesLoose(_ref, ["vocabularyName", "className", "classWrap", "val", "dataTest", "multiple"]);
|
|
4633
|
-
|
|
4634
|
-
const vocabulary = useVocabulary(vocabularyName);
|
|
4635
|
-
|
|
4636
|
-
const getOptions = () => {
|
|
4637
|
-
if (get$1(vocabulary, 'data.items', null)) {
|
|
4638
|
-
const vocData = vocabulary.data.items.map(item => {
|
|
4639
|
-
var _item$title$default;
|
|
4640
|
-
|
|
4641
|
-
return {
|
|
4642
|
-
text: (_item$title$default = item.title.default) != null ? _item$title$default : item.title,
|
|
4643
|
-
value: item.token
|
|
4644
|
-
};
|
|
4645
|
-
});
|
|
4646
|
-
return vocData;
|
|
4647
|
-
}
|
|
4648
|
-
|
|
4649
|
-
return [];
|
|
4650
|
-
};
|
|
4651
|
-
|
|
4652
|
-
const getProps = () => {
|
|
4653
|
-
if (multiple) {
|
|
4654
|
-
const currentValue = val || [];
|
|
4655
|
-
return {
|
|
4656
|
-
multiple: true,
|
|
4657
|
-
size: 5,
|
|
4658
|
-
value: currentValue,
|
|
4659
|
-
options: getOptions()
|
|
4660
|
-
};
|
|
4661
|
-
}
|
|
4662
|
-
|
|
4663
|
-
return {
|
|
4664
|
-
value: val != null ? val : '',
|
|
4665
|
-
appendDefault: true,
|
|
4666
|
-
options: getOptions()
|
|
4667
|
-
};
|
|
4668
|
-
};
|
|
4669
|
-
|
|
4670
|
-
if (vocabulary.data === undefined || vocabulary.loading) {
|
|
4671
|
-
return /*#__PURE__*/React.createElement("div", null);
|
|
4672
|
-
}
|
|
4673
|
-
|
|
4674
|
-
return /*#__PURE__*/React.createElement(Select, _extends({}, getProps(), {
|
|
4675
|
-
className: className,
|
|
4676
|
-
classWrap: classWrap || 'is-fullwidth',
|
|
4677
|
-
dataTest: dataTest,
|
|
4678
|
-
ref: ref
|
|
4679
|
-
}, rest));
|
|
4680
|
-
});
|
|
4681
|
-
Select.propTypes = {
|
|
4682
|
-
error: PropTypes.string,
|
|
4683
|
-
disabled: PropTypes.bool,
|
|
4684
|
-
loading: PropTypes.bool,
|
|
4685
|
-
isSubmitted: PropTypes.bool,
|
|
4686
|
-
size: PropTypes.number,
|
|
4687
|
-
onChange: PropTypes.func,
|
|
4688
|
-
multiple: PropTypes.bool,
|
|
4689
|
-
className: PropTypes.string,
|
|
4690
|
-
vocabularyName: PropTypes.string
|
|
4691
|
-
};
|
|
4692
|
-
|
|
4693
|
-
const initialState$1 = {
|
|
5339
|
+
const initialState$2 = {
|
|
4694
5340
|
page: 0,
|
|
4695
5341
|
items: [],
|
|
4696
5342
|
loading: true,
|
|
@@ -4704,7 +5350,7 @@ function PanelItems() {
|
|
|
4704
5350
|
} = useConfig();
|
|
4705
5351
|
const intl = useIntl();
|
|
4706
5352
|
const Ctx = useTraversal();
|
|
4707
|
-
const [state, setState] = useSetState(initialState$
|
|
5353
|
+
const [state, setState] = useSetState(initialState$2);
|
|
4708
5354
|
const {
|
|
4709
5355
|
items,
|
|
4710
5356
|
loading,
|
|
@@ -5125,7 +5771,7 @@ function PanelProperties() {
|
|
|
5125
5771
|
icon: model.icon,
|
|
5126
5772
|
align: "is-left",
|
|
5127
5773
|
className: "has-text-grey"
|
|
5128
|
-
}),
|
|
5774
|
+
}), "\xA0", /*#__PURE__*/React.createElement("span", null, Ctx.context.title || Ctx.context['@name']))), /*#__PURE__*/React.createElement("div", {
|
|
5129
5775
|
className: "level-right"
|
|
5130
5776
|
}, /*#__PURE__*/React.createElement(PropertiesButtonView, null))), /*#__PURE__*/React.createElement("hr", null), schema && schema.data && !schema.loading && /*#__PURE__*/React.createElement("div", {
|
|
5131
5777
|
className: "columns"
|
|
@@ -5134,18 +5780,28 @@ function PanelProperties() {
|
|
|
5134
5780
|
}, /*#__PURE__*/React.createElement("table", {
|
|
5135
5781
|
className: "table is-striped is-fullwidth is-size-7"
|
|
5136
5782
|
}, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
5783
|
+
style: {
|
|
5784
|
+
width: '150px'
|
|
5785
|
+
},
|
|
5137
5786
|
className: "is-2"
|
|
5138
5787
|
}, intl.formatMessage(genericMessages.property)), /*#__PURE__*/React.createElement("th", {
|
|
5139
5788
|
className: "is-8"
|
|
5140
5789
|
}, intl.formatMessage(genericMessages.value)))), /*#__PURE__*/React.createElement("tbody", null, showProperties.map(prop => /*#__PURE__*/React.createElement("tr", {
|
|
5141
5790
|
key: 'prop' + prop
|
|
5142
|
-
}, /*#__PURE__*/React.createElement("td",
|
|
5791
|
+
}, /*#__PURE__*/React.createElement("td", {
|
|
5792
|
+
style: {
|
|
5793
|
+
width: '150px'
|
|
5794
|
+
}
|
|
5795
|
+
}, prop), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(EditableField, {
|
|
5143
5796
|
field: prop,
|
|
5144
5797
|
value: Ctx.context[prop],
|
|
5145
5798
|
modifyContent: false
|
|
5146
5799
|
})))))), properties.length > 0 && /*#__PURE__*/React.createElement("table", {
|
|
5147
5800
|
className: "table is-striped is-fullwidth is-size-7"
|
|
5148
5801
|
}, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
5802
|
+
style: {
|
|
5803
|
+
width: '150px'
|
|
5804
|
+
},
|
|
5149
5805
|
className: "is-2"
|
|
5150
5806
|
}, intl.formatMessage(genericMessages.property)), /*#__PURE__*/React.createElement("th", {
|
|
5151
5807
|
className: "is-8"
|
|
@@ -5155,7 +5811,11 @@ function PanelProperties() {
|
|
|
5155
5811
|
}) => {
|
|
5156
5812
|
return /*#__PURE__*/React.createElement("tr", {
|
|
5157
5813
|
key: 'prop' + key
|
|
5158
|
-
}, /*#__PURE__*/React.createElement("td",
|
|
5814
|
+
}, /*#__PURE__*/React.createElement("td", {
|
|
5815
|
+
style: {
|
|
5816
|
+
width: '150px'
|
|
5817
|
+
}
|
|
5818
|
+
}, value.title || key), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(EditableField, {
|
|
5159
5819
|
field: key,
|
|
5160
5820
|
value: Ctx.context[key],
|
|
5161
5821
|
schema: value,
|
|
@@ -5783,12 +6443,12 @@ function TagsWidget({
|
|
|
5783
6443
|
|
|
5784
6444
|
/* eslint jsx-a11y/anchor-is-valid: "off" */
|
|
5785
6445
|
|
|
5786
|
-
const initialState$
|
|
6446
|
+
const initialState$3 = {
|
|
5787
6447
|
types: undefined
|
|
5788
6448
|
};
|
|
5789
6449
|
function CreateButton() {
|
|
5790
6450
|
const intl = useIntl();
|
|
5791
|
-
const [state, setState] = useSetState(initialState$
|
|
6451
|
+
const [state, setState] = useSetState(initialState$3);
|
|
5792
6452
|
const Ctx = useTraversal();
|
|
5793
6453
|
const Config = useConfig();
|
|
5794
6454
|
useEffect(() => {
|
|
@@ -5847,7 +6507,7 @@ function ContextToolbar(_ref) {
|
|
|
5847
6507
|
props = _objectWithoutPropertiesLoose(_ref, ["AddButton"]);
|
|
5848
6508
|
|
|
5849
6509
|
const intl = useIntl();
|
|
5850
|
-
const [state, setState] = useSetState(initialState$
|
|
6510
|
+
const [state, setState] = useSetState(initialState$3);
|
|
5851
6511
|
const [location, setLocation, del] = useLocation();
|
|
5852
6512
|
const traversal = useTraversal();
|
|
5853
6513
|
const Config = useConfig();
|
|
@@ -6900,14 +7560,18 @@ function IDublinCore({
|
|
|
6900
7560
|
properties,
|
|
6901
7561
|
values
|
|
6902
7562
|
}) {
|
|
7563
|
+
const intl = useIntl();
|
|
6903
7564
|
const Ctx = useTraversal();
|
|
6904
7565
|
const modifyContent = Ctx.hasPerm('guillotina.ModifyContent');
|
|
6905
7566
|
return /*#__PURE__*/React.createElement(Table, {
|
|
6906
|
-
headers: [
|
|
7567
|
+
headers: [intl.formatMessage(genericMessages.property), intl.formatMessage(genericMessages.value)],
|
|
6907
7568
|
className: "is-striped is-fullwidth is-size-7"
|
|
6908
7569
|
}, Object.keys(properties).map(key => /*#__PURE__*/React.createElement("tr", {
|
|
6909
7570
|
key: 'dublin_' + key
|
|
6910
7571
|
}, /*#__PURE__*/React.createElement("td", {
|
|
7572
|
+
style: {
|
|
7573
|
+
width: '150px'
|
|
7574
|
+
},
|
|
6911
7575
|
key: 1
|
|
6912
7576
|
}, key), /*#__PURE__*/React.createElement("td", {
|
|
6913
7577
|
key: 2
|
|
@@ -7078,12 +7742,12 @@ function GroupCtx() {
|
|
|
7078
7742
|
}), errorMessage);
|
|
7079
7743
|
};
|
|
7080
7744
|
|
|
7081
|
-
const addUser = async
|
|
7745
|
+
const addUser = async newUserId => {
|
|
7082
7746
|
const data = {};
|
|
7083
7747
|
Ctx.context.users.forEach(user => {
|
|
7084
7748
|
data[user] = true;
|
|
7085
7749
|
});
|
|
7086
|
-
data[
|
|
7750
|
+
data[newUserId] = true;
|
|
7087
7751
|
const {
|
|
7088
7752
|
isError,
|
|
7089
7753
|
errorMessage
|
|
@@ -7103,7 +7767,7 @@ function GroupCtx() {
|
|
|
7103
7767
|
"value": " added to group"
|
|
7104
7768
|
}]
|
|
7105
7769
|
}, {
|
|
7106
|
-
user:
|
|
7770
|
+
user: newUserId
|
|
7107
7771
|
}), errorMessage);
|
|
7108
7772
|
};
|
|
7109
7773
|
|
|
@@ -7364,134 +8028,6 @@ const buildPaths = segments => {
|
|
|
7364
8028
|
return results;
|
|
7365
8029
|
};
|
|
7366
8030
|
|
|
7367
|
-
const EditComponent = React.forwardRef((_ref, ref) => {
|
|
7368
|
-
let {
|
|
7369
|
-
schema,
|
|
7370
|
-
val,
|
|
7371
|
-
setValue,
|
|
7372
|
-
dataTest,
|
|
7373
|
-
className
|
|
7374
|
-
} = _ref,
|
|
7375
|
-
rest = _objectWithoutPropertiesLoose(_ref, ["schema", "val", "setValue", "dataTest", "className"]);
|
|
7376
|
-
|
|
7377
|
-
if ((schema == null ? void 0 : schema.widget) === 'textarea' || (schema == null ? void 0 : schema.widget) === 'richtext') {
|
|
7378
|
-
return /*#__PURE__*/React.createElement(Textarea, _extends({
|
|
7379
|
-
value: val || '',
|
|
7380
|
-
className: className,
|
|
7381
|
-
onChange: ev => setValue(ev),
|
|
7382
|
-
ref: ref,
|
|
7383
|
-
dataTest: dataTest
|
|
7384
|
-
}, rest));
|
|
7385
|
-
} else if ((schema == null ? void 0 : schema.type) === 'boolean') {
|
|
7386
|
-
return /*#__PURE__*/React.createElement(Checkbox, _extends({
|
|
7387
|
-
value: !!val,
|
|
7388
|
-
className: className,
|
|
7389
|
-
onChange: ev => setValue(ev),
|
|
7390
|
-
ref: ref,
|
|
7391
|
-
dataTest: dataTest
|
|
7392
|
-
}, rest));
|
|
7393
|
-
} else if ((schema == null ? void 0 : schema.type) === 'array') {
|
|
7394
|
-
if (schema.items && schema.items.type === 'string') {
|
|
7395
|
-
var _schema$items;
|
|
7396
|
-
|
|
7397
|
-
if (schema.items.vocabularyName) {
|
|
7398
|
-
return /*#__PURE__*/React.createElement(SelectVocabulary, _extends({
|
|
7399
|
-
vocabularyName: get$1(schema, 'items.vocabularyName', null),
|
|
7400
|
-
val: val || [],
|
|
7401
|
-
className: className,
|
|
7402
|
-
classWrap: "is-fullwidth",
|
|
7403
|
-
dataTest: dataTest
|
|
7404
|
-
}, rest, {
|
|
7405
|
-
onChange: setValue,
|
|
7406
|
-
multiple: true
|
|
7407
|
-
}));
|
|
7408
|
-
} else if (schema != null && (_schema$items = schema.items) != null && _schema$items.vocabulary) {
|
|
7409
|
-
return /*#__PURE__*/React.createElement(Select, _extends({
|
|
7410
|
-
value: val || [],
|
|
7411
|
-
className: className,
|
|
7412
|
-
classWrap: "is-fullwidth",
|
|
7413
|
-
dataTest: dataTest,
|
|
7414
|
-
options: schema == null ? void 0 : schema.items.vocabulary.map(item => {
|
|
7415
|
-
return {
|
|
7416
|
-
text: item,
|
|
7417
|
-
value: item
|
|
7418
|
-
};
|
|
7419
|
-
}),
|
|
7420
|
-
multiple: true,
|
|
7421
|
-
onChange: setValue
|
|
7422
|
-
}, rest));
|
|
7423
|
-
}
|
|
7424
|
-
}
|
|
7425
|
-
|
|
7426
|
-
return /*#__PURE__*/React.createElement(InputList, _extends({
|
|
7427
|
-
value: val || [],
|
|
7428
|
-
className: className,
|
|
7429
|
-
onChange: ev => setValue(ev),
|
|
7430
|
-
ref: ref,
|
|
7431
|
-
dataTest: dataTest
|
|
7432
|
-
}, rest));
|
|
7433
|
-
} else if ((schema == null ? void 0 : schema.widget) === 'file') {
|
|
7434
|
-
return /*#__PURE__*/React.createElement(FileUpload, _extends({
|
|
7435
|
-
onChange: ev => setValue(ev),
|
|
7436
|
-
label: get$1(val, 'filename', null),
|
|
7437
|
-
dataTest: dataTest
|
|
7438
|
-
}, rest));
|
|
7439
|
-
} else if ((schema == null ? void 0 : schema.widget) === 'select' && schema.type === 'string') {
|
|
7440
|
-
if (schema != null && schema.vocabularyName) {
|
|
7441
|
-
return /*#__PURE__*/React.createElement(SelectVocabulary, _extends({
|
|
7442
|
-
val: val || '',
|
|
7443
|
-
className: className,
|
|
7444
|
-
appendDefault: true,
|
|
7445
|
-
classWrap: "is-fullwidth",
|
|
7446
|
-
dataTest: dataTest,
|
|
7447
|
-
onChange: setValue,
|
|
7448
|
-
vocabularyName: get$1(schema, 'vocabularyName', null)
|
|
7449
|
-
}, rest));
|
|
7450
|
-
}
|
|
7451
|
-
|
|
7452
|
-
return /*#__PURE__*/React.createElement(Select, _extends({
|
|
7453
|
-
value: val || '',
|
|
7454
|
-
className: className,
|
|
7455
|
-
appendDefault: true,
|
|
7456
|
-
classWrap: "is-fullwidth",
|
|
7457
|
-
dataTest: dataTest,
|
|
7458
|
-
options: schema == null ? void 0 : schema.vocabulary.map(item => {
|
|
7459
|
-
return {
|
|
7460
|
-
text: item,
|
|
7461
|
-
value: item
|
|
7462
|
-
};
|
|
7463
|
-
}),
|
|
7464
|
-
onChange: setValue
|
|
7465
|
-
}, rest));
|
|
7466
|
-
}
|
|
7467
|
-
|
|
7468
|
-
const getInputType = () => {
|
|
7469
|
-
switch (schema == null ? void 0 : schema.type) {
|
|
7470
|
-
case 'integer':
|
|
7471
|
-
return 'number';
|
|
7472
|
-
|
|
7473
|
-
case 'date':
|
|
7474
|
-
return 'date';
|
|
7475
|
-
|
|
7476
|
-
case 'datetime':
|
|
7477
|
-
return 'datetime-local';
|
|
7478
|
-
|
|
7479
|
-
default:
|
|
7480
|
-
return 'text';
|
|
7481
|
-
}
|
|
7482
|
-
};
|
|
7483
|
-
|
|
7484
|
-
return /*#__PURE__*/React.createElement(Input, _extends({
|
|
7485
|
-
value: val || '',
|
|
7486
|
-
className: className,
|
|
7487
|
-
dataTest: dataTest,
|
|
7488
|
-
onChange: ev => setValue(ev),
|
|
7489
|
-
ref: ref,
|
|
7490
|
-
type: getInputType()
|
|
7491
|
-
}, rest));
|
|
7492
|
-
});
|
|
7493
|
-
EditComponent.displayName = 'EditComponent';
|
|
7494
|
-
|
|
7495
8031
|
let registry = {
|
|
7496
8032
|
paths: {},
|
|
7497
8033
|
views: {
|
|
@@ -7664,7 +8200,7 @@ const registry = {
|
|
|
7664
8200
|
|
|
7665
8201
|
*/
|
|
7666
8202
|
|
|
7667
|
-
const initialState$
|
|
8203
|
+
const initialState$4 = {
|
|
7668
8204
|
path: '',
|
|
7669
8205
|
loading: false,
|
|
7670
8206
|
context: undefined,
|
|
@@ -10566,10 +11102,10 @@ function Guillotina(_ref) {
|
|
|
10566
11102
|
const searchPath = location.get('path') || '/';
|
|
10567
11103
|
|
|
10568
11104
|
if (searchPath && searchPath !== '') {
|
|
10569
|
-
initialState$
|
|
11105
|
+
initialState$4.path = searchPath;
|
|
10570
11106
|
}
|
|
10571
11107
|
|
|
10572
|
-
const [state, dispatch] = useReducer(guillotinaReducer, initialState$
|
|
11108
|
+
const [state, dispatch] = useReducer(guillotinaReducer, initialState$4);
|
|
10573
11109
|
const {
|
|
10574
11110
|
path,
|
|
10575
11111
|
refresh
|
|
@@ -10715,7 +11251,7 @@ const ERRORS = {
|
|
|
10715
11251
|
failed_to_fetch: 'Failed to fetch data: Backend not running?',
|
|
10716
11252
|
invalid_credentials: 'Failed! Invalid credentials'
|
|
10717
11253
|
};
|
|
10718
|
-
const initialState$
|
|
11254
|
+
const initialState$5 = {
|
|
10719
11255
|
username: '',
|
|
10720
11256
|
password: '',
|
|
10721
11257
|
loading: undefined,
|
|
@@ -10728,7 +11264,7 @@ const Login = ({
|
|
|
10728
11264
|
auth,
|
|
10729
11265
|
onLogin
|
|
10730
11266
|
}) => {
|
|
10731
|
-
const [state, setState] = useSetState(initialState$
|
|
11267
|
+
const [state, setState] = useSetState(initialState$5);
|
|
10732
11268
|
const inputRef = useRef(null);
|
|
10733
11269
|
useEffect(() => {
|
|
10734
11270
|
if (inputRef) {
|
|
@@ -11101,5 +11637,5 @@ class Auth {
|
|
|
11101
11637
|
|
|
11102
11638
|
}
|
|
11103
11639
|
|
|
11104
|
-
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 };
|
|
11640
|
+
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 };
|
|
11105
11641
|
//# sourceMappingURL=react-gmi.modern.js.map
|