|
@@ -6,16 +6,15 @@ import { useTranslation } from 'react-i18next';
|
|
|
import { parse as parseQuerystring } from 'querystring';
|
|
import { parse as parseQuerystring } from 'querystring';
|
|
|
|
|
|
|
|
import AppContainer from '~/client/services/AppContainer';
|
|
import AppContainer from '~/client/services/AppContainer';
|
|
|
-import { IFormattedSearchResult, IPageSearchMeta } from '~/interfaces/search';
|
|
|
|
|
-import { IPageWithMeta } from '~/interfaces/page';
|
|
|
|
|
-
|
|
|
|
|
|
|
+import { IFormattedSearchResult } from '~/interfaces/search';
|
|
|
|
|
+import { ISelectableAll, ISelectableAndIndeterminatable } from '~/client/interfaces/selectable-all';
|
|
|
import { ISearchConditions, ISearchConfigurations, useSWRxFullTextSearch } from '~/stores/search';
|
|
import { ISearchConditions, ISearchConfigurations, useSWRxFullTextSearch } from '~/stores/search';
|
|
|
|
|
+
|
|
|
import PaginationWrapper from './PaginationWrapper';
|
|
import PaginationWrapper from './PaginationWrapper';
|
|
|
-import { OperateAllControl, useSelectAll } from './SearchPage/OperateAllControl';
|
|
|
|
|
|
|
+import { OperateAllControl } from './SearchPage/OperateAllControl';
|
|
|
import SearchControl from './SearchPage/SearchControl';
|
|
import SearchControl from './SearchPage/SearchControl';
|
|
|
|
|
|
|
|
import { SearchPageBase } from './SearchPage2/SearchPageBase';
|
|
import { SearchPageBase } from './SearchPage2/SearchPageBase';
|
|
|
-import { ISelectableAll } from '~/client/interfaces/selectable-all';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: replace with "customize:showPageLimitationS"
|
|
// TODO: replace with "customize:showPageLimitationS"
|
|
@@ -105,6 +104,7 @@ export const SearchPage = (props: Props): JSX.Element => {
|
|
|
limit: INITIAL_PAGIONG_SIZE,
|
|
limit: INITIAL_PAGIONG_SIZE,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ const selectAllControlRef = useRef<ISelectableAndIndeterminatable|null>(null);
|
|
|
const searchPageBaseRef = useRef<ISelectableAll|null>(null);
|
|
const searchPageBaseRef = useRef<ISelectableAll|null>(null);
|
|
|
|
|
|
|
|
const { data, conditions } = useSWRxFullTextSearch(keyword, {
|
|
const { data, conditions } = useSWRxFullTextSearch(keyword, {
|
|
@@ -113,11 +113,6 @@ export const SearchPage = (props: Props): JSX.Element => {
|
|
|
...configurationsByPagination,
|
|
...configurationsByPagination,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- const {
|
|
|
|
|
- checkboxType: selectAllPagesCheckboxType,
|
|
|
|
|
- setSelectedCount: setSelectedPagesCount,
|
|
|
|
|
- } = useSelectAll(data?.meta.hitsCount);
|
|
|
|
|
-
|
|
|
|
|
const searchInvokedHandler = useCallback((_keyword: string, newConfigurations: Partial<ISearchConfigurations>) => {
|
|
const searchInvokedHandler = useCallback((_keyword: string, newConfigurations: Partial<ISearchConfigurations>) => {
|
|
|
setKeyword(_keyword);
|
|
setKeyword(_keyword);
|
|
|
setConfigurationsByControl(newConfigurations);
|
|
setConfigurationsByControl(newConfigurations);
|
|
@@ -133,7 +128,7 @@ export const SearchPage = (props: Props): JSX.Element => {
|
|
|
if (isChecked) {
|
|
if (isChecked) {
|
|
|
instance.selectAll();
|
|
instance.selectAll();
|
|
|
}
|
|
}
|
|
|
- if (!isChecked) {
|
|
|
|
|
|
|
+ else {
|
|
|
instance.deselectAll();
|
|
instance.deselectAll();
|
|
|
}
|
|
}
|
|
|
}, []);
|
|
}, []);
|
|
@@ -159,8 +154,8 @@ export const SearchPage = (props: Props): JSX.Element => {
|
|
|
newUrl.searchParams.append('q', keyword);
|
|
newUrl.searchParams.append('q', keyword);
|
|
|
window.history.pushState('', `Search - ${keyword}`, `${newUrl.pathname}${newUrl.search}`);
|
|
window.history.pushState('', `Search - ${keyword}`, `${newUrl.pathname}${newUrl.search}`);
|
|
|
}, [keyword]);
|
|
}, [keyword]);
|
|
|
-
|
|
|
|
|
const hitsCount = data?.meta.hitsCount;
|
|
const hitsCount = data?.meta.hitsCount;
|
|
|
|
|
+
|
|
|
const { offset, limit } = conditions;
|
|
const { offset, limit } = conditions;
|
|
|
|
|
|
|
|
const deleteAllControl = useMemo(() => {
|
|
const deleteAllControl = useMemo(() => {
|
|
@@ -168,7 +163,7 @@ export const SearchPage = (props: Props): JSX.Element => {
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<OperateAllControl
|
|
<OperateAllControl
|
|
|
- checkboxType={selectAllPagesCheckboxType}
|
|
|
|
|
|
|
+ ref={selectAllControlRef}
|
|
|
isCheckboxDisabled={isDisabled}
|
|
isCheckboxDisabled={isDisabled}
|
|
|
onCheckboxChanged={selectAllCheckboxChangedHandler}
|
|
onCheckboxChanged={selectAllCheckboxChangedHandler}
|
|
|
>
|
|
>
|
|
@@ -183,7 +178,7 @@ export const SearchPage = (props: Props): JSX.Element => {
|
|
|
</button>
|
|
</button>
|
|
|
</OperateAllControl>
|
|
</OperateAllControl>
|
|
|
);
|
|
);
|
|
|
- }, [hitsCount, selectAllCheckboxChangedHandler, selectAllPagesCheckboxType, t]);
|
|
|
|
|
|
|
+ }, [hitsCount, selectAllCheckboxChangedHandler, t]);
|
|
|
|
|
|
|
|
const searchControl = useMemo(() => {
|
|
const searchControl = useMemo(() => {
|
|
|
return (
|
|
return (
|
|
@@ -230,19 +225,12 @@ export const SearchPage = (props: Props): JSX.Element => {
|
|
|
);
|
|
);
|
|
|
}, [conditions, configurationsByPagination?.limit, data, pagingNumberChangedHandler]);
|
|
}, [conditions, configurationsByPagination?.limit, data, pagingNumberChangedHandler]);
|
|
|
|
|
|
|
|
- // reset selected count when data is refetched
|
|
|
|
|
- useEffect(() => {
|
|
|
|
|
- if (data != null) {
|
|
|
|
|
- setSelectedPagesCount(0);
|
|
|
|
|
- }
|
|
|
|
|
- }, [data, setSelectedPagesCount]);
|
|
|
|
|
-
|
|
|
|
|
return (
|
|
return (
|
|
|
<SearchPageBase
|
|
<SearchPageBase
|
|
|
ref={searchPageBaseRef}
|
|
ref={searchPageBaseRef}
|
|
|
appContainer={appContainer}
|
|
appContainer={appContainer}
|
|
|
pages={data?.data}
|
|
pages={data?.data}
|
|
|
- onSelectedPagesByCheckboxesChanged={setSelectedPagesCount}
|
|
|
|
|
|
|
+ onSelectedPagesByCheckboxesChanged={selectedPagesByCheckboxesChangedHandler}
|
|
|
// Components
|
|
// Components
|
|
|
searchControl={searchControl}
|
|
searchControl={searchControl}
|
|
|
searchResultListHead={searchResultListHead}
|
|
searchResultListHead={searchResultListHead}
|