Clear cards setting option

This commit is contained in:
Jason Wall 2024-03-08 08:46:55 -05:00
parent d406a1554b
commit 6f1cd2c68a
5 changed files with 33 additions and 0 deletions

View File

@ -18,6 +18,10 @@
<mat-icon matListIcon color="accenovert">note_add</mat-icon> <mat-icon matListIcon color="accenovert">note_add</mat-icon>
Create a New Note Create a New Note
</a> </a>
<a mat-list-item (click)="clearCurrentCard()">
<mat-icon matListIcon color="accenovert">clear_all</mat-icon>
Clear Cards
</a>
</mat-nav-list> </mat-nav-list>
<mat-toolbar>Search Settings</mat-toolbar> <mat-toolbar>Search Settings</mat-toolbar>

View File

@ -134,6 +134,11 @@ export class SettingsComponent extends SubscriberBase {
}); });
} }
clearCurrentCard(){
this.appService.clearCards();
this.navService.closeSettings();
}
//#endregion //#endregion
//#region Saved Page Settings //#region Saved Page Settings

View File

@ -96,6 +96,12 @@ export class AppActionFactory {
} as AppAction; } as AppAction;
} }
static newClearCards(): AppAction {
return {
type: 'CLEAR_CARDS',
} as AppAction;
}
static newUpdateError(error: Error): AppAction { static newUpdateError(error: Error): AppAction {
return { return {
type: 'UPDATE_ERROR', type: 'UPDATE_ERROR',
@ -227,6 +233,9 @@ export type AppAction =
type: 'REMOVE_CARD'; type: 'REMOVE_CARD';
card: CardItem; card: CardItem;
} }
| {
type: 'CLEAR_CARDS';
}
| { | {
type: 'MOVE_CARD'; type: 'MOVE_CARD';
card: CardItem; card: CardItem;

View File

@ -311,6 +311,15 @@ export function reducer(state: AppState, action: AppAction): AppState {
}; };
} }
case 'CLEAR_CARDS': {
// potentially remove card from a saved page.
return {
...state,
currentCards: new Storable([]),
};
}
case 'MOVE_CARD': { case 'MOVE_CARD': {
const cards = moveItemUpOrDown(state.currentCards.value, action.card, action.direction); const cards = moveItemUpOrDown(state.currentCards.value, action.card, action.direction);

View File

@ -170,6 +170,12 @@ export class AppService extends createStateService(reducer, initialState) {
); );
} }
async clearCards() {
this.dispatch(
AppActionFactory.newClearCards()
);
}
private async getCardByQuery(qry: string, type?: CardType): Promise<CardItem> { private async getCardByQuery(qry: string, type?: CardType): Promise<CardItem> {
if (qry.startsWith('note:')) { if (qry.startsWith('note:')) {
const q = qry.toLocaleLowerCase().trim().replace('note:', ''); const q = qry.toLocaleLowerCase().trim().replace('note:', '');