@guillotinaweb/react-gmi 0.28.3 → 0.29.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/index.d.ts +2 -0
- package/dist/components/input/index.d.ts +3 -0
- package/dist/hooks/useRegistry.d.ts +7 -0
- package/dist/react-gmi.esm.js +1019 -1004
- package/dist/react-gmi.esm.js.map +1 -1
- package/dist/react-gmi.js +1020 -1003
- package/dist/react-gmi.js.map +1 -1
- package/dist/react-gmi.modern.js +557 -542
- package/dist/react-gmi.modern.js.map +1 -1
- package/dist/react-gmi.umd.js +1020 -1003
- package/dist/react-gmi.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/react-gmi.modern.js
CHANGED
|
@@ -1621,6 +1621,129 @@ const Select = forwardRef(({
|
|
|
1621
1621
|
});
|
|
1622
1622
|
Select.displayName = 'Select';
|
|
1623
1623
|
|
|
1624
|
+
const formatDate = str => {
|
|
1625
|
+
const d = new Date(str);
|
|
1626
|
+
const minutes = d.getMinutes() < 10 ? `0${d.getMinutes()}` : d.getMinutes();
|
|
1627
|
+
return `${d.getDate()}/${d.getMonth() + 1}/${d.getFullYear()} ${d.getHours()}:${minutes}`;
|
|
1628
|
+
};
|
|
1629
|
+
const get$1 = (obj, path, defValue) => {
|
|
1630
|
+
var _pathArray$reduce;
|
|
1631
|
+
|
|
1632
|
+
if (!path) return undefined;
|
|
1633
|
+
const pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g);
|
|
1634
|
+
return (_pathArray$reduce = pathArray.reduce((prevObj, key) => prevObj && prevObj[key], obj)) != null ? _pathArray$reduce : defValue;
|
|
1635
|
+
};
|
|
1636
|
+
function getNewId(id = '') {
|
|
1637
|
+
const suffix = '-copy-';
|
|
1638
|
+
const rgx = new RegExp(`($|${suffix}\\d*)`);
|
|
1639
|
+
return stringToSlug(id).replace(rgx, r => {
|
|
1640
|
+
const num = parseInt(r.replace(suffix, '') || '0');
|
|
1641
|
+
return `${suffix}${num + 1}`;
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
function useVocabulary(vocabularyName, path = null) {
|
|
1646
|
+
const traversal = useTraversal();
|
|
1647
|
+
const [vocabulary, setVocabulary] = useSetState({
|
|
1648
|
+
data: undefined,
|
|
1649
|
+
loading: false,
|
|
1650
|
+
error: undefined
|
|
1651
|
+
});
|
|
1652
|
+
|
|
1653
|
+
const getPath = () => {
|
|
1654
|
+
if (path) return path;
|
|
1655
|
+
return `${traversal.path}@vocabularies/${vocabularyName}`;
|
|
1656
|
+
};
|
|
1657
|
+
|
|
1658
|
+
useEffect(() => {
|
|
1659
|
+
const getVocabulary = async () => {
|
|
1660
|
+
if (vocabularyName && vocabulary.data === undefined && !vocabulary.loading) {
|
|
1661
|
+
try {
|
|
1662
|
+
setVocabulary({
|
|
1663
|
+
loading: true
|
|
1664
|
+
});
|
|
1665
|
+
const data = await traversal.client.get(getPath());
|
|
1666
|
+
const dataJson = await data.json();
|
|
1667
|
+
setVocabulary({
|
|
1668
|
+
loading: false,
|
|
1669
|
+
data: dataJson
|
|
1670
|
+
});
|
|
1671
|
+
} catch (err) {
|
|
1672
|
+
setVocabulary({
|
|
1673
|
+
loading: false,
|
|
1674
|
+
error: err,
|
|
1675
|
+
data: undefined
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
};
|
|
1680
|
+
|
|
1681
|
+
getVocabulary();
|
|
1682
|
+
}, [vocabularyName, vocabulary, path]);
|
|
1683
|
+
return vocabulary;
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
const SelectVocabulary = forwardRef(({
|
|
1687
|
+
vocabularyName,
|
|
1688
|
+
className,
|
|
1689
|
+
classWrap,
|
|
1690
|
+
val,
|
|
1691
|
+
dataTest,
|
|
1692
|
+
multiple,
|
|
1693
|
+
onChange,
|
|
1694
|
+
id,
|
|
1695
|
+
placeholder
|
|
1696
|
+
}, ref) => {
|
|
1697
|
+
const vocabulary = useVocabulary(vocabularyName);
|
|
1698
|
+
|
|
1699
|
+
const getOptions = () => {
|
|
1700
|
+
if (get$1(vocabulary, 'data.items', null)) {
|
|
1701
|
+
const vocData = vocabulary.data.items.map(item => {
|
|
1702
|
+
return {
|
|
1703
|
+
text: item.title,
|
|
1704
|
+
value: item.token
|
|
1705
|
+
};
|
|
1706
|
+
});
|
|
1707
|
+
return vocData;
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
return [];
|
|
1711
|
+
};
|
|
1712
|
+
|
|
1713
|
+
const getProps = () => {
|
|
1714
|
+
if (multiple) {
|
|
1715
|
+
const currentValue = val || [];
|
|
1716
|
+
return {
|
|
1717
|
+
multiple: true,
|
|
1718
|
+
size: 5,
|
|
1719
|
+
value: currentValue,
|
|
1720
|
+
options: getOptions()
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
return {
|
|
1725
|
+
value: val != null ? val : '',
|
|
1726
|
+
appendDefault: true,
|
|
1727
|
+
options: getOptions()
|
|
1728
|
+
};
|
|
1729
|
+
};
|
|
1730
|
+
|
|
1731
|
+
if (vocabulary.data === undefined || vocabulary.loading) {
|
|
1732
|
+
return jsx("div", {});
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
return jsx(Select, _extends({}, getProps(), {
|
|
1736
|
+
className: className,
|
|
1737
|
+
classWrap: classWrap || 'is-fullwidth',
|
|
1738
|
+
dataTest: dataTest,
|
|
1739
|
+
ref: ref,
|
|
1740
|
+
onChange: onChange,
|
|
1741
|
+
id: id,
|
|
1742
|
+
placeholder: placeholder
|
|
1743
|
+
}));
|
|
1744
|
+
});
|
|
1745
|
+
SelectVocabulary.displayName = 'SelectVocabulary';
|
|
1746
|
+
|
|
1624
1747
|
const setURLParams = p => {
|
|
1625
1748
|
return window.history.pushState(0, '0', '' + '?' + p.toString().replace(/%2F/g, '/'));
|
|
1626
1749
|
};
|
|
@@ -2431,27 +2554,6 @@ function useClickAway(ref, onClickAway, events = defaultEvents) {
|
|
|
2431
2554
|
}, [events, ref]);
|
|
2432
2555
|
}
|
|
2433
2556
|
|
|
2434
|
-
const formatDate = str => {
|
|
2435
|
-
const d = new Date(str);
|
|
2436
|
-
const minutes = d.getMinutes() < 10 ? `0${d.getMinutes()}` : d.getMinutes();
|
|
2437
|
-
return `${d.getDate()}/${d.getMonth() + 1}/${d.getFullYear()} ${d.getHours()}:${minutes}`;
|
|
2438
|
-
};
|
|
2439
|
-
const get$1 = (obj, path, defValue) => {
|
|
2440
|
-
var _pathArray$reduce;
|
|
2441
|
-
|
|
2442
|
-
if (!path) return undefined;
|
|
2443
|
-
const pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g);
|
|
2444
|
-
return (_pathArray$reduce = pathArray.reduce((prevObj, key) => prevObj && prevObj[key], obj)) != null ? _pathArray$reduce : defValue;
|
|
2445
|
-
};
|
|
2446
|
-
function getNewId(id = '') {
|
|
2447
|
-
const suffix = '-copy-';
|
|
2448
|
-
const rgx = new RegExp(`($|${suffix}\\d*)`);
|
|
2449
|
-
return stringToSlug(id).replace(rgx, r => {
|
|
2450
|
-
const num = parseInt(r.replace(suffix, '') || '0');
|
|
2451
|
-
return `${suffix}${num + 1}`;
|
|
2452
|
-
});
|
|
2453
|
-
}
|
|
2454
|
-
|
|
2455
2557
|
function debounce(func, wait) {
|
|
2456
2558
|
let timeout;
|
|
2457
2559
|
return function () {
|
|
@@ -2733,62 +2835,355 @@ const SearchInput = ({
|
|
|
2733
2835
|
});
|
|
2734
2836
|
};
|
|
2735
2837
|
|
|
2736
|
-
|
|
2737
|
-
|
|
2838
|
+
function debounce$1(func, wait) {
|
|
2839
|
+
let timeout;
|
|
2840
|
+
return function () {
|
|
2841
|
+
const context = this;
|
|
2842
|
+
const args = arguments;
|
|
2843
|
+
|
|
2844
|
+
const later = function later() {
|
|
2845
|
+
timeout = null;
|
|
2846
|
+
func.apply(context, args);
|
|
2847
|
+
};
|
|
2848
|
+
|
|
2849
|
+
clearTimeout(timeout);
|
|
2850
|
+
timeout = setTimeout(later, wait);
|
|
2851
|
+
};
|
|
2852
|
+
}
|
|
2853
|
+
|
|
2854
|
+
const initialState$1 = {
|
|
2855
|
+
page: 0,
|
|
2856
|
+
items: undefined,
|
|
2857
|
+
loading: false,
|
|
2858
|
+
items_total: 0
|
|
2859
|
+
};
|
|
2860
|
+
const SearchInputList = ({
|
|
2738
2861
|
onChange,
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2862
|
+
error,
|
|
2863
|
+
errorZoneClassName,
|
|
2864
|
+
traversal: _traversal = null,
|
|
2865
|
+
path: _path = null,
|
|
2866
|
+
qs: _qs = [],
|
|
2867
|
+
queryCondition: _queryCondition = 'id__in',
|
|
2868
|
+
value,
|
|
2869
|
+
btnClass: _btnClass = '',
|
|
2870
|
+
dataTestWrapper: _dataTestWrapper = 'wrapperSearchInputTest',
|
|
2871
|
+
dataTestSearchInput: _dataTestSearchInput = 'searchInputTest',
|
|
2872
|
+
dataTestItem: _dataTestItem = 'searchInputItemTest',
|
|
2873
|
+
renderTextItemOption: _renderTextItemOption = null,
|
|
2874
|
+
typeNameQuery: _typeNameQuery = null,
|
|
2875
|
+
labelProperty: _labelProperty = 'id'
|
|
2876
|
+
}) => {
|
|
2742
2877
|
const intl = useIntl();
|
|
2743
|
-
const [
|
|
2878
|
+
const [options, setOptions] = useSetState(initialState$1);
|
|
2879
|
+
const [valuesLabel, setValuesLabels] = useState(undefined);
|
|
2880
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
2881
|
+
const [searchTerm, setSearchTerm] = useState('');
|
|
2882
|
+
const inputRef = useRef(null);
|
|
2883
|
+
const wrapperRef = useRef(null);
|
|
2884
|
+
const {
|
|
2885
|
+
PageSize,
|
|
2886
|
+
SearchEngine
|
|
2887
|
+
} = useConfig();
|
|
2888
|
+
const [isLoadingData, setIsLoadingData] = useState(false);
|
|
2889
|
+
const [uid] = useState(generateUID('search_input'));
|
|
2890
|
+
useClickAway(wrapperRef, () => {
|
|
2891
|
+
setIsOpen(false);
|
|
2892
|
+
});
|
|
2744
2893
|
|
|
2745
|
-
const
|
|
2746
|
-
if (
|
|
2747
|
-
|
|
2748
|
-
|
|
2894
|
+
const getHeight = () => {
|
|
2895
|
+
if (wrapperRef && wrapperRef.current) {
|
|
2896
|
+
return {
|
|
2897
|
+
maxHeight: `${window.innerHeight - wrapperRef.current.getBoundingClientRect().top - 100}px`
|
|
2898
|
+
};
|
|
2749
2899
|
}
|
|
2900
|
+
|
|
2901
|
+
return {
|
|
2902
|
+
maxHeight: 'auto'
|
|
2903
|
+
};
|
|
2750
2904
|
};
|
|
2751
2905
|
|
|
2752
|
-
|
|
2753
|
-
className: "control",
|
|
2754
|
-
children: [(value != null ? value : []).length > 0 && jsx("div", {
|
|
2755
|
-
className: "tags",
|
|
2756
|
-
children: value.map((tag, index) => jsxs("div", {
|
|
2757
|
-
className: "tag is-info is-medium",
|
|
2758
|
-
children: [tag, jsx("button", {
|
|
2759
|
-
className: "delete is-small",
|
|
2760
|
-
type: "button",
|
|
2761
|
-
onClick: () => onChange([...value.filter(tag => value.indexOf(tag) !== index)])
|
|
2762
|
-
})]
|
|
2763
|
-
}, `input_list_${tag}_${index}`))
|
|
2764
|
-
}), jsx(Input, {
|
|
2765
|
-
type: "text",
|
|
2766
|
-
id: id,
|
|
2767
|
-
placeholder: intl.formatMessage({
|
|
2768
|
-
id: "press_enter_to_add_value",
|
|
2769
|
-
defaultMessage: [{
|
|
2770
|
-
"type": 0,
|
|
2771
|
-
"value": "Press enter to add value"
|
|
2772
|
-
}]
|
|
2773
|
-
}),
|
|
2774
|
-
onKeyUp: event => addTags(event),
|
|
2775
|
-
value: inputValue,
|
|
2776
|
-
ref: ref,
|
|
2777
|
-
dataTest: dataTest,
|
|
2778
|
-
onChange: value => {
|
|
2779
|
-
setInputValue(value);
|
|
2780
|
-
}
|
|
2781
|
-
})]
|
|
2782
|
-
});
|
|
2783
|
-
});
|
|
2784
|
-
InputList.displayName = 'InputList';
|
|
2906
|
+
const delayedQuery = useCallback(debounce$1(value => handleSearch(0, false, value), 500), []);
|
|
2785
2907
|
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2908
|
+
const handleSearch = async (page = 0, concat = false, value = '') => {
|
|
2909
|
+
var _data$items_total;
|
|
2910
|
+
|
|
2911
|
+
setOptions({
|
|
2912
|
+
loading: true
|
|
2913
|
+
});
|
|
2914
|
+
let searchTermQs = '';
|
|
2915
|
+
let searchTermParsed = [];
|
|
2916
|
+
|
|
2917
|
+
if (value !== '') {
|
|
2918
|
+
searchTermParsed = parser(`${_queryCondition}=${value}`);
|
|
2919
|
+
}
|
|
2920
|
+
|
|
2921
|
+
const {
|
|
2922
|
+
get
|
|
2923
|
+
} = _traversal.registry;
|
|
2924
|
+
const fnName = get('searchEngineQueryParamsFunction', SearchEngine);
|
|
2925
|
+
|
|
2926
|
+
const qsParsed = _traversal.client[fnName]({
|
|
2927
|
+
path: _traversal.path,
|
|
2928
|
+
start: page * PageSize,
|
|
2929
|
+
pageSize: PageSize,
|
|
2930
|
+
withDepth: false
|
|
2931
|
+
});
|
|
2932
|
+
|
|
2933
|
+
const sortParsed = parser(`_sort_des=${_labelProperty}`);
|
|
2934
|
+
let typeNameParsed = [];
|
|
2935
|
+
|
|
2936
|
+
if (_typeNameQuery) {
|
|
2937
|
+
typeNameParsed = parser(`type_name__in=${_typeNameQuery}`);
|
|
2938
|
+
}
|
|
2939
|
+
|
|
2940
|
+
if (_qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
|
|
2941
|
+
searchTermQs = buildQs([..._qs, ...searchTermParsed, ...qsParsed, ...typeNameParsed, ...sortParsed]);
|
|
2942
|
+
}
|
|
2943
|
+
|
|
2944
|
+
const data = await _traversal.client.search(_path ? _path : _traversal.client.getContainerFromPath(_traversal.path), searchTermQs, false, false);
|
|
2945
|
+
const newItems = options.items && concat ? [...options.items, ...data.items] : data.items;
|
|
2946
|
+
setOptions({
|
|
2947
|
+
items: newItems != null ? newItems : [],
|
|
2948
|
+
loading: false,
|
|
2949
|
+
items_total: (_data$items_total = data.items_total) != null ? _data$items_total : 0,
|
|
2950
|
+
page: page
|
|
2951
|
+
});
|
|
2952
|
+
};
|
|
2953
|
+
|
|
2954
|
+
const inicializeLabels = async () => {
|
|
2955
|
+
if (_labelProperty !== 'id' && value.length > 0) {
|
|
2956
|
+
setIsLoadingData(true);
|
|
2957
|
+
let searchTermQs = '';
|
|
2958
|
+
const searchTermParsed = ['__or', `id=${value.join('%26id=')}`];
|
|
2959
|
+
const {
|
|
2960
|
+
get: getSearch
|
|
2961
|
+
} = _traversal.registry;
|
|
2962
|
+
const fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
|
|
2963
|
+
|
|
2964
|
+
const qsParsed = _traversal.client[fnName]({
|
|
2965
|
+
path: _traversal.path,
|
|
2966
|
+
start: 0,
|
|
2967
|
+
pageSize: 100,
|
|
2968
|
+
withDepth: false
|
|
2969
|
+
});
|
|
2970
|
+
|
|
2971
|
+
let typeNameParsed = [];
|
|
2972
|
+
|
|
2973
|
+
if (_typeNameQuery) {
|
|
2974
|
+
typeNameParsed = parser(`type_name__in=${_typeNameQuery}`);
|
|
2975
|
+
}
|
|
2976
|
+
|
|
2977
|
+
if (_qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
|
|
2978
|
+
searchTermQs = buildQs([..._qs, searchTermParsed, ...qsParsed, ...typeNameParsed]);
|
|
2979
|
+
}
|
|
2980
|
+
|
|
2981
|
+
const data = await _traversal.client.search(_path ? _path : _traversal.client.getContainerFromPath(_traversal.path), searchTermQs, false, false, 0, 100);
|
|
2982
|
+
const newValuesLabel = data.items.reduce((result, item) => {
|
|
2983
|
+
result[item.id] = get$1(item, _labelProperty, item.id);
|
|
2984
|
+
return result;
|
|
2985
|
+
}, {});
|
|
2986
|
+
setValuesLabels(newValuesLabel);
|
|
2987
|
+
setIsLoadingData(false);
|
|
2988
|
+
}
|
|
2989
|
+
};
|
|
2990
|
+
|
|
2991
|
+
const renderTextItemOptionFn = item => {
|
|
2992
|
+
if (_renderTextItemOption) {
|
|
2993
|
+
return _renderTextItemOption(item);
|
|
2994
|
+
}
|
|
2995
|
+
|
|
2996
|
+
return get$1(item, _labelProperty, item.title) || item['@name'];
|
|
2997
|
+
};
|
|
2998
|
+
|
|
2999
|
+
useEffect(() => {
|
|
3000
|
+
if (!options.loading && !options.items && value.length > 0) {
|
|
3001
|
+
inicializeLabels();
|
|
3002
|
+
} else if (value.length === 0) {
|
|
3003
|
+
setValuesLabels({});
|
|
3004
|
+
}
|
|
3005
|
+
}, [_path, options.loading, options.items]);
|
|
3006
|
+
|
|
3007
|
+
if (isLoadingData || valuesLabel === undefined) {
|
|
3008
|
+
return jsx("div", {
|
|
3009
|
+
className: "spinner"
|
|
3010
|
+
});
|
|
3011
|
+
}
|
|
3012
|
+
|
|
3013
|
+
return jsxs(Fragment, {
|
|
3014
|
+
children: [jsx("div", {
|
|
3015
|
+
className: "tags mb-2",
|
|
3016
|
+
children: value.map((tag, index) => jsxs("div", {
|
|
3017
|
+
className: "tag is-info is-medium",
|
|
3018
|
+
children: [get$1(valuesLabel, tag, tag), jsx("button", {
|
|
3019
|
+
className: "delete is-small",
|
|
3020
|
+
onClick: ev => {
|
|
3021
|
+
ev.stopPropagation();
|
|
3022
|
+
ev.preventDefault();
|
|
3023
|
+
onChange([...value.filter(tag => value.indexOf(tag) !== index)]);
|
|
3024
|
+
}
|
|
3025
|
+
})]
|
|
3026
|
+
}, `input_list_${tag}_${index}`))
|
|
3027
|
+
}), jsxs("div", {
|
|
3028
|
+
"data-test": _dataTestWrapper,
|
|
3029
|
+
ref: wrapperRef,
|
|
3030
|
+
className: `dropdown mb-2 ${isOpen ? 'is-active' : ''}`,
|
|
3031
|
+
onBlur: ev => {
|
|
3032
|
+
if (!ev.currentTarget.contains(ev.relatedTarget)) {
|
|
3033
|
+
if (searchTerm !== '') {
|
|
3034
|
+
setSearchTerm('');
|
|
3035
|
+
setOptions(initialState$1);
|
|
3036
|
+
}
|
|
3037
|
+
|
|
3038
|
+
setIsOpen(false);
|
|
3039
|
+
}
|
|
3040
|
+
},
|
|
3041
|
+
children: [jsx("div", {
|
|
3042
|
+
className: "dropdown-trigger",
|
|
3043
|
+
children: jsxs("button", {
|
|
3044
|
+
className: `button ${_btnClass}`,
|
|
3045
|
+
onClick: ev => {
|
|
3046
|
+
ev.preventDefault();
|
|
3047
|
+
setIsOpen(!isOpen);
|
|
3048
|
+
|
|
3049
|
+
if (!options.loading && !options.items) {
|
|
3050
|
+
handleSearch(options.page);
|
|
3051
|
+
}
|
|
3052
|
+
},
|
|
3053
|
+
"aria-haspopup": "true",
|
|
3054
|
+
"aria-controls": "dropdown-menu",
|
|
3055
|
+
children: [jsx("span", {
|
|
3056
|
+
children: intl.formatMessage(genericMessages.choose)
|
|
3057
|
+
}), jsx("span", {
|
|
3058
|
+
className: "icon",
|
|
3059
|
+
children: jsx("i", {
|
|
3060
|
+
className: "fas fa-angle-down",
|
|
3061
|
+
"aria-hidden": "true"
|
|
3062
|
+
})
|
|
3063
|
+
})]
|
|
3064
|
+
})
|
|
3065
|
+
}), jsx("div", {
|
|
3066
|
+
className: "dropdown-menu",
|
|
3067
|
+
id: "dropdown-menu",
|
|
3068
|
+
role: "menu",
|
|
3069
|
+
style: getHeight(),
|
|
3070
|
+
children: jsxs("div", {
|
|
3071
|
+
className: "dropdown-content",
|
|
3072
|
+
children: [jsx("div", {
|
|
3073
|
+
className: "dropdown-item",
|
|
3074
|
+
children: jsx("input", {
|
|
3075
|
+
ref: inputRef,
|
|
3076
|
+
"data-test": _dataTestSearchInput,
|
|
3077
|
+
className: "input",
|
|
3078
|
+
type: "text",
|
|
3079
|
+
placeholder: intl.formatMessage(genericMessages.search),
|
|
3080
|
+
value: searchTerm,
|
|
3081
|
+
onChange: ev => {
|
|
3082
|
+
delayedQuery(ev.target.value);
|
|
3083
|
+
setSearchTerm(ev.target.value);
|
|
3084
|
+
}
|
|
3085
|
+
})
|
|
3086
|
+
}), jsx("hr", {
|
|
3087
|
+
className: "dropdown-divider"
|
|
3088
|
+
}), options.loading && jsx(Loading, {}), options.items && options.items.map(item => {
|
|
3089
|
+
return jsx("div", {
|
|
3090
|
+
className: `dropdown-item editable ${value.includes(item.id) ? 'is-active' : ''}`,
|
|
3091
|
+
"data-test": `${_dataTestItem}-${item.id}`,
|
|
3092
|
+
onMouseDown: ev => {
|
|
3093
|
+
ev.stopPropagation();
|
|
3094
|
+
ev.preventDefault();
|
|
3095
|
+
|
|
3096
|
+
if (onChange && !value.includes(item.id)) {
|
|
3097
|
+
setValuesLabels(_extends({}, valuesLabel, {
|
|
3098
|
+
[item.id]: get$1(item, _labelProperty, item.id)
|
|
3099
|
+
}));
|
|
3100
|
+
onChange([...value, item.id]);
|
|
3101
|
+
}
|
|
3102
|
+
},
|
|
3103
|
+
children: renderTextItemOptionFn(item)
|
|
3104
|
+
}, item.path);
|
|
3105
|
+
}), options.items && options.items.length === 0 && jsx("div", {
|
|
3106
|
+
className: "dropdown-item",
|
|
3107
|
+
children: intl.formatMessage(genericMessages.no_results)
|
|
3108
|
+
}), options.items && options.items_total > options.items.length && jsxs(Fragment, {
|
|
3109
|
+
children: [jsx("hr", {
|
|
3110
|
+
className: "dropdown-divider"
|
|
3111
|
+
}), jsx("div", {
|
|
3112
|
+
className: "dropdown-item editable",
|
|
3113
|
+
onMouseDown: ev => {
|
|
3114
|
+
ev.stopPropagation();
|
|
3115
|
+
ev.preventDefault();
|
|
3116
|
+
handleSearch(options.page + 1, true);
|
|
3117
|
+
},
|
|
3118
|
+
children: intl.formatMessage(genericMessages.load_more)
|
|
3119
|
+
})]
|
|
3120
|
+
})]
|
|
3121
|
+
})
|
|
3122
|
+
})]
|
|
3123
|
+
}), error && jsx(ErrorZone, {
|
|
3124
|
+
className: errorZoneClassName,
|
|
3125
|
+
id: uid,
|
|
3126
|
+
children: error ? error : ''
|
|
3127
|
+
})]
|
|
3128
|
+
});
|
|
3129
|
+
};
|
|
3130
|
+
|
|
3131
|
+
const InputList = forwardRef(({
|
|
3132
|
+
value,
|
|
3133
|
+
onChange,
|
|
3134
|
+
dataTest,
|
|
3135
|
+
id
|
|
3136
|
+
}, ref) => {
|
|
3137
|
+
const intl = useIntl();
|
|
3138
|
+
const [inputValue, setInputValue] = useState('');
|
|
3139
|
+
|
|
3140
|
+
const addTags = event => {
|
|
3141
|
+
if (event.key === 'Enter' && event.target.value !== '') {
|
|
3142
|
+
onChange([...value, event.target.value]);
|
|
3143
|
+
setInputValue('');
|
|
3144
|
+
}
|
|
3145
|
+
};
|
|
3146
|
+
|
|
3147
|
+
return jsxs("div", {
|
|
3148
|
+
className: "control",
|
|
3149
|
+
children: [(value != null ? value : []).length > 0 && jsx("div", {
|
|
3150
|
+
className: "tags",
|
|
3151
|
+
children: value.map((tag, index) => jsxs("div", {
|
|
3152
|
+
className: "tag is-info is-medium",
|
|
3153
|
+
children: [tag, jsx("button", {
|
|
3154
|
+
className: "delete is-small",
|
|
3155
|
+
type: "button",
|
|
3156
|
+
onClick: () => onChange([...value.filter(tag => value.indexOf(tag) !== index)])
|
|
3157
|
+
})]
|
|
3158
|
+
}, `input_list_${tag}_${index}`))
|
|
3159
|
+
}), jsx(Input, {
|
|
3160
|
+
type: "text",
|
|
3161
|
+
id: id,
|
|
3162
|
+
placeholder: intl.formatMessage({
|
|
3163
|
+
id: "press_enter_to_add_value",
|
|
3164
|
+
defaultMessage: [{
|
|
3165
|
+
"type": 0,
|
|
3166
|
+
"value": "Press enter to add value"
|
|
3167
|
+
}]
|
|
3168
|
+
}),
|
|
3169
|
+
onKeyUp: event => addTags(event),
|
|
3170
|
+
value: inputValue,
|
|
3171
|
+
ref: ref,
|
|
3172
|
+
dataTest: dataTest,
|
|
3173
|
+
onChange: value => {
|
|
3174
|
+
setInputValue(value);
|
|
3175
|
+
}
|
|
3176
|
+
})]
|
|
3177
|
+
});
|
|
3178
|
+
});
|
|
3179
|
+
InputList.displayName = 'InputList';
|
|
3180
|
+
|
|
3181
|
+
function Dropdown({
|
|
3182
|
+
children,
|
|
3183
|
+
disabled,
|
|
3184
|
+
id,
|
|
3185
|
+
isRight,
|
|
3186
|
+
onChange,
|
|
2792
3187
|
optionDisabledWhen,
|
|
2793
3188
|
options
|
|
2794
3189
|
}) {
|
|
@@ -3092,47 +3487,6 @@ const DownloadField = ({
|
|
|
3092
3487
|
});
|
|
3093
3488
|
};
|
|
3094
3489
|
|
|
3095
|
-
function useVocabulary(vocabularyName, path = null) {
|
|
3096
|
-
const traversal = useTraversal();
|
|
3097
|
-
const [vocabulary, setVocabulary] = useSetState({
|
|
3098
|
-
data: undefined,
|
|
3099
|
-
loading: false,
|
|
3100
|
-
error: undefined
|
|
3101
|
-
});
|
|
3102
|
-
|
|
3103
|
-
const getPath = () => {
|
|
3104
|
-
if (path) return path;
|
|
3105
|
-
return `${traversal.path}@vocabularies/${vocabularyName}`;
|
|
3106
|
-
};
|
|
3107
|
-
|
|
3108
|
-
useEffect(() => {
|
|
3109
|
-
const getVocabulary = async () => {
|
|
3110
|
-
if (vocabularyName && vocabulary.data === undefined && !vocabulary.loading) {
|
|
3111
|
-
try {
|
|
3112
|
-
setVocabulary({
|
|
3113
|
-
loading: true
|
|
3114
|
-
});
|
|
3115
|
-
const data = await traversal.client.get(getPath());
|
|
3116
|
-
const dataJson = await data.json();
|
|
3117
|
-
setVocabulary({
|
|
3118
|
-
loading: false,
|
|
3119
|
-
data: dataJson
|
|
3120
|
-
});
|
|
3121
|
-
} catch (err) {
|
|
3122
|
-
setVocabulary({
|
|
3123
|
-
loading: false,
|
|
3124
|
-
error: err,
|
|
3125
|
-
data: undefined
|
|
3126
|
-
});
|
|
3127
|
-
}
|
|
3128
|
-
}
|
|
3129
|
-
};
|
|
3130
|
-
|
|
3131
|
-
getVocabulary();
|
|
3132
|
-
}, [vocabularyName, vocabulary, path]);
|
|
3133
|
-
return vocabulary;
|
|
3134
|
-
}
|
|
3135
|
-
|
|
3136
3490
|
const plain = ['string', 'number', 'boolean'];
|
|
3137
3491
|
function RenderField({
|
|
3138
3492
|
value,
|
|
@@ -3263,457 +3617,103 @@ const SearchRenderField = ({
|
|
|
3263
3617
|
}, [value]);
|
|
3264
3618
|
|
|
3265
3619
|
const getRenderValue = () => {
|
|
3266
|
-
if (value === undefined) {
|
|
3267
|
-
if (modifyContent) {
|
|
3268
|
-
return DEFAULT_VALUE_EDITABLE_FIELD;
|
|
3269
|
-
}
|
|
3270
|
-
|
|
3271
|
-
return DEFAULT_VALUE_NO_EDITABLE_FIELD;
|
|
3272
|
-
}
|
|
3273
|
-
|
|
3274
|
-
if (isLoadingData) {
|
|
3275
|
-
return 'Loading...';
|
|
3276
|
-
}
|
|
3277
|
-
|
|
3278
|
-
return valuesLabels;
|
|
3279
|
-
};
|
|
3280
|
-
|
|
3281
|
-
return jsx(RenderField, {
|
|
3282
|
-
value: getRenderValue()
|
|
3283
|
-
});
|
|
3284
|
-
};
|
|
3285
|
-
const VocabularyRenderField = ({
|
|
3286
|
-
schema,
|
|
3287
|
-
value,
|
|
3288
|
-
modifyContent
|
|
3289
|
-
}) => {
|
|
3290
|
-
var _schema$items;
|
|
3291
|
-
|
|
3292
|
-
const intl = useIntl();
|
|
3293
|
-
const DEFAULT_VALUE_EDITABLE_FIELD = getDefaultValueEditableField(intl);
|
|
3294
|
-
const vocabularyName = (schema == null ? void 0 : (_schema$items = schema.items) == null ? void 0 : _schema$items.vocabularyName) || (schema == null ? void 0 : schema.vocabularyName);
|
|
3295
|
-
const vocabulary = useVocabulary(vocabularyName);
|
|
3296
|
-
|
|
3297
|
-
const getRenderProps = () => {
|
|
3298
|
-
const renderProps = {
|
|
3299
|
-
value: value != null ? value : modifyContent ? DEFAULT_VALUE_EDITABLE_FIELD : DEFAULT_VALUE_NO_EDITABLE_FIELD
|
|
3300
|
-
};
|
|
3301
|
-
|
|
3302
|
-
if (schema != null && schema.vocabularyName) {
|
|
3303
|
-
var _vocabularyValue$titl;
|
|
3304
|
-
|
|
3305
|
-
const vocabularyValue = get$1(vocabulary, 'data.items', []).find(item => item.token === value);
|
|
3306
|
-
renderProps['value'] = (_vocabularyValue$titl = vocabularyValue == null ? void 0 : vocabularyValue.title) != null ? _vocabularyValue$titl : '';
|
|
3307
|
-
} else {
|
|
3308
|
-
var _renderProps$value;
|
|
3309
|
-
|
|
3310
|
-
renderProps['value'] = ((_renderProps$value = renderProps['value']) != null ? _renderProps$value : []).map(value => {
|
|
3311
|
-
var _get$find$title, _get$find;
|
|
3312
|
-
|
|
3313
|
-
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 : '';
|
|
3314
|
-
});
|
|
3315
|
-
}
|
|
3316
|
-
|
|
3317
|
-
return renderProps;
|
|
3318
|
-
};
|
|
3319
|
-
|
|
3320
|
-
return jsx(RenderField, _extends({}, getRenderProps()));
|
|
3321
|
-
};
|
|
3322
|
-
function RenderFieldComponent({
|
|
3323
|
-
schema,
|
|
3324
|
-
field,
|
|
3325
|
-
val,
|
|
3326
|
-
modifyContent
|
|
3327
|
-
}) {
|
|
3328
|
-
const intl = useIntl();
|
|
3329
|
-
const DEFAULT_VALUE_EDITABLE_FIELD = getDefaultValueEditableField(intl);
|
|
3330
|
-
|
|
3331
|
-
const getRenderProps = () => {
|
|
3332
|
-
var _schema$items2;
|
|
3333
|
-
|
|
3334
|
-
const renderProps = {
|
|
3335
|
-
value: val != null ? val : modifyContent ? DEFAULT_VALUE_EDITABLE_FIELD : DEFAULT_VALUE_NO_EDITABLE_FIELD,
|
|
3336
|
-
schema: schema
|
|
3337
|
-
};
|
|
3338
|
-
|
|
3339
|
-
if (val && (schema == null ? void 0 : schema.widget) === 'file') {
|
|
3340
|
-
renderProps['value'] = {
|
|
3341
|
-
data: val,
|
|
3342
|
-
field: field
|
|
3343
|
-
};
|
|
3344
|
-
renderProps['Widget'] = DownloadField;
|
|
3345
|
-
} else if ((schema == null ? void 0 : schema.type) === 'boolean') {
|
|
3346
|
-
var _val$toString;
|
|
3347
|
-
|
|
3348
|
-
renderProps['value'] = (_val$toString = val == null ? void 0 : val.toString()) != null ? _val$toString : renderProps['value'];
|
|
3349
|
-
} else if (val && (schema == null ? void 0 : schema.type) === 'datetime') {
|
|
3350
|
-
renderProps['value'] = new Date(val).toLocaleString();
|
|
3351
|
-
} else if (schema != null && (_schema$items2 = schema.items) != null && _schema$items2.vocabularyName || schema != null && schema.vocabularyName) {
|
|
3352
|
-
renderProps['Widget'] = VocabularyRenderField;
|
|
3353
|
-
} else if ((schema == null ? void 0 : schema.widget) === 'search' || (schema == null ? void 0 : schema.widget) === 'search_list') {
|
|
3354
|
-
renderProps['Widget'] = SearchRenderField;
|
|
3355
|
-
renderProps['value'] = val;
|
|
3356
|
-
}
|
|
3357
|
-
|
|
3358
|
-
return renderProps;
|
|
3359
|
-
};
|
|
3360
|
-
|
|
3361
|
-
return jsx(RenderField, _extends({}, getRenderProps()));
|
|
3362
|
-
}
|
|
3363
|
-
|
|
3364
|
-
const SelectVocabulary = forwardRef(({
|
|
3365
|
-
vocabularyName,
|
|
3366
|
-
className,
|
|
3367
|
-
classWrap,
|
|
3368
|
-
val,
|
|
3369
|
-
dataTest,
|
|
3370
|
-
multiple,
|
|
3371
|
-
onChange,
|
|
3372
|
-
id,
|
|
3373
|
-
placeholder
|
|
3374
|
-
}, ref) => {
|
|
3375
|
-
const vocabulary = useVocabulary(vocabularyName);
|
|
3376
|
-
|
|
3377
|
-
const getOptions = () => {
|
|
3378
|
-
if (get$1(vocabulary, 'data.items', null)) {
|
|
3379
|
-
const vocData = vocabulary.data.items.map(item => {
|
|
3380
|
-
return {
|
|
3381
|
-
text: item.title,
|
|
3382
|
-
value: item.token
|
|
3383
|
-
};
|
|
3384
|
-
});
|
|
3385
|
-
return vocData;
|
|
3386
|
-
}
|
|
3387
|
-
|
|
3388
|
-
return [];
|
|
3389
|
-
};
|
|
3390
|
-
|
|
3391
|
-
const getProps = () => {
|
|
3392
|
-
if (multiple) {
|
|
3393
|
-
const currentValue = val || [];
|
|
3394
|
-
return {
|
|
3395
|
-
multiple: true,
|
|
3396
|
-
size: 5,
|
|
3397
|
-
value: currentValue,
|
|
3398
|
-
options: getOptions()
|
|
3399
|
-
};
|
|
3400
|
-
}
|
|
3401
|
-
|
|
3402
|
-
return {
|
|
3403
|
-
value: val != null ? val : '',
|
|
3404
|
-
appendDefault: true,
|
|
3405
|
-
options: getOptions()
|
|
3406
|
-
};
|
|
3407
|
-
};
|
|
3408
|
-
|
|
3409
|
-
if (vocabulary.data === undefined || vocabulary.loading) {
|
|
3410
|
-
return jsx("div", {});
|
|
3411
|
-
}
|
|
3412
|
-
|
|
3413
|
-
return jsx(Select, _extends({}, getProps(), {
|
|
3414
|
-
className: className,
|
|
3415
|
-
classWrap: classWrap || 'is-fullwidth',
|
|
3416
|
-
dataTest: dataTest,
|
|
3417
|
-
ref: ref,
|
|
3418
|
-
onChange: onChange,
|
|
3419
|
-
id: id,
|
|
3420
|
-
placeholder: placeholder
|
|
3421
|
-
}));
|
|
3422
|
-
});
|
|
3423
|
-
SelectVocabulary.displayName = 'SelectVocabulary';
|
|
3424
|
-
|
|
3425
|
-
function debounce$1(func, wait) {
|
|
3426
|
-
let timeout;
|
|
3427
|
-
return function () {
|
|
3428
|
-
const context = this;
|
|
3429
|
-
const args = arguments;
|
|
3430
|
-
|
|
3431
|
-
const later = function later() {
|
|
3432
|
-
timeout = null;
|
|
3433
|
-
func.apply(context, args);
|
|
3434
|
-
};
|
|
3435
|
-
|
|
3436
|
-
clearTimeout(timeout);
|
|
3437
|
-
timeout = setTimeout(later, wait);
|
|
3438
|
-
};
|
|
3439
|
-
}
|
|
3440
|
-
|
|
3441
|
-
const initialState$1 = {
|
|
3442
|
-
page: 0,
|
|
3443
|
-
items: undefined,
|
|
3444
|
-
loading: false,
|
|
3445
|
-
items_total: 0
|
|
3446
|
-
};
|
|
3447
|
-
const SearchInputList = ({
|
|
3448
|
-
onChange,
|
|
3449
|
-
error,
|
|
3450
|
-
errorZoneClassName,
|
|
3451
|
-
traversal: _traversal = null,
|
|
3452
|
-
path: _path = null,
|
|
3453
|
-
qs: _qs = [],
|
|
3454
|
-
queryCondition: _queryCondition = 'id__in',
|
|
3455
|
-
value,
|
|
3456
|
-
btnClass: _btnClass = '',
|
|
3457
|
-
dataTestWrapper: _dataTestWrapper = 'wrapperSearchInputTest',
|
|
3458
|
-
dataTestSearchInput: _dataTestSearchInput = 'searchInputTest',
|
|
3459
|
-
dataTestItem: _dataTestItem = 'searchInputItemTest',
|
|
3460
|
-
renderTextItemOption: _renderTextItemOption = null,
|
|
3461
|
-
typeNameQuery: _typeNameQuery = null,
|
|
3462
|
-
labelProperty: _labelProperty = 'id'
|
|
3463
|
-
}) => {
|
|
3464
|
-
const intl = useIntl();
|
|
3465
|
-
const [options, setOptions] = useSetState(initialState$1);
|
|
3466
|
-
const [valuesLabel, setValuesLabels] = useState(undefined);
|
|
3467
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
3468
|
-
const [searchTerm, setSearchTerm] = useState('');
|
|
3469
|
-
const inputRef = useRef(null);
|
|
3470
|
-
const wrapperRef = useRef(null);
|
|
3471
|
-
const {
|
|
3472
|
-
PageSize,
|
|
3473
|
-
SearchEngine
|
|
3474
|
-
} = useConfig();
|
|
3475
|
-
const [isLoadingData, setIsLoadingData] = useState(false);
|
|
3476
|
-
const [uid] = useState(generateUID('search_input'));
|
|
3477
|
-
useClickAway(wrapperRef, () => {
|
|
3478
|
-
setIsOpen(false);
|
|
3479
|
-
});
|
|
3480
|
-
|
|
3481
|
-
const getHeight = () => {
|
|
3482
|
-
if (wrapperRef && wrapperRef.current) {
|
|
3483
|
-
return {
|
|
3484
|
-
maxHeight: `${window.innerHeight - wrapperRef.current.getBoundingClientRect().top - 100}px`
|
|
3485
|
-
};
|
|
3486
|
-
}
|
|
3487
|
-
|
|
3488
|
-
return {
|
|
3489
|
-
maxHeight: 'auto'
|
|
3490
|
-
};
|
|
3491
|
-
};
|
|
3492
|
-
|
|
3493
|
-
const delayedQuery = useCallback(debounce$1(value => handleSearch(0, false, value), 500), []);
|
|
3494
|
-
|
|
3495
|
-
const handleSearch = async (page = 0, concat = false, value = '') => {
|
|
3496
|
-
var _data$items_total;
|
|
3497
|
-
|
|
3498
|
-
setOptions({
|
|
3499
|
-
loading: true
|
|
3500
|
-
});
|
|
3501
|
-
let searchTermQs = '';
|
|
3502
|
-
let searchTermParsed = [];
|
|
3503
|
-
|
|
3504
|
-
if (value !== '') {
|
|
3505
|
-
searchTermParsed = parser(`${_queryCondition}=${value}`);
|
|
3506
|
-
}
|
|
3507
|
-
|
|
3508
|
-
const {
|
|
3509
|
-
get
|
|
3510
|
-
} = _traversal.registry;
|
|
3511
|
-
const fnName = get('searchEngineQueryParamsFunction', SearchEngine);
|
|
3512
|
-
|
|
3513
|
-
const qsParsed = _traversal.client[fnName]({
|
|
3514
|
-
path: _traversal.path,
|
|
3515
|
-
start: page * PageSize,
|
|
3516
|
-
pageSize: PageSize,
|
|
3517
|
-
withDepth: false
|
|
3518
|
-
});
|
|
3519
|
-
|
|
3520
|
-
const sortParsed = parser(`_sort_des=${_labelProperty}`);
|
|
3521
|
-
let typeNameParsed = [];
|
|
3620
|
+
if (value === undefined) {
|
|
3621
|
+
if (modifyContent) {
|
|
3622
|
+
return DEFAULT_VALUE_EDITABLE_FIELD;
|
|
3623
|
+
}
|
|
3522
3624
|
|
|
3523
|
-
|
|
3524
|
-
typeNameParsed = parser(`type_name__in=${_typeNameQuery}`);
|
|
3625
|
+
return DEFAULT_VALUE_NO_EDITABLE_FIELD;
|
|
3525
3626
|
}
|
|
3526
3627
|
|
|
3527
|
-
if (
|
|
3528
|
-
|
|
3628
|
+
if (isLoadingData) {
|
|
3629
|
+
return 'Loading...';
|
|
3529
3630
|
}
|
|
3530
3631
|
|
|
3531
|
-
|
|
3532
|
-
const newItems = options.items && concat ? [...options.items, ...data.items] : data.items;
|
|
3533
|
-
setOptions({
|
|
3534
|
-
items: newItems != null ? newItems : [],
|
|
3535
|
-
loading: false,
|
|
3536
|
-
items_total: (_data$items_total = data.items_total) != null ? _data$items_total : 0,
|
|
3537
|
-
page: page
|
|
3538
|
-
});
|
|
3632
|
+
return valuesLabels;
|
|
3539
3633
|
};
|
|
3540
3634
|
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3635
|
+
return jsx(RenderField, {
|
|
3636
|
+
value: getRenderValue()
|
|
3637
|
+
});
|
|
3638
|
+
};
|
|
3639
|
+
const VocabularyRenderField = ({
|
|
3640
|
+
schema,
|
|
3641
|
+
value,
|
|
3642
|
+
modifyContent
|
|
3643
|
+
}) => {
|
|
3644
|
+
var _schema$items;
|
|
3550
3645
|
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
withDepth: false
|
|
3556
|
-
});
|
|
3646
|
+
const intl = useIntl();
|
|
3647
|
+
const DEFAULT_VALUE_EDITABLE_FIELD = getDefaultValueEditableField(intl);
|
|
3648
|
+
const vocabularyName = (schema == null ? void 0 : (_schema$items = schema.items) == null ? void 0 : _schema$items.vocabularyName) || (schema == null ? void 0 : schema.vocabularyName);
|
|
3649
|
+
const vocabulary = useVocabulary(vocabularyName);
|
|
3557
3650
|
|
|
3558
|
-
|
|
3651
|
+
const getRenderProps = () => {
|
|
3652
|
+
const renderProps = {
|
|
3653
|
+
value: value != null ? value : modifyContent ? DEFAULT_VALUE_EDITABLE_FIELD : DEFAULT_VALUE_NO_EDITABLE_FIELD
|
|
3654
|
+
};
|
|
3559
3655
|
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
}
|
|
3656
|
+
if (schema != null && schema.vocabularyName) {
|
|
3657
|
+
var _vocabularyValue$titl;
|
|
3563
3658
|
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3659
|
+
const vocabularyValue = get$1(vocabulary, 'data.items', []).find(item => item.token === value);
|
|
3660
|
+
renderProps['value'] = (_vocabularyValue$titl = vocabularyValue == null ? void 0 : vocabularyValue.title) != null ? _vocabularyValue$titl : '';
|
|
3661
|
+
} else {
|
|
3662
|
+
var _renderProps$value;
|
|
3567
3663
|
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
result[item.id] = get$1(item, _labelProperty, item.id);
|
|
3571
|
-
return result;
|
|
3572
|
-
}, {});
|
|
3573
|
-
setValuesLabels(newValuesLabel);
|
|
3574
|
-
setIsLoadingData(false);
|
|
3575
|
-
}
|
|
3576
|
-
};
|
|
3664
|
+
renderProps['value'] = ((_renderProps$value = renderProps['value']) != null ? _renderProps$value : []).map(value => {
|
|
3665
|
+
var _get$find$title, _get$find;
|
|
3577
3666
|
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
return _renderTextItemOption(item);
|
|
3667
|
+
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 : '';
|
|
3668
|
+
});
|
|
3581
3669
|
}
|
|
3582
3670
|
|
|
3583
|
-
return
|
|
3671
|
+
return renderProps;
|
|
3584
3672
|
};
|
|
3585
3673
|
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3674
|
+
return jsx(RenderField, _extends({}, getRenderProps()));
|
|
3675
|
+
};
|
|
3676
|
+
function RenderFieldComponent({
|
|
3677
|
+
schema,
|
|
3678
|
+
field,
|
|
3679
|
+
val,
|
|
3680
|
+
modifyContent
|
|
3681
|
+
}) {
|
|
3682
|
+
const intl = useIntl();
|
|
3683
|
+
const DEFAULT_VALUE_EDITABLE_FIELD = getDefaultValueEditableField(intl);
|
|
3593
3684
|
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
className: "spinner"
|
|
3597
|
-
});
|
|
3598
|
-
}
|
|
3685
|
+
const getRenderProps = () => {
|
|
3686
|
+
var _schema$items2;
|
|
3599
3687
|
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
className: "tag is-info is-medium",
|
|
3605
|
-
children: [get$1(valuesLabel, tag, tag), jsx("button", {
|
|
3606
|
-
className: "delete is-small",
|
|
3607
|
-
onClick: ev => {
|
|
3608
|
-
ev.stopPropagation();
|
|
3609
|
-
ev.preventDefault();
|
|
3610
|
-
onChange([...value.filter(tag => value.indexOf(tag) !== index)]);
|
|
3611
|
-
}
|
|
3612
|
-
})]
|
|
3613
|
-
}, `input_list_${tag}_${index}`))
|
|
3614
|
-
}), jsxs("div", {
|
|
3615
|
-
"data-test": _dataTestWrapper,
|
|
3616
|
-
ref: wrapperRef,
|
|
3617
|
-
className: `dropdown mb-2 ${isOpen ? 'is-active' : ''}`,
|
|
3618
|
-
onBlur: ev => {
|
|
3619
|
-
if (!ev.currentTarget.contains(ev.relatedTarget)) {
|
|
3620
|
-
if (searchTerm !== '') {
|
|
3621
|
-
setSearchTerm('');
|
|
3622
|
-
setOptions(initialState$1);
|
|
3623
|
-
}
|
|
3688
|
+
const renderProps = {
|
|
3689
|
+
value: val != null ? val : modifyContent ? DEFAULT_VALUE_EDITABLE_FIELD : DEFAULT_VALUE_NO_EDITABLE_FIELD,
|
|
3690
|
+
schema: schema
|
|
3691
|
+
};
|
|
3624
3692
|
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
ev.preventDefault();
|
|
3634
|
-
setIsOpen(!isOpen);
|
|
3693
|
+
if (val && (schema == null ? void 0 : schema.widget) === 'file') {
|
|
3694
|
+
renderProps['value'] = {
|
|
3695
|
+
data: val,
|
|
3696
|
+
field: field
|
|
3697
|
+
};
|
|
3698
|
+
renderProps['Widget'] = DownloadField;
|
|
3699
|
+
} else if ((schema == null ? void 0 : schema.type) === 'boolean') {
|
|
3700
|
+
var _val$toString;
|
|
3635
3701
|
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
className: "icon",
|
|
3646
|
-
children: jsx("i", {
|
|
3647
|
-
className: "fas fa-angle-down",
|
|
3648
|
-
"aria-hidden": "true"
|
|
3649
|
-
})
|
|
3650
|
-
})]
|
|
3651
|
-
})
|
|
3652
|
-
}), jsx("div", {
|
|
3653
|
-
className: "dropdown-menu",
|
|
3654
|
-
id: "dropdown-menu",
|
|
3655
|
-
role: "menu",
|
|
3656
|
-
style: getHeight(),
|
|
3657
|
-
children: jsxs("div", {
|
|
3658
|
-
className: "dropdown-content",
|
|
3659
|
-
children: [jsx("div", {
|
|
3660
|
-
className: "dropdown-item",
|
|
3661
|
-
children: jsx("input", {
|
|
3662
|
-
ref: inputRef,
|
|
3663
|
-
"data-test": _dataTestSearchInput,
|
|
3664
|
-
className: "input",
|
|
3665
|
-
type: "text",
|
|
3666
|
-
placeholder: intl.formatMessage(genericMessages.search),
|
|
3667
|
-
value: searchTerm,
|
|
3668
|
-
onChange: ev => {
|
|
3669
|
-
delayedQuery(ev.target.value);
|
|
3670
|
-
setSearchTerm(ev.target.value);
|
|
3671
|
-
}
|
|
3672
|
-
})
|
|
3673
|
-
}), jsx("hr", {
|
|
3674
|
-
className: "dropdown-divider"
|
|
3675
|
-
}), options.loading && jsx(Loading, {}), options.items && options.items.map(item => {
|
|
3676
|
-
return jsx("div", {
|
|
3677
|
-
className: `dropdown-item editable ${value.includes(item.id) ? 'is-active' : ''}`,
|
|
3678
|
-
"data-test": `${_dataTestItem}-${item.id}`,
|
|
3679
|
-
onMouseDown: ev => {
|
|
3680
|
-
ev.stopPropagation();
|
|
3681
|
-
ev.preventDefault();
|
|
3702
|
+
renderProps['value'] = (_val$toString = val == null ? void 0 : val.toString()) != null ? _val$toString : renderProps['value'];
|
|
3703
|
+
} else if (val && (schema == null ? void 0 : schema.type) === 'datetime') {
|
|
3704
|
+
renderProps['value'] = new Date(val).toLocaleString();
|
|
3705
|
+
} else if (schema != null && (_schema$items2 = schema.items) != null && _schema$items2.vocabularyName || schema != null && schema.vocabularyName) {
|
|
3706
|
+
renderProps['Widget'] = VocabularyRenderField;
|
|
3707
|
+
} else if ((schema == null ? void 0 : schema.widget) === 'search' || (schema == null ? void 0 : schema.widget) === 'search_list') {
|
|
3708
|
+
renderProps['Widget'] = SearchRenderField;
|
|
3709
|
+
renderProps['value'] = val;
|
|
3710
|
+
}
|
|
3682
3711
|
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
}
|
|
3689
|
-
},
|
|
3690
|
-
children: renderTextItemOptionFn(item)
|
|
3691
|
-
}, item.path);
|
|
3692
|
-
}), options.items && options.items.length === 0 && jsx("div", {
|
|
3693
|
-
className: "dropdown-item",
|
|
3694
|
-
children: intl.formatMessage(genericMessages.no_results)
|
|
3695
|
-
}), options.items && options.items_total > options.items.length && jsxs(Fragment, {
|
|
3696
|
-
children: [jsx("hr", {
|
|
3697
|
-
className: "dropdown-divider"
|
|
3698
|
-
}), jsx("div", {
|
|
3699
|
-
className: "dropdown-item editable",
|
|
3700
|
-
onMouseDown: ev => {
|
|
3701
|
-
ev.stopPropagation();
|
|
3702
|
-
ev.preventDefault();
|
|
3703
|
-
handleSearch(options.page + 1, true);
|
|
3704
|
-
},
|
|
3705
|
-
children: intl.formatMessage(genericMessages.load_more)
|
|
3706
|
-
})]
|
|
3707
|
-
})]
|
|
3708
|
-
})
|
|
3709
|
-
})]
|
|
3710
|
-
}), error && jsx(ErrorZone, {
|
|
3711
|
-
className: errorZoneClassName,
|
|
3712
|
-
id: uid,
|
|
3713
|
-
children: error ? error : ''
|
|
3714
|
-
})]
|
|
3715
|
-
});
|
|
3716
|
-
};
|
|
3712
|
+
return renderProps;
|
|
3713
|
+
};
|
|
3714
|
+
|
|
3715
|
+
return jsx(RenderField, _extends({}, getRenderProps()));
|
|
3716
|
+
}
|
|
3717
3717
|
|
|
3718
3718
|
const EditComponent = forwardRef(({
|
|
3719
3719
|
schema,
|
|
@@ -5670,6 +5670,15 @@ function PanelItems() {
|
|
|
5670
5670
|
get
|
|
5671
5671
|
} = Ctx.registry;
|
|
5672
5672
|
const fnName = get('searchEngineQueryParamsFunction', SearchEngine);
|
|
5673
|
+
|
|
5674
|
+
if (sortParsed === undefined) {
|
|
5675
|
+
const defaultSortValue = Ctx.registry.getDefaultSortValue(Ctx.context['@type'], {
|
|
5676
|
+
key: 'id',
|
|
5677
|
+
direction: 'des'
|
|
5678
|
+
});
|
|
5679
|
+
sortParsed = parser(`_sort_${defaultSortValue.direction}=${defaultSortValue.key}}`);
|
|
5680
|
+
}
|
|
5681
|
+
|
|
5673
5682
|
const qsParsed = Ctx.client[fnName]({
|
|
5674
5683
|
path: Ctx.path,
|
|
5675
5684
|
start: page * PageSize,
|
|
@@ -8582,7 +8591,8 @@ const registry = {
|
|
|
8582
8591
|
},
|
|
8583
8592
|
fieldsToFilter: {
|
|
8584
8593
|
UserManager: ['id', 'email', 'user_name']
|
|
8585
|
-
}
|
|
8594
|
+
},
|
|
8595
|
+
defaultSortValue: {}
|
|
8586
8596
|
};
|
|
8587
8597
|
|
|
8588
8598
|
const get$2 = (key, param, fallback = undefined) => {
|
|
@@ -8642,6 +8652,10 @@ const getFieldsToFilter = (type, fallback) => {
|
|
|
8642
8652
|
return registry.fieldsToFilter[type] || fallback;
|
|
8643
8653
|
};
|
|
8644
8654
|
|
|
8655
|
+
const getDefaultSortValue = (type, fallback) => {
|
|
8656
|
+
return registry.defaultSortValue[type] || fallback;
|
|
8657
|
+
};
|
|
8658
|
+
|
|
8645
8659
|
const defaultComponent = context => {
|
|
8646
8660
|
return context.is_folderish ? FolderCtx : ItemCtx;
|
|
8647
8661
|
};
|
|
@@ -8663,6 +8677,7 @@ function useRegistry(data) {
|
|
|
8663
8677
|
getProperties,
|
|
8664
8678
|
getItemsColumn,
|
|
8665
8679
|
getFieldsToFilter,
|
|
8680
|
+
getDefaultSortValue,
|
|
8666
8681
|
getSchemas
|
|
8667
8682
|
};
|
|
8668
8683
|
}
|
|
@@ -12157,5 +12172,5 @@ class Auth {
|
|
|
12157
12172
|
|
|
12158
12173
|
}
|
|
12159
12174
|
|
|
12160
|
-
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, Traversal, TraversalContext, TraversalProvider, UserCtx, UserForm, UsersCtx, UsersToolbar, VocabularyRenderField, base64ToArrayBuffer, buildQs, classnames, defaultComponent, formatDate, generateUID, genericFileMessages, genericMessages, 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 };
|
|
12175
|
+
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, SearchInputList, SearchLabels, SearchOptionsLabels, SearchRenderField, SearchVocabularyLabels, Select, SelectVocabulary, Sharing, Table, TabsPanel, Tag, TagsWidget, TdLink, Textarea, Traversal, TraversalContext, TraversalProvider, UserCtx, UserForm, UsersCtx, UsersToolbar, VocabularyRenderField, base64ToArrayBuffer, buildQs, classnames, defaultComponent, formatDate, generateUID, genericFileMessages, genericMessages, 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 };
|
|
12161
12176
|
//# sourceMappingURL=react-gmi.modern.js.map
|