42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
// vim: set tw=80 ts=2 sw=2 sts=2:
|
|
import { Component, Input, ViewChild } from '@angular/core';
|
|
|
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
|
|
|
import { Account } from './account';
|
|
import { AccountFormComponent } from './accountForm.component';
|
|
|
|
@Component({
|
|
selector: 'account-edit-modal',
|
|
templateUrl: './accountEditModal.component.html'
|
|
})
|
|
export class AccountEditModalComponent {
|
|
@Input() account: Account;
|
|
@ViewChild('accountForm') accountForm: AccountFormComponent;
|
|
|
|
constructor(private activeModal: NgbActiveModal) {}
|
|
|
|
title(): string {
|
|
if(this.account.id) {
|
|
return "Account #" + this.account.id;
|
|
} else {
|
|
return "New account";
|
|
}
|
|
}
|
|
|
|
submit(): void {
|
|
let formModel = this.accountForm.form.value;
|
|
let account = Object.assign({}, this.account);
|
|
|
|
account.id = this.account.id;
|
|
account.name = formModel.name;
|
|
account.authorized_overdraft = formModel.authorizedOverdraft;
|
|
|
|
this.activeModal.close(account);
|
|
}
|
|
|
|
cancel(): void {
|
|
this.activeModal.dismiss("closed");
|
|
}
|
|
}
|