added reorder state changing
This commit is contained in:
parent
b41c31b4ac
commit
335cbf4956
|
@ -7,7 +7,7 @@ import { faCommentAlt, faCalendarAlt } from "@fortawesome/free-regular-svg-icons
|
|||
import { HotkeysService, Hotkey } from 'angular2-hotkeys';
|
||||
|
||||
import { AccountWrapper } from "../../models/account.models";
|
||||
import { AccountInfo, SelectAccount } from "../../states/accounts.state";
|
||||
import { AccountInfo, ReorderAccounts, SelectAccount } from "../../states/accounts.state";
|
||||
import { NavigationService, LeftPanelType } from "../../services/navigation.service";
|
||||
import { UserNotificationService, UserNotification } from '../../services/user-notification.service';
|
||||
import { ToolsService } from '../../services/tools.service';
|
||||
|
@ -169,14 +169,12 @@ export class LeftSideBarComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
onDrop(event: CdkDragDrop<AccountWithNotificationWrapper[]>) {
|
||||
console.warn(event);
|
||||
|
||||
if (event.previousContainer === event.container) {
|
||||
moveItemInArray(event.container.data,
|
||||
event.previousIndex,
|
||||
event.currentIndex);
|
||||
|
||||
console.warn(this.accounts);
|
||||
this.store.dispatch([new ReorderAccounts(this.accounts.map(x => x.info))])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,11 @@ export class AddAccount {
|
|||
constructor(public account: AccountInfo) {}
|
||||
}
|
||||
|
||||
export class ReorderAccounts {
|
||||
static readonly type = '[Accounts] Reorder';
|
||||
constructor(public accounts: AccountInfo[]) {}
|
||||
}
|
||||
|
||||
export class SelectAccount {
|
||||
static readonly type = '[Accounts] Select account';
|
||||
constructor(public account: AccountInfo, public multiselection: boolean = false) {}
|
||||
|
@ -46,6 +51,16 @@ export class AccountsState {
|
|||
});
|
||||
}
|
||||
|
||||
@Action(ReorderAccounts)
|
||||
ReorderAccounts(ctx: StateContext<AccountsStateModel>, action: ReorderAccounts){
|
||||
// const state = ctx.getState();
|
||||
const reorderedAccounts = action.accounts;
|
||||
|
||||
ctx.patchState({
|
||||
accounts: [...reorderedAccounts]
|
||||
});
|
||||
}
|
||||
|
||||
@Action(UpdateAccount)
|
||||
UpdateAccount(ctx: StateContext<AccountsStateModel>, action: UpdateAccount){
|
||||
const state = ctx.getState();
|
||||
|
|
Loading…
Reference in New Issue