refactor: add chain to extend settings base add
This commit is contained in:
32
src/app/components/chain-add/chain-add.ts
Normal file
32
src/app/components/chain-add/chain-add.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { Chain } from '../../models/Chain';
|
||||
import { ChainFormGroup } from '../../pages/settings/chains/chain-formgroup';
|
||||
import { ActionBtn } from '../action-btn/action-btn';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { UpperfirstPipe } from '../../pipes/upperfirst-pipe';
|
||||
import { ChainSettings } from '../../services/chain-settings';
|
||||
import { SettingsBaseAdd } from '../settings-base-add/settings-base-add';
|
||||
|
||||
@Component({
|
||||
selector: 'app-chain-add',
|
||||
imports: [
|
||||
ActionBtn,
|
||||
TranslatePipe,
|
||||
UpperfirstPipe,
|
||||
],
|
||||
templateUrl: './../settings-base-add/settings-base-add.html',
|
||||
styleUrl: './../settings-base-add/settings-base-add.scss',
|
||||
})
|
||||
export class ChainAdd extends SettingsBaseAdd {
|
||||
private readonly chainSettings = inject(ChainSettings);
|
||||
override readonly form = new ChainFormGroup();
|
||||
override title = 'settings.chain.new_chain';
|
||||
|
||||
async save() {
|
||||
const name = this.form.controls.name.value;
|
||||
const img = this.form.controls.image.value;
|
||||
//TODO: the sqlite bridge can't handle null as param
|
||||
const chain = new Chain(name, '');
|
||||
await this.chainSettings.save(chain, img);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user