Use Schedule Edit Modal component in Schedule Row component.

This commit is contained in:
Alexis Lahouze 2017-07-25 17:21:01 +02:00
parent 57aa737465
commit d1344d57b8

View File

@ -11,8 +11,6 @@ import { ScheduleEditModalComponent } from './scheduleEditModal.component';
import { ScheduleService } from './schedule.service';
import { Schedule } from './schedule';
var scheduleFormTmpl = require('./schedule.form.tmpl.html');
@Component({
selector: 'tr[schedule-row]',
host: {
@ -61,7 +59,6 @@ export class ScheduleRowComponent {
private scheduleService: ScheduleService,
private logger: Logger,
private toastrService: ToastrService,
@Inject('$modal') private $modal,
private ngbModal: NgbModal
) {}
@ -108,26 +105,15 @@ export class ScheduleRowComponent {
}
modify() {
// FIXME Alexis Lahouze 2017-06-15 i18n
var title = "Modify schedule #" + this.schedule.id;
const modal = this.ngbModal.open(ScheduleEditModalComponent, {
windowClass: 'in'
});
this.$modal({
templateUrl: scheduleFormTmpl,
controller: function($scope, title, schedule, $save) {
$scope.title = title;
$scope.operation = schedule;
$scope.$save = () => {
$scope.$hide();
$save($scope.operation);
};
},
locals: {
title: title,
schedule: this.schedule,
$save: (operation) => {
this.save(operation);
}
}
modal.componentInstance.schedule = this.schedule;
modal.result.then((schedule: Schedule) => {
this.save(schedule);
}, (reason) => function(reason) {
});
}
}