|
@@ -1,33 +1,38 @@
|
|
|
-import React, { FC } from 'react';
|
|
|
|
|
|
|
+import React, { FC, useState } from 'react';
|
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
import SearchPageForm from './SearchPageForm';
|
|
import SearchPageForm from './SearchPageForm';
|
|
|
import AppContainer from '../../client/services/AppContainer';
|
|
import AppContainer from '../../client/services/AppContainer';
|
|
|
import DeleteSelectedPageGroup from './DeleteSelectedPageGroup';
|
|
import DeleteSelectedPageGroup from './DeleteSelectedPageGroup';
|
|
|
|
|
+import SearchOptionModal from './SearchOptionModal';
|
|
|
import { CheckboxType } from '../../interfaces/search';
|
|
import { CheckboxType } from '../../interfaces/search';
|
|
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
|
searchingKeyword: string,
|
|
searchingKeyword: string,
|
|
|
appContainer: AppContainer,
|
|
appContainer: AppContainer,
|
|
|
- onSearchInvoked: (data : any[]) => boolean,
|
|
|
|
|
- onExcludeUsersHome?: () => void,
|
|
|
|
|
- onExcludeTrash?: () => void,
|
|
|
|
|
|
|
+ excludeUserPages: boolean,
|
|
|
|
|
+ excludeTrashPages: boolean,
|
|
|
|
|
+ onSearchInvoked: (data: {keyword: string}) => boolean,
|
|
|
|
|
+ onExcludeUserPagesSwitched?: () => void,
|
|
|
|
|
+ onExcludeTrashPagesSwitched?: () => void,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const SearchControl: FC <Props> = (props: Props) => {
|
|
const SearchControl: FC <Props> = (props: Props) => {
|
|
|
|
|
+
|
|
|
|
|
+ const [isFileterOptionModalShown, setIsFileterOptionModalShown] = useState(false);
|
|
|
// Temporaly workaround for lint error
|
|
// Temporaly workaround for lint error
|
|
|
// later needs to be fixed: SearchControl to typescript componet
|
|
// later needs to be fixed: SearchControl to typescript componet
|
|
|
const SearchPageFormTypeAny : any = SearchPageForm;
|
|
const SearchPageFormTypeAny : any = SearchPageForm;
|
|
|
const { t } = useTranslation('');
|
|
const { t } = useTranslation('');
|
|
|
|
|
|
|
|
- const onExcludeUsersHome = () => {
|
|
|
|
|
- if (props.onExcludeUsersHome != null) {
|
|
|
|
|
- props.onExcludeUsersHome();
|
|
|
|
|
|
|
+ const switchExcludeUserPagesHandler = () => {
|
|
|
|
|
+ if (props.onExcludeUserPagesSwitched != null) {
|
|
|
|
|
+ props.onExcludeUserPagesSwitched();
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const onExcludeTrash = () => {
|
|
|
|
|
- if (props.onExcludeTrash != null) {
|
|
|
|
|
- props.onExcludeTrash();
|
|
|
|
|
|
|
+ const switchExcludeTrashPagesHandler = () => {
|
|
|
|
|
+ if (props.onExcludeTrashPagesSwitched != null) {
|
|
|
|
|
+ props.onExcludeTrashPagesSwitched();
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -46,6 +51,34 @@ const SearchControl: FC <Props> = (props: Props) => {
|
|
|
// ref: https://getbootstrap.com/docs/4.5/components/forms/#checkboxes
|
|
// ref: https://getbootstrap.com/docs/4.5/components/forms/#checkboxes
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ const openSearchOptionModalHandler = () => {
|
|
|
|
|
+ setIsFileterOptionModalShown(true);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const closeSearchOptionModalHandler = () => {
|
|
|
|
|
+ setIsFileterOptionModalShown(false);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const onRetrySearchInvoked = () => {
|
|
|
|
|
+ if (props.onSearchInvoked != null) {
|
|
|
|
|
+ props.onSearchInvoked({ keyword: props.searchingKeyword });
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const rednerSearchOptionModal = () => {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <SearchOptionModal
|
|
|
|
|
+ isOpen={isFileterOptionModalShown || false}
|
|
|
|
|
+ onClickFilteringSearchResult={onRetrySearchInvoked}
|
|
|
|
|
+ onClose={closeSearchOptionModalHandler}
|
|
|
|
|
+ onExcludeUserPagesSwitched={switchExcludeUserPagesHandler}
|
|
|
|
|
+ onExcludeTrashPagesSwitched={switchExcludeTrashPagesHandler}
|
|
|
|
|
+ excludeUserPages={props.excludeUserPages}
|
|
|
|
|
+ excludeTrashPages={props.excludeTrashPages}
|
|
|
|
|
+ />
|
|
|
|
|
+ );
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
<div className="search-page-nav d-flex py-3 align-items-center">
|
|
<div className="search-page-nav d-flex py-3 align-items-center">
|
|
@@ -71,14 +104,24 @@ const SearchControl: FC <Props> = (props: Props) => {
|
|
|
onCheckInvoked={onCheckAllPagesInvoked}
|
|
onCheckInvoked={onCheckAllPagesInvoked}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
- <div className="d-flex align-items-center mr-3">
|
|
|
|
|
|
|
+ {/** filter option */}
|
|
|
|
|
+ <div className="d-lg-none mr-4">
|
|
|
|
|
+ <button
|
|
|
|
|
+ type="button"
|
|
|
|
|
+ className="btn"
|
|
|
|
|
+ onClick={openSearchOptionModalHandler}
|
|
|
|
|
+ >
|
|
|
|
|
+ <i className="icon-equalizer"></i>
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="d-none d-lg-flex align-items-center mr-3">
|
|
|
<div className="border border-gray mr-3">
|
|
<div className="border border-gray mr-3">
|
|
|
<label className="px-3 py-2 mb-0 d-flex align-items-center" htmlFor="flexCheckDefault">
|
|
<label className="px-3 py-2 mb-0 d-flex align-items-center" htmlFor="flexCheckDefault">
|
|
|
<input
|
|
<input
|
|
|
className="mr-2"
|
|
className="mr-2"
|
|
|
type="checkbox"
|
|
type="checkbox"
|
|
|
id="flexCheckDefault"
|
|
id="flexCheckDefault"
|
|
|
- onClick={() => onExcludeUsersHome()}
|
|
|
|
|
|
|
+ onClick={switchExcludeUserPagesHandler}
|
|
|
/>
|
|
/>
|
|
|
{t('Include Subordinated Target Page', { target: '/user' })}
|
|
{t('Include Subordinated Target Page', { target: '/user' })}
|
|
|
</label>
|
|
</label>
|
|
@@ -89,13 +132,14 @@ const SearchControl: FC <Props> = (props: Props) => {
|
|
|
className="mr-2"
|
|
className="mr-2"
|
|
|
type="checkbox"
|
|
type="checkbox"
|
|
|
id="flexCheckChecked"
|
|
id="flexCheckChecked"
|
|
|
- onClick={() => onExcludeTrash()}
|
|
|
|
|
|
|
+ onClick={switchExcludeTrashPagesHandler}
|
|
|
/>
|
|
/>
|
|
|
{t('Include Subordinated Target Page', { target: '/trash' })}
|
|
{t('Include Subordinated Target Page', { target: '/trash' })}
|
|
|
</label>
|
|
</label>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+ {rednerSearchOptionModal()}
|
|
|
</>
|
|
</>
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|