diff --git a/CHANGELOG.md b/CHANGELOG.md index 0129224..f002a60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +0.25.2 +------ +- feat: use label property to render info in search inputs and to sort elements + 0.25.1 ------ - chore: export generic Messages diff --git a/package.json b/package.json index 44dd4a9..d511e71 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.25.1", + "version": "0.25.2", "repository": { "type": "git", "url": "git@github.com:guillotinaweb/guillotina_react.git" diff --git a/src/guillo-gmi/components/input/search_input.js b/src/guillo-gmi/components/input/search_input.js index 1fd3ff1..8528b60 100644 --- a/src/guillo-gmi/components/input/search_input.js +++ b/src/guillo-gmi/components/input/search_input.js @@ -58,7 +58,6 @@ export const SearchInput = ({ const wrapperRef = React.useRef(null) const { PageSize, SearchEngine } = useConfig() const [valueLabel, setValueLabel] = useState(undefined) - const [isLoadingData, setIsLoadingData] = useState(false) const [uid] = useState(generateUID('search_input')) useClickAway(wrapperRef, () => { @@ -85,7 +84,6 @@ export const SearchInput = ({ const inicializeLabels = async () => { if (labelProperty !== 'id' && value) { - setIsLoadingData(true) let searchTermQs = [] const searchTermParsed = [`id`, value] const { get: getSearch } = traversal.registry @@ -124,7 +122,6 @@ export const SearchInput = ({ return result }, {}) setValueLabel(newValuesLabel) - setIsLoadingData(false) } } @@ -143,7 +140,7 @@ export const SearchInput = ({ pageSize: PageSize, withDepth: false, }) - let sortParsed = parser(`_sort_des=title`) + let sortParsed = parser(`_sort_des=${labelProperty}`) let typeNameParsed = [] if (typeNameQuery) { typeNameParsed = parser(`type_name__in=${typeNameQuery}`) @@ -185,7 +182,7 @@ export const SearchInput = ({ if (renderTextItemOption) { return renderTextItemOption(item) } - return item.title || item['@name'] + return get(item, labelProperty, item.title) || item['@name'] } useEffect(() => { diff --git a/src/guillo-gmi/components/input/search_input_list.js b/src/guillo-gmi/components/input/search_input_list.js index 8d744dc..55de4c1 100644 --- a/src/guillo-gmi/components/input/search_input_list.js +++ b/src/guillo-gmi/components/input/search_input_list.js @@ -99,7 +99,7 @@ export const SearchInputList = ({ pageSize: PageSize, withDepth: false, }) - let sortParsed = parser(`_sort_des=title`) + let sortParsed = parser(`_sort_des=${labelProperty}`) let typeNameParsed = [] if (typeNameQuery) { typeNameParsed = parser(`type_name__in=${typeNameQuery}`) @@ -188,7 +188,7 @@ export const SearchInputList = ({ if (renderTextItemOption) { return renderTextItemOption(item) } - return item.title || item['@name'] + return get(item, labelProperty, item.title) || item['@name'] } React.useEffect(() => {