mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-23 15:30:14 -04:00
rename the list direction type
This commit is contained in:
parent
2c986fb3df
commit
b5f69fe088
@ -1,4 +0,0 @@
|
||||
export enum ListDirection {
|
||||
Up,
|
||||
Down,
|
||||
}
|
4
app/db/src/app/common/move-direction.ts
Normal file
4
app/db/src/app/common/move-direction.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export enum MoveDirection {
|
||||
Up,
|
||||
Down,
|
||||
}
|
@ -3,7 +3,7 @@ import { Observable } from 'rxjs';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { SubscriberBase } from '../common/subscriber-base';
|
||||
import { AppService } from 'src/app/services/app.service';
|
||||
import { ListDirection } from '../common/list-direction';
|
||||
import { MoveDirection } from '../common/move-direction';
|
||||
import { AddToPageModalComponent } from '../components/add-to-page-modal/add-to-page-modal.component';
|
||||
import { CardItem } from '../models/card-state';
|
||||
|
||||
@ -64,10 +64,10 @@ export class CardComponent extends SubscriberBase {
|
||||
}
|
||||
|
||||
moveCardDown() {
|
||||
this.appService.moveCard(this.cardItem, ListDirection.Down);
|
||||
this.appService.moveCard(this.cardItem, MoveDirection.Down);
|
||||
}
|
||||
|
||||
moveCardUp() {
|
||||
this.appService.moveCard(this.cardItem, ListDirection.Up);
|
||||
this.appService.moveCard(this.cardItem, MoveDirection.Up);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Error, DisplaySettings, User } from '../models/app-state';
|
||||
import { IStorable } from '../common/storable';
|
||||
import { NoteItem } from '../models/note-state';
|
||||
import { ListDirection } from '../common/list-direction';
|
||||
import { MoveDirection } from '../common/move-direction';
|
||||
import { SavedPage } from '../models/page-state';
|
||||
import { CardItem } from '../models/card-state';
|
||||
|
||||
@ -64,7 +64,7 @@ export class AppActionFactory {
|
||||
} as AppAction;
|
||||
}
|
||||
|
||||
static newMoveCard(card: CardItem, direction: ListDirection) {
|
||||
static newMoveCard(card: CardItem, direction: MoveDirection) {
|
||||
return {
|
||||
type: 'MOVE_CARD',
|
||||
card,
|
||||
@ -189,7 +189,7 @@ export type AppAction =
|
||||
| {
|
||||
type: 'MOVE_CARD';
|
||||
card: CardItem;
|
||||
direction: ListDirection;
|
||||
direction: MoveDirection;
|
||||
}
|
||||
| {
|
||||
type: 'UPDATE_ERROR';
|
||||
|
@ -4,7 +4,7 @@ import { AppState, DisplaySettings } from '../models/app-state';
|
||||
import { IStorable, Storable } from '../common/storable';
|
||||
import { NoteItem } from '../models/note-state';
|
||||
|
||||
import { ListDirection } from '../common/list-direction';
|
||||
import { MoveDirection } from '../common/move-direction';
|
||||
|
||||
import { AppAction } from './app-state-actions';
|
||||
import { initialState } from './app-state-initial-state';
|
||||
@ -200,8 +200,8 @@ export function reducer(state: AppState, action: AppAction): AppState {
|
||||
const idx = state.cards.indexOf(action.card);
|
||||
|
||||
if (
|
||||
(idx === 0 && action.direction === ListDirection.Up) || // can't go up if you're at the top
|
||||
(idx === state.cards.length - 1 && action.direction === ListDirection.Down) // can't go down if you're at the bottom
|
||||
(idx === 0 && action.direction === MoveDirection.Up) || // can't go up if you're at the top
|
||||
(idx === state.cards.length - 1 && action.direction === MoveDirection.Down) // can't go down if you're at the bottom
|
||||
) {
|
||||
// you can't go up.
|
||||
return state;
|
||||
@ -210,7 +210,7 @@ export function reducer(state: AppState, action: AppAction): AppState {
|
||||
const before = state.cards.slice(0, idx);
|
||||
const after = state.cards.slice(idx + 1);
|
||||
|
||||
if (action.direction === ListDirection.Down) {
|
||||
if (action.direction === MoveDirection.Down) {
|
||||
cards = [...before, after[0], action.card, ...after.slice(1)];
|
||||
} else {
|
||||
cards = [...before.slice(0, before.length - 1), action.card, before[before.length - 1], ...after];
|
||||
|
@ -17,7 +17,7 @@ import {
|
||||
} from '../models/strongs-state';
|
||||
import { WordToStem, IndexResult, WordLookupResult } from '../models/words-state';
|
||||
import { HashTable } from '../common/hashtable';
|
||||
import { ListDirection } from '../common/list-direction';
|
||||
import { MoveDirection } from '../common/move-direction';
|
||||
import { reducer } from './app-state-reducer';
|
||||
import { initialState } from './app-state-initial-state';
|
||||
import { CardItem, CardType } from '../models/card-state';
|
||||
@ -48,7 +48,7 @@ export class AppService extends createStateService(reducer, initialState) {
|
||||
card,
|
||||
});
|
||||
}
|
||||
moveCard(card: CardItem, direction: ListDirection) {
|
||||
moveCard(card: CardItem, direction: MoveDirection) {
|
||||
this.dispatch({
|
||||
type: 'MOVE_CARD',
|
||||
card,
|
||||
|
Loading…
x
Reference in New Issue
Block a user