[ARVADOS-WORKBENCH2] created: 1.2.0-747-gd76d0db
Git user
git at public.curoverse.com
Mon Oct 29 08:03:17 EDT 2018
at d76d0dbba0c7fdcb29303bbc2d4eca27d1a0984b (commit)
commit d76d0dbba0c7fdcb29303bbc2d4eca27d1a0984b
Author: Janicki Artur <artur.janicki at contractors.roche.com>
Date: Mon Oct 29 13:03:04 2018 +0100
add filter by create_at for advance search bar
Feature #14276_structured_search_service
Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki at contractors.roche.com>
diff --git a/src/services/api/filter-builder.ts b/src/services/api/filter-builder.ts
index 06a040e..e36765b 100644
--- a/src/services/api/filter-builder.ts
+++ b/src/services/api/filter-builder.ts
@@ -31,6 +31,22 @@ export class FilterBuilder {
return this.addCondition(field, "in", value, "", "", resourcePrefix);
}
+ public addGt(field: string, value?: string, resourcePrefix?: string) {
+ return this.addCondition(field, ">", value, "", "", resourcePrefix);
+ }
+
+ public addGte(field: string, value?: string, resourcePrefix?: string) {
+ return this.addCondition(field, ">=", value, "", "", resourcePrefix);
+ }
+
+ public addLt(field: string, value?: string, resourcePrefix?: string) {
+ return this.addCondition(field, "<", value, "", "", resourcePrefix);
+ }
+
+ public addLte(field: string, value?: string, resourcePrefix?: string) {
+ return this.addCondition(field, "<=", value, "", "", resourcePrefix);
+ }
+
public getFilters() {
return this.filters;
}
diff --git a/src/store/search-bar/search-bar-actions.ts b/src/store/search-bar/search-bar-actions.ts
index 653a8f5..d6203d2 100644
--- a/src/store/search-bar/search-bar-actions.ts
+++ b/src/store/search-bar/search-bar-actions.ts
@@ -55,7 +55,7 @@ export const searchData = (searchValue: string) =>
const currentView = getState().searchBar.currentView;
dispatch(searchBarActions.SET_SEARCH_VALUE(searchValue));
dispatch(searchBarActions.SET_SEARCH_RESULTS([]));
- dispatch<any>(searchGroups(searchValue));
+ dispatch<any>(searchGroups(searchValue, 5, {}));
if (currentView === SearchView.BASIC) {
dispatch(searchBarActions.CLOSE_SEARCH_VIEW());
dispatch(navigateToSearchResults);
@@ -67,7 +67,7 @@ export const searchAdvanceData = (data: SearchBarAdvanceFormData) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
const searchValue = getState().searchBar.searchValue;
dispatch<any>(saveQuery(data));
- dispatch<any>(searchGroups(searchValue, 100, data.type));
+ dispatch<any>(searchGroups(searchValue, 100, data));
dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.BASIC));
dispatch(searchBarActions.CLOSE_SEARCH_VIEW());
dispatch(navigateToSearchResults);
@@ -122,7 +122,7 @@ export const closeSearchView = () =>
}
};
-export const closeAdvanceView = () =>
+export const closeAdvanceView = () =>
(dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
dispatch(searchBarActions.SET_SEARCH_VALUE(''));
dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.BASIC));
@@ -134,7 +134,7 @@ export const navigateToItem = (uuid: string) =>
dispatch(navigateTo(uuid));
};
-export const changeData = (searchValue: string) =>
+export const changeData = (searchValue: string) =>
(dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
dispatch(searchBarActions.SET_SEARCH_VALUE(searchValue));
const currentView = getState().searchBar.currentView;
@@ -166,24 +166,24 @@ const searchDataOnEnter = (searchValue: string) =>
dispatch(searchBarActions.CLOSE_SEARCH_VIEW());
dispatch(searchBarActions.SET_SEARCH_VALUE(searchValue));
dispatch(searchBarActions.SET_SEARCH_RESULTS([]));
- dispatch<any>(searchGroups(searchValue, 100));
+ dispatch<any>(searchGroups(searchValue, 100, {}));
dispatch(navigateToSearchResults);
};
const debounceStartSearch = debounce((dispatch: Dispatch) => dispatch<any>(startSearch()), DEFAULT_SEARCH_DEBOUNCE);
-const startSearch = () =>
+const startSearch = () =>
(dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
const searchValue = getState().searchBar.searchValue;
dispatch<any>(searchData(searchValue));
};
-const searchGroups = (searchValue: string, limit = 5, resourceKind?: ResourceKind) =>
+const searchGroups = (searchValue: string, limit: number, {...props}) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
const currentView = getState().searchBar.currentView;
-
+
if (searchValue || currentView === SearchView.ADVANCED) {
- const filters = getFilters('name', searchValue, resourceKind);
+ const filters = getFilters('name', searchValue, props);
const { items } = await services.groupsService.contents('', {
filters,
limit,
@@ -193,12 +193,15 @@ const searchGroups = (searchValue: string, limit = 5, resourceKind?: ResourceKin
}
};
-export const getFilters = (filterName: string, searchValue: string, resourceKind?: ResourceKind): string => {
+export const getFilters = (filterName: string, searchValue: string, {...props}): string => {
+ const { resourceKind, dateTo, dateFrom } = props;
return new FilterBuilder()
.addIsA("uuid", buildUuidFilter(resourceKind))
.addILike(filterName, searchValue, GroupContentsResourcePrefix.COLLECTION)
.addILike(filterName, searchValue, GroupContentsResourcePrefix.PROCESS)
.addILike(filterName, searchValue, GroupContentsResourcePrefix.PROJECT)
+ .addLte('created_at', buildDateFilter(dateTo))
+ .addGte('created_at', buildDateFilter(dateFrom))
.addEqual('groupClass', GroupClass.PROJECT, GroupContentsResourcePrefix.PROJECT)
.getFilters();
};
@@ -207,6 +210,10 @@ const buildUuidFilter = (type?: ResourceKind): ResourceKind[] => {
return type ? [type] : [ResourceKind.PROJECT, ResourceKind.COLLECTION, ResourceKind.PROCESS];
};
+const buildDateFilter = (date?: string): string => {
+ return date ? date : '';
+};
+
export const initAdvanceFormProjectsTree = () =>
(dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
dispatch<any>(initUserProject(SEARCH_BAR_ADVANCE_FORM_PICKER_ID));
diff --git a/src/store/search-results-panel/search-results-middleware-service.ts b/src/store/search-results-panel/search-results-middleware-service.ts
index 5ccb61b..0b38444 100644
--- a/src/store/search-results-panel/search-results-middleware-service.ts
+++ b/src/store/search-results-panel/search-results-middleware-service.ts
@@ -39,7 +39,7 @@ export class SearchResultsMiddlewareService extends DataExplorerMiddlewareServic
export const getParams = (dataExplorer: DataExplorer, searchValue: string) => ({
...dataExplorerToListParams(dataExplorer),
- filters: getFilters('name', searchValue),
+ filters: getFilters('name', searchValue, {}),
order: getOrder(dataExplorer)
});
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list