Skip to content

Commit

Permalink
feat(user): delete user in local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
ElonH committed May 18, 2020
1 parent 691513d commit 21c3834
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/app/@dataflow/extra/users-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export abstract class UsersFlow extends BareFlow<FlowInNode, UsersFlowNode> {
data.push(user);
this.setAll(data);
}
public static del(name: string) {
const data = this.getAll();
this.setAll(data.filter((x) => x.name !== name));
}
public static purge() {
localStorage.removeItem('users');
}
Expand Down
7 changes: 4 additions & 3 deletions src/app/pages/user/user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { NbStepperComponent, NbStepComponent } from '@nebular/theme';
<user-confirm
[users$]="usersFlow$.getOutput()"
[selected$]="selectedTrigger"
(onDelete)="onConfirm()"
(onDelete)="onConfirm($event)"
>
</user-confirm>
<button nbButton (click)="realPrev()">prev</button>
Expand Down Expand Up @@ -152,7 +152,8 @@ export class UserComponent implements OnInit {
this.saveUserTrigger.next(user);
}

onConfirm() {
console.log('deleted');
onConfirm(name: string) {
UsersFlow.del(name);
this.usersTrigger.next(1); // update users
}
}

0 comments on commit 21c3834

Please sign in to comment.