[ARVADOS-WORKBENCH2] updated: 1.2.0-952-g56ee0a4

Git user git at public.curoverse.com
Tue Nov 27 03:37:26 EST 2018


Summary of changes:
 src/store/search-bar/search-bar-actions.ts         | 30 +++++++++++++++-------
 src/store/search-bar/search-bar-reducer.ts         |  3 +--
 .../search-bar/search-bar-view.tsx                 | 30 ++++++++++++++++++++--
 src/views-components/search-bar/search-bar.tsx     |  5 ++--
 4 files changed, 53 insertions(+), 15 deletions(-)

       via  56ee0a472ab8c77df51f6bb19d616d5f81ffde96 (commit)
      from  89c3c647797787377f4d950b38d320ee3b28e92c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 56ee0a472ab8c77df51f6bb19d616d5f81ffde96
Author: Daniel Kos <daniel.kos at contractors.roche.com>
Date:   Tue Nov 27 09:37:19 2018 +0100

    Fix various search issues
    
    Feature #14280
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos at contractors.roche.com>

diff --git a/src/store/search-bar/search-bar-actions.ts b/src/store/search-bar/search-bar-actions.ts
index 2ad9b28..2bac245 100644
--- a/src/store/search-bar/search-bar-actions.ts
+++ b/src/store/search-bar/search-bar-actions.ts
@@ -80,13 +80,20 @@ export const searchAdvanceData = (data: SearchBarAdvanceFormData) =>
 
 export const setSearchValueFromAdvancedData = (data: SearchBarAdvanceFormData, prevData?: SearchBarAdvanceFormData) =>
     (dispatch: Dispatch, getState: () => RootState) => {
+        const searchValue = getState().searchBar.searchValue;
         const value = getQueryFromAdvancedData({
-            searchValue: getState().searchBar.searchValue,
-            ...data
+            ...data,
+            searchValue
         }, prevData);
         dispatch(searchBarActions.SET_SEARCH_VALUE(value));
     };
 
+export const setAdvancedDataFromSearchValue = (search: string) =>
+    (dispatch: Dispatch) => {
+        const data = getAdvancedDataFromQuery(search);
+        dispatch<any>(initialize(SEARCH_BAR_ADVANCE_FORM_NAME, data));
+    };
+
 const saveQuery = (data: SearchBarAdvanceFormData) =>
     (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
         const savedQueries = services.searchService.getSavedQueries();
@@ -155,7 +162,7 @@ export const changeData = (searchValue: string) =>
         const searchValuePresent = searchValue.length > 0;
 
         if (currentView === SearchView.ADVANCED) {
-
+            dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.AUTOCOMPLETE));
         } else if (searchValuePresent) {
             dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.AUTOCOMPLETE));
             dispatch(searchBarActions.SET_SELECTED_ITEM(searchValue));
@@ -205,8 +212,19 @@ const searchGroups = (searchValue: string, limit: number) =>
 const buildQueryFromKeyMap = (data: any, keyMap: string[][], mode: 'rebuild' | 'reuse') => {
     let value = data.searchValue;
 
+    const rem = (field: string, fieldValue: any, value: string) => {
+    };
+
     const addRem = (field: string, key: string) => {
         const v = data[key];
+
+        if (data.hasOwnProperty(key)) {
+            const pattern = v === false
+                ? `${field.replace(':', '\\:\\s*')}\\s*`
+                : `${field.replace(':', '\\:\\s*')}\\:\\s*[\\w|\\#|\\-|\\/]*\\s*`;
+            value = value.replace(new RegExp(pattern), '');
+        }
+
         if (v) {
             const nv = v === true
                 ? `${field}`
@@ -217,11 +235,6 @@ const buildQueryFromKeyMap = (data: any, keyMap: string[][], mode: 'rebuild' | '
             } else {
                 value = nv + ' ' + value;
             }
-        } else if (data.hasOwnProperty(key) && (v === undefined || v === false)) {
-            const pattern = v === false
-                ? `${field.replace(':', '\\:\\s*')}\\s*`
-                : `${field.replace(':', '\\:\\s*')}\\:\\s*[\\w|\\#|\\-|\\/]*`;
-            value = value.replace(new RegExp(pattern), '');
         }
     };
 
@@ -260,7 +273,6 @@ export const getQueryFromAdvancedData = (data: SearchBarAdvanceFormData, prevDat
 
     if (prevData) {
         const obj = getModifiedKeysValues(flatData(data), flatData(prevData));
-        console.log(obj);
         value = buildQueryFromKeyMap({
             searchValue: data.searchValue,
             ...obj
diff --git a/src/store/search-bar/search-bar-reducer.ts b/src/store/search-bar/search-bar-reducer.ts
index 46477c1..4f663ee 100644
--- a/src/store/search-bar/search-bar-reducer.ts
+++ b/src/store/search-bar/search-bar-reducer.ts
@@ -5,8 +5,7 @@
 import {
     getQueryFromAdvancedData,
     searchBarActions,
-    SearchBarActions,
-    setSearchValueFromAdvancedData
+    SearchBarActions
 } from '~/store/search-bar/search-bar-actions';
 import { GroupContentsResource } from '~/services/groups-service/groups-service';
 import { SearchBarAdvanceFormData } from '~/models/search-bar';
diff --git a/src/views-components/search-bar/search-bar-view.tsx b/src/views-components/search-bar/search-bar-view.tsx
index ec1c8b8..beaad49 100644
--- a/src/views-components/search-bar/search-bar-view.tsx
+++ b/src/views-components/search-bar/search-bar-view.tsx
@@ -86,6 +86,7 @@ interface SearchBarViewActionProps {
     loadRecentQueries: () => string[];
     moveUp: () => void;
     moveDown: () => void;
+    setAdvancedDataFromSearchValue: (search: string) => void;
 }
 
 type SearchBarViewProps = SearchBarDataProps & SearchBarActionProps & WithStyles<CssRules>;
@@ -94,6 +95,7 @@ const handleKeyDown = (e: React.KeyboardEvent, props: SearchBarViewProps) => {
     if (e.keyCode === KEY_CODE_DOWN) {
         e.preventDefault();
         if (!props.isPopoverOpen) {
+            props.onSetView(SearchView.AUTOCOMPLETE);
             props.openSearchView();
         } else {
             props.moveDown();
@@ -117,6 +119,30 @@ const handleKeyDown = (e: React.KeyboardEvent, props: SearchBarViewProps) => {
     }
 };
 
+const handleInputClick = (e: React.MouseEvent, props: SearchBarViewProps) => {
+    if (props.searchValue) {
+        props.onSetView(SearchView.AUTOCOMPLETE);
+        props.openSearchView();
+    } else {
+        props.closeView();
+    }
+};
+
+const handleDropdownClick = (e: React.MouseEvent, props: SearchBarViewProps) => {
+    e.stopPropagation();
+    if (props.isPopoverOpen) {
+        if (props.currentView === SearchView.ADVANCED) {
+            props.closeView();
+        } else {
+            props.setAdvancedDataFromSearchValue(props.searchValue);
+            props.onSetView(SearchView.ADVANCED);
+        }
+    } else {
+        props.setAdvancedDataFromSearchValue(props.searchValue);
+        props.onSetView(SearchView.ADVANCED);
+    }
+};
+
 export const SearchBarView = withStyles(styles)(
     (props : SearchBarViewProps) => {
         const { classes, isPopoverOpen } = props;
@@ -131,7 +157,7 @@ export const SearchBarView = withStyles(styles)(
                             value={props.searchValue}
                             fullWidth={true}
                             disableUnderline={true}
-                            onClick={props.openSearchView}
+                            onClick={e => handleInputClick(e, props)}
                             onKeyDown={e => handleKeyDown(e, props)}
                             startAdornment={
                                 <InputAdornment position="start">
@@ -145,7 +171,7 @@ export const SearchBarView = withStyles(styles)(
                             endAdornment={
                                 <InputAdornment position="end">
                                     <Tooltip title='Advanced search'>
-                                        <IconButton onClick={() => props.onSetView(SearchView.ADVANCED)}>
+                                        <IconButton onClick={e => handleDropdownClick(e, props)}>
                                             <ArrowDropDownIcon />
                                         </IconButton>
                                     </Tooltip>
diff --git a/src/views-components/search-bar/search-bar.tsx b/src/views-components/search-bar/search-bar.tsx
index e60b214..3107ad7 100644
--- a/src/views-components/search-bar/search-bar.tsx
+++ b/src/views-components/search-bar/search-bar.tsx
@@ -16,7 +16,7 @@ import {
     navigateToItem,
     editSavedQuery,
     changeData,
-    submitData, moveUp, moveDown
+    submitData, moveUp, moveDown, setAdvancedDataFromSearchValue
 } from '~/store/search-bar/search-bar-actions';
 import { SearchBarView, SearchBarActionProps, SearchBarDataProps } from '~/views-components/search-bar/search-bar-view';
 import { SearchBarAdvanceFormData } from '~/models/search-bar';
@@ -46,7 +46,8 @@ const mapDispatchToProps = (dispatch: Dispatch): SearchBarActionProps => ({
     navigateTo: (uuid: string) => dispatch<any>(navigateToItem(uuid)),
     editSavedQuery: (data: SearchBarAdvanceFormData) => dispatch<any>(editSavedQuery(data)),
     moveUp: () => dispatch<any>(moveUp()),
-    moveDown: () => dispatch<any>(moveDown())
+    moveDown: () => dispatch<any>(moveDown()),
+    setAdvancedDataFromSearchValue: (search: string) => dispatch<any>(setAdvancedDataFromSearchValue(search))
 });
 
 export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView);

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list