Use Operation Edit form to edit operation in Operation Row component.
This commit is contained in:
parent
6da1861139
commit
1c18d93d13
@ -5,12 +5,11 @@ import { Component, Inject, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { ToastrService } from 'ngx-toastr';
|
||||
|
||||
var operationFormTmpl = require('./operation.form.tmpl.html');
|
||||
|
||||
import { Account } from '../accounts/account';
|
||||
import { Operation } from './operation';
|
||||
import { OperationService } from './operation.service';
|
||||
import { OperationDeleteModalComponent } from './operationDeleteModal.component';
|
||||
import { OperationEditModalComponent } from './operationEditModal.component';
|
||||
|
||||
@Component({
|
||||
selector: 'tr[operation-row]',
|
||||
@ -81,8 +80,7 @@ export class OperationRowComponent {
|
||||
constructor(
|
||||
private operationService: OperationService,
|
||||
private toastrService: ToastrService,
|
||||
private modal: NgbModal,
|
||||
@Inject('$modal') private $modal,
|
||||
private ngbModal: NgbModal,
|
||||
) {}
|
||||
|
||||
togglePointed(operation, rowform) {
|
||||
@ -112,7 +110,7 @@ export class OperationRowComponent {
|
||||
}
|
||||
|
||||
confirmDelete(operation) {
|
||||
const modal = this.modal.open(OperationDeleteModalComponent);
|
||||
const modal = this.ngbModal.open(OperationDeleteModalComponent);
|
||||
|
||||
modal.componentInstance.operation = this.operation;
|
||||
|
||||
@ -141,25 +139,15 @@ export class OperationRowComponent {
|
||||
|
||||
modify(operation) {
|
||||
// FIXME Alexis Lahouze 2017-06-15 i18n
|
||||
var title = "Modify operation #" + operation.id;
|
||||
const modal = this.ngbModal.open(OperationEditModalComponent, {
|
||||
windowClass: 'in'
|
||||
});
|
||||
|
||||
this.$modal({
|
||||
templateUrl: operationFormTmpl,
|
||||
controller: function($scope, title, operation, $save) {
|
||||
$scope.title = title;
|
||||
$scope.operation = operation;
|
||||
$scope.$save = () => {
|
||||
$scope.$hide();
|
||||
$save($scope.operation);
|
||||
};
|
||||
},
|
||||
locals: {
|
||||
title: title,
|
||||
operation: operation,
|
||||
$save: (operation: Operation) => {
|
||||
modal.componentInstance.operation = operation;
|
||||
|
||||
modal.result.then((operation: Operation) => {
|
||||
this.save(operation);
|
||||
}
|
||||
}
|
||||
}, (reason) => {
|
||||
});
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user