From 7eed338e122d5c5f16988acae10d304de15761bf Mon Sep 17 00:00:00 2001 From: Michal Klobukowski Date: Mon, 30 Jul 2018 16:52:56 +0200 Subject: [PATCH] Implement 'select/unselect all' actions Feature #13855 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- .../collection-panel-files-actions.ts | 4 +++- .../collections-panel-files-reducer.ts | 2 ++ .../action-sets/collection-files-action-set.ts | 9 +++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts b/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts index 6997f088e2..caaa4268c5 100644 --- a/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts +++ b/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts @@ -8,7 +8,9 @@ import { CollectionPanelFilesState, CollectionPanelFile } from "./collection-pan export const collectionPanelFilesAction = unionize({ SET_COLLECTION_FILES: ofType<{ files: CollectionPanelFilesState }>(), TOGGLE_COLLECTION_FILE_COLLAPSE: ofType<{ id: string }>(), - TOGGLE_COLLECTION_FILE_SELECTION: ofType<{ id: string }>() + TOGGLE_COLLECTION_FILE_SELECTION: ofType<{ id: string }>(), + SELECT_ALL_COLLECTION_FILES: ofType<{}>(), + UNSELECT_ALL_COLLECTION_FILES: ofType<{}>(), }, { tag: 'type', value: 'payload' }); export type CollectionPanelFilesAction = UnionOf; \ No newline at end of file diff --git a/src/store/collection-panel/collection-panel-files/collections-panel-files-reducer.ts b/src/store/collection-panel/collection-panel-files/collections-panel-files-reducer.ts index 1e62bad6e2..408779cfc6 100644 --- a/src/store/collection-panel/collection-panel-files/collections-panel-files-reducer.ts +++ b/src/store/collection-panel/collection-panel-files/collections-panel-files-reducer.ts @@ -60,6 +60,8 @@ export const collectionPanelFilesReducer = (state: CollectionPanelFilesState = i SET_COLLECTION_FILES: data => data.files, TOGGLE_COLLECTION_FILE_COLLAPSE: data => toggleCollapsed(state, data.id), TOGGLE_COLLECTION_FILE_SELECTION: data => toggleSelected(state, data.id), + SELECT_ALL_COLLECTION_FILES: () => state.map(file => ({...file, selected: true})), + UNSELECT_ALL_COLLECTION_FILES: () => state.map(file => ({...file, selected: false})), default: () => state }); }; diff --git a/src/views-components/context-menu/action-sets/collection-files-action-set.ts b/src/views-components/context-menu/action-sets/collection-files-action-set.ts index 1e183d53c0..dc17e693e3 100644 --- a/src/views-components/context-menu/action-sets/collection-files-action-set.ts +++ b/src/views-components/context-menu/action-sets/collection-files-action-set.ts @@ -3,17 +3,18 @@ // SPDX-License-Identifier: AGPL-3.0 import { ContextMenuActionSet } from "../context-menu-action-set"; +import { collectionPanelFilesAction } from "../../../store/collection-panel/collection-panel-files/collection-panel-files-actions"; export const collectionFilesActionSet: ContextMenuActionSet = [[{ name: "Select all", - execute: (dispatch, resource) => { - return; + execute: (dispatch) => { + dispatch(collectionPanelFilesAction.SELECT_ALL_COLLECTION_FILES()); } },{ name: "Unselect all", - execute: (dispatch, resource) => { - return; + execute: (dispatch) => { + dispatch(collectionPanelFilesAction.UNSELECT_ALL_COLLECTION_FILES()); } },{ name: "Remove selected", -- 2.30.2