Add Schedule Edit Modal component.

This commit is contained in:
Alexis Lahouze 2017-07-25 17:18:04 +02:00
parent 3c0d3c1a39
commit 57aa737465
3 changed files with 57 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import { ToastrModule } from 'ngx-toastr';
import { ScheduleService } from './schedule.service'; import { ScheduleService } from './schedule.service';
import { ScheduleDeleteModalComponent } from './scheduleDeleteModal.component'; import { ScheduleDeleteModalComponent } from './scheduleDeleteModal.component';
import { ScheduleEditModalComponent } from './scheduleEditModal.component';
import { ScheduleFormComponent } from './scheduleForm.component'; import { ScheduleFormComponent } from './scheduleForm.component';
import { ScheduleRowComponent } from './scheduleRow.component'; import { ScheduleRowComponent } from './scheduleRow.component';
import { ScheduleListComponent } from './scheduleList.component'; import { ScheduleListComponent } from './scheduleList.component';
@ -48,12 +49,14 @@ export function accountIdServiceFactory(i: any) {
], ],
declarations: [ declarations: [
ScheduleDeleteModalComponent, ScheduleDeleteModalComponent,
ScheduleEditModalComponent,
ScheduleFormComponent, ScheduleFormComponent,
ScheduleListComponent, ScheduleListComponent,
ScheduleRowComponent ScheduleRowComponent
], ],
entryComponents: [ entryComponents: [
ScheduleDeleteModalComponent, ScheduleDeleteModalComponent,
ScheduleEditModalComponent,
ScheduleFormComponent, ScheduleFormComponent,
ScheduleListComponent, ScheduleListComponent,
ScheduleRowComponent ScheduleRowComponent

View File

@ -0,0 +1,53 @@
// 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");
}
}

View File

@ -7,6 +7,7 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { ScheduleDeleteModalComponent } from './scheduleDeleteModal.component'; import { ScheduleDeleteModalComponent } from './scheduleDeleteModal.component';
import { ScheduleEditModalComponent } from './scheduleEditModal.component';
import { ScheduleService } from './schedule.service'; import { ScheduleService } from './schedule.service';
import { Schedule } from './schedule'; import { Schedule } from './schedule';