mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
Merge global search.
This commit is contained in:
@@ -5,22 +5,25 @@ import DashboardContent from 'components/Dashboard/DashboardContent';
|
|||||||
import DialogsContainer from 'components/DialogsContainer';
|
import DialogsContainer from 'components/DialogsContainer';
|
||||||
import PreferencesContent from 'components/Preferences/PreferencesContent';
|
import PreferencesContent from 'components/Preferences/PreferencesContent';
|
||||||
import PreferencesSidebar from 'components/Preferences/PreferencesSidebar';
|
import PreferencesSidebar from 'components/Preferences/PreferencesSidebar';
|
||||||
|
import Search from 'containers/Dashboard/GeneralSearch/Search';
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
return (
|
return (
|
||||||
<div className="dashboard">
|
<div className='dashboard'>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/dashboard/preferences">
|
<Route path='/dashboard/preferences'>
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
<PreferencesSidebar />
|
<PreferencesSidebar />
|
||||||
<PreferencesContent />
|
<PreferencesContent />
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
<Route path="/dashboard">
|
<Route path='/dashboard'>
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
<DashboardContent />
|
<DashboardContent />
|
||||||
</Route>
|
</Route>
|
||||||
</Switch>
|
</Switch>
|
||||||
|
|
||||||
|
<Search />
|
||||||
<DialogsContainer />
|
<DialogsContainer />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,17 +6,20 @@ import {
|
|||||||
NavbarGroup,
|
NavbarGroup,
|
||||||
Button,
|
Button,
|
||||||
Classes,
|
Classes,
|
||||||
MenuDivider,
|
|
||||||
MenuItem,
|
|
||||||
Menu,
|
|
||||||
Popover,
|
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import DashboardBreadcrumbs from 'components/Dashboard/DashboardBreadcrumbs';
|
import DashboardBreadcrumbs from 'components/Dashboard/DashboardBreadcrumbs';
|
||||||
import DashboardTopbarUser from 'components/Dashboard/TopbarUser';
|
import DashboardTopbarUser from 'components/Dashboard/TopbarUser';
|
||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import Search from 'containers/Dashboard/GeneralSearch/Search';
|
import SearchConnect from 'connectors/Search.connect';
|
||||||
|
import { compose } from 'utils';
|
||||||
|
|
||||||
function DashboardTopbar({ pageTitle, pageSubtitle, editViewId }) {
|
function DashboardTopbar({
|
||||||
|
pageTitle,
|
||||||
|
pageSubtitle,
|
||||||
|
editViewId,
|
||||||
|
globalSearchShow,
|
||||||
|
openGlobalSearch,
|
||||||
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
const handlerClickEditView = () => {
|
const handlerClickEditView = () => {
|
||||||
@@ -70,8 +73,13 @@ function DashboardTopbar({ pageTitle, pageSubtitle, editViewId }) {
|
|||||||
<div class='dashboard__topbar-right'>
|
<div class='dashboard__topbar-right'>
|
||||||
<Navbar class='dashboard__topbar-navbar'>
|
<Navbar class='dashboard__topbar-navbar'>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
{/* <Button className={Classes.MINIMAL} icon="home" text="Search" /> */}
|
<Button
|
||||||
<Search className />
|
onClick={() => openGlobalSearch(true)}
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon='home'
|
||||||
|
text='Search'
|
||||||
|
/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon='document'
|
icon='document'
|
||||||
@@ -100,4 +108,7 @@ const mapStateToProps = (state) => ({
|
|||||||
editViewId: state.dashboard.topbarEditViewId,
|
editViewId: state.dashboard.topbarEditViewId,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps)(DashboardTopbar);
|
export default compose(
|
||||||
|
SearchConnect,
|
||||||
|
connect(mapStateToProps)
|
||||||
|
)(DashboardTopbar);
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ import t from 'store/types';
|
|||||||
import { generalSearch } from 'store/search/search.actions';
|
import { generalSearch } from 'store/search/search.actions';
|
||||||
|
|
||||||
export const mapStateToProps = (state, props) => ({
|
export const mapStateToProps = (state, props) => ({
|
||||||
resultSearch: state.GeneralSearch,
|
resultSearch: state.globalSearch.searches,
|
||||||
|
globalSearchShow: state.globalSearch.isOpen,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const mapDispatchToProps = (dispatch) => ({
|
export const mapDispatchToProps = (dispatch) => ({
|
||||||
generalSearch: (result) => dispatch(generalSearch(result)),
|
openGlobalSearch: (result) => dispatch({ type: t.OPEN_SEARCH, }),
|
||||||
|
closeGlobalSearch: (result) => dispatch({ type: t.CLOSE_SEARCH }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps);
|
export default connect(mapStateToProps, mapDispatchToProps);
|
||||||
|
|||||||
@@ -1,71 +1,41 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Omnibar } from '@blueprintjs/select';
|
import { Omnibar } from '@blueprintjs/select';
|
||||||
import { MenuItem, Button, Classes } from '@blueprintjs/core';
|
import { MenuItem } from '@blueprintjs/core';
|
||||||
import { useAsync } from 'react-use';
|
|
||||||
import * as Yup from 'yup';
|
|
||||||
import { useFormik } from 'formik';
|
|
||||||
import Icon from 'components/Icon';
|
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
import SearchConnect from 'connectors/Search.connect';
|
import SearchConnect from 'connectors/Search.connect';
|
||||||
|
|
||||||
function Search({}) {
|
function Search({
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
resultSearch,
|
||||||
|
globalSearchShow,
|
||||||
|
openGlobalSearch,
|
||||||
|
closeGlobalSearch,
|
||||||
|
}) {
|
||||||
const items = [
|
const items = [
|
||||||
{ title: 'The Shawshank Redemption', year: 1994 },
|
{ title: 'The Shawshank Redemption', year: 1994 },
|
||||||
{ title: 'The Godfather', year: 1972 },
|
{ title: 'The Godfather', year: 1972 },
|
||||||
{ title: 'The Godfather: Part II', year: 1974 },
|
{ title: 'The Godfather: Part II', year: 1974 },
|
||||||
];
|
];
|
||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
const renderSearch = (search, { handleClick }) => (
|
||||||
name: Yup.string().required(),
|
|
||||||
});
|
|
||||||
const formik = useFormik({
|
|
||||||
enableReinitialize: true,
|
|
||||||
validationSchema: validationSchema,
|
|
||||||
initialValues: {},
|
|
||||||
});
|
|
||||||
const renderSearch = (search, { handleClick, modifiers }) => (
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
active={modifiers.active}
|
key={search.year}
|
||||||
key={search.id}
|
text={search.title}
|
||||||
text={search.name}
|
label={search.title}
|
||||||
label={search.name}
|
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
const filterSearch = (query, search, _index, exactMatch) => {
|
|
||||||
// const normalizedTitle = search.toLowerCase();
|
|
||||||
// const normalizedQuery = query.toLowerCase();
|
|
||||||
// if (exactMatch) {
|
|
||||||
// return normalizedTitle === normalizedQuery;
|
|
||||||
// } else {
|
|
||||||
// return `${search} ${normalizedTitle}`.indexOf(normalizedQuery) >= 0;
|
|
||||||
// }
|
|
||||||
return search;
|
|
||||||
};
|
|
||||||
const handleClick = () => setIsOpen(true);
|
|
||||||
const handleClose = () => setIsOpen(false);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Button
|
|
||||||
className={Classes.MINIMAL}
|
|
||||||
icon='home'
|
|
||||||
text='Search'
|
|
||||||
onClick={handleClick}
|
|
||||||
/>
|
|
||||||
<Omnibar
|
<Omnibar
|
||||||
isOpen={isOpen}
|
className={'navbar-omnibar'}
|
||||||
|
isOpen={globalSearchShow}
|
||||||
noResults={<MenuItem disabled={true} text='No results.' />}
|
noResults={<MenuItem disabled={true} text='No results.' />}
|
||||||
onClose={handleClose}
|
onClose={() => closeGlobalSearch(false)}
|
||||||
resetOnSelect={true}
|
resetOnSelect={true}
|
||||||
itemRenderer={renderSearch}
|
itemRenderer={renderSearch}
|
||||||
items={items}
|
items={items}
|
||||||
// onItemSelect={}
|
// onItemSelect={onItemsSelect()}
|
||||||
itemListPredicate={filterSearch}
|
|
||||||
// style={{ position: 'absolute', canter: '50%' }}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import financialStatements from './financialStatement/financialStatements.reduce
|
|||||||
import itemCategories from './itemCategories/itemsCategory.reducer';
|
import itemCategories from './itemCategories/itemsCategory.reducer';
|
||||||
import settings from './settings/settings.reducer';
|
import settings from './settings/settings.reducer';
|
||||||
import manualJournals from './manualJournals/manualJournals.reducers';
|
import manualJournals from './manualJournals/manualJournals.reducers';
|
||||||
import search from './search/search.reducer';
|
import globalSearch from './search/search.reducer';
|
||||||
|
|
||||||
export default combineReducers({
|
export default combineReducers({
|
||||||
authentication,
|
authentication,
|
||||||
@@ -31,5 +31,5 @@ export default combineReducers({
|
|||||||
items,
|
items,
|
||||||
itemCategories,
|
itemCategories,
|
||||||
settings,
|
settings,
|
||||||
search,
|
globalSearch,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
import t from 'store/types';
|
import t from 'store/types';
|
||||||
|
|
||||||
|
export function openSearch(result) {
|
||||||
|
return {
|
||||||
|
type: t.OPEN_SEARCH,
|
||||||
|
result,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function closeSearch(result) {
|
||||||
|
return {
|
||||||
|
type: t.ClOSE_SEARCH,
|
||||||
|
result,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function generalSearch(name, result) {
|
export function generalSearch(name, result) {
|
||||||
return {
|
return {
|
||||||
type: t.SEARCH_SUCCESS,
|
type: t.SEARCH_SUCCESS,
|
||||||
|
|||||||
@@ -8,26 +8,11 @@ const initialState = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default createReducer(initialState, {
|
export default createReducer(initialState, {
|
||||||
[t.SEARCH_SUCCESS]: (state, action) => {
|
[t.OPEN_SEARCH]: (state, action) => {
|
||||||
const _result = {};
|
state.isOpen = true;
|
||||||
|
|
||||||
action.searches.forEach((search) => {
|
|
||||||
_result[search.id] = search;
|
|
||||||
});
|
|
||||||
|
|
||||||
state.searches = {
|
|
||||||
...state.searches,
|
|
||||||
..._result,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
[t.CLOSE_SEARCH]: (state, action) => {
|
||||||
|
state.isOpen = false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// return state = action.result;
|
|
||||||
// if (typeof state === 'undefined') {
|
|
||||||
// return initialState;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// state.search[action.name] = {
|
|
||||||
// isOpen: true,
|
|
||||||
// payload: action.payload || {},
|
|
||||||
// };
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export default {
|
export default {
|
||||||
SEARCH_SUCCESS:'SEARCH_SUCCESS',
|
SEARCH_SUCCESS:'SEARCH_SUCCESS',
|
||||||
SEARCH_FAILURE: 'SEARCH_FAILURE',
|
OPEN_SEARCH: 'OPEN_SEARCH',
|
||||||
SEARCH_REQUEST: 'SEARCH_REQUEST',
|
CLOSE_SEARCH: 'CLOSE_SEARCH',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import financialStatements from './financialStatement/financialStatements.types'
|
|||||||
import itemCategories from './itemCategories/itemsCategory.type';
|
import itemCategories from './itemCategories/itemsCategory.type';
|
||||||
import settings from './settings/settings.type';
|
import settings from './settings/settings.type';
|
||||||
import search from './search/search.type';
|
import search from './search/search.type';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
...authentication,
|
...authentication,
|
||||||
...accounts,
|
...accounts,
|
||||||
|
|||||||
@@ -274,3 +274,19 @@
|
|||||||
box-shadow: 0 0 0;
|
box-shadow: 0 0 0;
|
||||||
border-bottom: 1px solid #EAEAEA;
|
border-bottom: 1px solid #EAEAEA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.navbar-omnibar{
|
||||||
|
-webkit-filter: blur(0);
|
||||||
|
filter: blur(0);
|
||||||
|
opacity: 1;
|
||||||
|
top: 20vh;
|
||||||
|
left: calc(50% - 250px);
|
||||||
|
z-index: 21;
|
||||||
|
border-radius: 3px;
|
||||||
|
-webkit-box-shadow: 0 0 0 1px rgba(16, 22, 26, 0.1),
|
||||||
|
0 4px 8px rgba(16, 22, 26, 0.2), 0 18px 46px 6px rgba(16, 22, 26, 0.2);
|
||||||
|
box-shadow: 0 0 0 1px rgba(16, 22, 26, 0.1), 0 4px 8px rgba(16, 22, 26, 0.2),
|
||||||
|
0 18px 46px 6px rgba(16, 22, 26, 0.2);
|
||||||
|
background-color: #fff;
|
||||||
|
width: 500px;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user