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