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,32 +6,32 @@ import { SimpleListItem } from '../../../../components/simple-list-w-actions/Sim
|
|||||||
import { SimpleListItemAction } from '../../../../components/simple-list-w-actions/SimpleListItemAction';
|
import { SimpleListItemAction } from '../../../../components/simple-list-w-actions/SimpleListItemAction';
|
||||||
import { Chain } from '../../../../models/Chain';
|
import { Chain } from '../../../../models/Chain';
|
||||||
import { AsyncPipe } from '@angular/common';
|
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({
|
@Component({
|
||||||
selector: 'app-chain-list',
|
selector: 'app-chain-list',
|
||||||
imports: [SimpleListWActions, AsyncPipe, FloatingBigBtn],
|
imports: [SimpleListWActions, AsyncPipe, FloatingBigBtn],
|
||||||
templateUrl: './chain-list.html',
|
templateUrl: './../../../../components/settings-base-list/settings-base-list.html',
|
||||||
styles: ``,
|
styleUrl: './../../../../components/settings-base-list/settings-base-list.scss',
|
||||||
})
|
})
|
||||||
export class ChainList {
|
export class ChainList extends SettingsBaseList {
|
||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
protected readonly activatedRoute = inject(ActivatedRoute);
|
protected readonly activatedRoute = inject(ActivatedRoute);
|
||||||
|
|
||||||
chains$ = this.activatedRoute.data.pipe(
|
data$ = this.activatedRoute.data.pipe(
|
||||||
map((data) =>
|
map((data) =>
|
||||||
(<Chain[]>data['chains']).map(
|
(<Chain[]>data['chains']).map(
|
||||||
(c, i) =>
|
(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: {
|
protected edit(action: { action: string; subject: string }) {
|
||||||
action: string;
|
this.router.navigate(['settings', 'chains', 'edit', action.subject]);
|
||||||
subject: string;
|
|
||||||
}) {
|
|
||||||
this.router.navigate(['settings', 'chains', 'edit', action.subject])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected add() {
|
protected add() {
|
||||||
|
|||||||
Reference in New Issue
Block a user