accountant-ui/src/scheduler/scheduleEditModal.component.ts
2017-07-25 17:18:04 +02:00

54 lines
1.1 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 { Schedule } from './schedule';
@Component({
selector: 'schedule-edit-modal',
template: `
<div class="modal-header">
<h3 class="modal-title" id="modal-title">{{ title() }}</h3>
</div>
<div class="modal-body" id="modal-body">
<schedule-form [(schedule)]="schedule" (onValid)="valid=$event"></schedule-form>
</div>
<div class="modal-footer">
<button class="btn btn-primary" [disabled]="!valid" (click)="submit()">
Save
</button>
<button class="btn btn-default" (click)="cancel()">
Cancel
</button>
</div>
`
})
export class ScheduleEditModalComponent {
@Input() schedule: Schedule;
valid: boolean = false;
constructor(private activeModal: NgbActiveModal) {}
title(): string {
if(this.schedule.id) {
return "Schedule #" + this.schedule.id;
} else {
return "New schedule";
}
}
submit(): void {
this.activeModal.close(this.schedule);
}
cancel(): void {
this.activeModal.dismiss("closed");
}
}