refactor: chain list to extend base settings list
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
<app-simple-list-w-actions [items]="(chains$|async) ?? []" (action)="edit($event)"/>
|
||||
<app-floating-big-btn icon="add" (bigClick)="add()"/>
|
||||
@@ -6,34 +6,34 @@ import { SimpleListItem } from '../../../../components/simple-list-w-actions/Sim
|
||||
import { SimpleListItemAction } from '../../../../components/simple-list-w-actions/SimpleListItemAction';
|
||||
import { Chain } from '../../../../models/Chain';
|
||||
import { AsyncPipe } from '@angular/common';
|
||||
import { FloatingBigBtn } from "../../../../components/floating-big-btn/floating-big-btn";
|
||||
import { FloatingBigBtn } from '../../../../components/floating-big-btn/floating-big-btn';
|
||||
import { SettingsBaseList } from '../../../../components/settings-base-list/settings-base-list';
|
||||
|
||||
@Component({
|
||||
selector: 'app-chain-list',
|
||||
imports: [SimpleListWActions, AsyncPipe, FloatingBigBtn],
|
||||
templateUrl: './chain-list.html',
|
||||
styles: ``,
|
||||
templateUrl: './../../../../components/settings-base-list/settings-base-list.html',
|
||||
styleUrl: './../../../../components/settings-base-list/settings-base-list.scss',
|
||||
})
|
||||
export class ChainList {
|
||||
export class ChainList extends SettingsBaseList {
|
||||
private readonly router = inject(Router);
|
||||
protected readonly activatedRoute = inject(ActivatedRoute);
|
||||
|
||||
chains$ = this.activatedRoute.data.pipe(
|
||||
data$ = this.activatedRoute.data.pipe(
|
||||
map((data) =>
|
||||
(<Chain[]>data['chains']).map(
|
||||
(c, i) =>
|
||||
new SimpleListItem(String(c.id), c.name ?? '', [new SimpleListItemAction('edit', 'edit')]),
|
||||
new SimpleListItem(String(c.id), c.name ?? '', [
|
||||
new SimpleListItemAction('edit', 'edit'),
|
||||
]),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
protected edit(action: {
|
||||
action: string;
|
||||
subject: string;
|
||||
}) {
|
||||
this.router.navigate(['settings', 'chains', 'edit', action.subject])
|
||||
protected edit(action: { action: string; subject: string }) {
|
||||
this.router.navigate(['settings', 'chains', 'edit', action.subject]);
|
||||
}
|
||||
|
||||
|
||||
protected add() {
|
||||
this.router.navigate(['settings', 'chains', 'add']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user