Add Schedule Edit Modal component.
This commit is contained in:
parent
3c0d3c1a39
commit
57aa737465
@ -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
|
||||||
|
53
src/scheduler/scheduleEditModal.component.ts
Normal file
53
src/scheduler/scheduleEditModal.component.ts
Normal 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");
|
||||||
|
}
|
||||||
|
}
|
@ -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';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user