54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
// vim: set tw=80 ts=2 sw=2 sts=2:
|
|
import { Component, Input } from '@angular/core';
|
|
import { NgForm } from '@angular/forms';
|
|
|
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
|
|
|
import { Account } from './account';
|
|
|
|
@Component({
|
|
selector: 'account-edit-modal',
|
|
template: `
|
|
<div class="modal-header">
|
|
<h3 class="modal-title" id="modal-title">{{ title() }}</h3>
|
|
</div>
|
|
|
|
<div class="modal-body" id="modal-body">
|
|
<account-form [(account)]="account" (onFormChanged)="accountForm = $event"></account-form>
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
<button class="btn btn-primary" [disabled]="!accountForm?.form.valid" (click)="submit()">
|
|
Save
|
|
</button>
|
|
|
|
<button class="btn btn-default" (click)="cancel()">
|
|
Cancel
|
|
</button>
|
|
</div>
|
|
`
|
|
})
|
|
export class AccountEditModalComponent {
|
|
@Input() account: Account;
|
|
|
|
accountForm: NgForm;
|
|
|
|
constructor(public activeModal: NgbActiveModal) {}
|
|
|
|
title(): string {
|
|
if(this.account.id) {
|
|
return "Account #" + this.account.id;
|
|
} else {
|
|
return "New account";
|
|
}
|
|
}
|
|
|
|
submit(): void {
|
|
this.activeModal.close(this.account);
|
|
}
|
|
|
|
cancel(): void {
|
|
this.activeModal.dismiss("closed");
|
|
}
|
|
}
|