Board assignment changing on click

This commit is contained in:
Kevin Brack 2023-07-30 13:05:29 -05:00 committed by psychedelicious
parent 0d125bf3e4
commit 0ba8a0ea6c
3 changed files with 23 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import IAIPopover from 'common/components/IAIPopover';
import IAISimpleCheckbox from 'common/components/IAISimpleCheckbox'; import IAISimpleCheckbox from 'common/components/IAISimpleCheckbox';
import IAISlider from 'common/components/IAISlider'; import IAISlider from 'common/components/IAISlider';
import { import {
autoAssignBoardOnClickChanged,
setGalleryImageMinimumWidth, setGalleryImageMinimumWidth,
shouldAutoSwitchChanged, shouldAutoSwitchChanged,
} from 'features/gallery/store/gallerySlice'; } from 'features/gallery/store/gallerySlice';
@ -19,11 +20,16 @@ import BoardAutoAddSelect from './Boards/BoardAutoAddSelect';
const selector = createSelector( const selector = createSelector(
[stateSelector], [stateSelector],
(state) => { (state) => {
const { galleryImageMinimumWidth, shouldAutoSwitch } = state.gallery; const {
galleryImageMinimumWidth,
shouldAutoSwitch,
autoAssignBoardOnClick,
} = state.gallery;
return { return {
galleryImageMinimumWidth, galleryImageMinimumWidth,
shouldAutoSwitch, shouldAutoSwitch,
autoAssignBoardOnClick,
}; };
}, },
defaultSelectorOptions defaultSelectorOptions
@ -33,7 +39,7 @@ const GallerySettingsPopover = () => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const { t } = useTranslation(); const { t } = useTranslation();
const { galleryImageMinimumWidth, shouldAutoSwitch } = const { galleryImageMinimumWidth, shouldAutoSwitch, autoAssignBoardOnClick } =
useAppSelector(selector); useAppSelector(selector);
const handleChangeGalleryImageMinimumWidth = (v: number) => { const handleChangeGalleryImageMinimumWidth = (v: number) => {
@ -69,7 +75,14 @@ const GallerySettingsPopover = () => {
dispatch(shouldAutoSwitchChanged(e.target.checked)) dispatch(shouldAutoSwitchChanged(e.target.checked))
} }
/> />
<BoardAutoAddSelect /> <IAISimpleCheckbox
label={t('gallery.autoAssignBoardOnClick')}
isChecked={autoAssignBoardOnClick}
onChange={(e: ChangeEvent<HTMLInputElement>) =>
dispatch(autoAssignBoardOnClickChanged(e.target.checked))
}
/>
{!autoAssignBoardOnClick && <BoardAutoAddSelect />}
</Flex> </Flex>
</IAIPopover> </IAIPopover>
); );

View File

@ -8,6 +8,7 @@ export const initialGalleryState: GalleryState = {
selection: [], selection: [],
shouldAutoSwitch: true, shouldAutoSwitch: true,
autoAddBoardId: undefined, autoAddBoardId: undefined,
autoAssignBoardOnClick: true,
galleryImageMinimumWidth: 96, galleryImageMinimumWidth: 96,
selectedBoardId: undefined, selectedBoardId: undefined,
galleryView: 'images', galleryView: 'images',
@ -66,9 +67,13 @@ export const gallerySlice = createSlice({
setGalleryImageMinimumWidth: (state, action: PayloadAction<number>) => { setGalleryImageMinimumWidth: (state, action: PayloadAction<number>) => {
state.galleryImageMinimumWidth = action.payload; state.galleryImageMinimumWidth = action.payload;
}, },
autoAssignBoardOnClickChanged: (state, action: PayloadAction<boolean>) => {
state.autoAssignBoardOnClick = action.payload;
},
boardIdSelected: (state, action: PayloadAction<BoardId>) => { boardIdSelected: (state, action: PayloadAction<BoardId>) => {
state.selectedBoardId = action.payload; state.selectedBoardId = action.payload;
state.galleryView = 'images'; state.galleryView = 'images';
state.autoAssignBoardOnClick && (state.autoAddBoardId = action.payload);
}, },
isBatchEnabledChanged: (state, action: PayloadAction<boolean>) => { isBatchEnabledChanged: (state, action: PayloadAction<boolean>) => {
state.isBatchEnabled = action.payload; state.isBatchEnabled = action.payload;
@ -140,6 +145,7 @@ export const {
imageSelectionToggled, imageSelectionToggled,
imageSelected, imageSelected,
shouldAutoSwitchChanged, shouldAutoSwitchChanged,
autoAssignBoardOnClickChanged,
setGalleryImageMinimumWidth, setGalleryImageMinimumWidth,
boardIdSelected, boardIdSelected,
isBatchEnabledChanged, isBatchEnabledChanged,

View File

@ -18,6 +18,7 @@ export type GalleryState = {
selection: string[]; selection: string[];
shouldAutoSwitch: boolean; shouldAutoSwitch: boolean;
autoAddBoardId: string | undefined; autoAddBoardId: string | undefined;
autoAssignBoardOnClick: boolean;
galleryImageMinimumWidth: number; galleryImageMinimumWidth: number;
selectedBoardId: BoardId; selectedBoardId: BoardId;
galleryView: GalleryView; galleryView: GalleryView;