Use Operation Edit form to add new operation in Operation List component.
This commit is contained in:
parent
f6bcdcfc2b
commit
6da1861139
@ -1,14 +1,15 @@
|
|||||||
import { Component, Inject, OnInit } from '@angular/core';
|
import { Component, Inject, OnInit } from '@angular/core';
|
||||||
import { Observable } from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
|
|
||||||
|
import { Logger } from '@nsalaun/ng-logger';
|
||||||
|
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 { AccountService } from '../accounts/account.service';
|
import { AccountService } from '../accounts/account.service';
|
||||||
import { Operation } from './operation';
|
import { Operation } from './operation';
|
||||||
import { OperationService } from './operation.service';
|
import { OperationService } from './operation.service';
|
||||||
|
import { OperationEditModalComponent } from './operationEditModal.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'operation-list',
|
selector: 'operation-list',
|
||||||
@ -68,11 +69,12 @@ export class OperationListComponent implements OnInit {
|
|||||||
private operations: Operation[];
|
private operations: Operation[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject("$modal") private $modal,
|
|
||||||
@Inject("accountIdService") private accountIdService,
|
@Inject("accountIdService") private accountIdService,
|
||||||
private toastrService: ToastrService,
|
private toastrService: ToastrService,
|
||||||
private operationService: OperationService,
|
private operationService: OperationService,
|
||||||
private accountService: AccountService
|
private accountService: AccountService,
|
||||||
|
private logger: Logger,
|
||||||
|
private ngbModal: NgbModal,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -136,25 +138,15 @@ export class OperationListComponent implements OnInit {
|
|||||||
|
|
||||||
modify(operation) {
|
modify(operation) {
|
||||||
// FIXME Alexis Lahouze 2017-06-15 i18n
|
// FIXME Alexis Lahouze 2017-06-15 i18n
|
||||||
var title = "New operation";
|
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;
|
this.save(operation);
|
||||||
$scope.operation = operation;
|
}, (reason) => {
|
||||||
$scope.$save = () => {
|
|
||||||
$scope.$hide();
|
|
||||||
$save($scope.operation);
|
|
||||||
};
|
|
||||||
},
|
|
||||||
locals: {
|
|
||||||
title: title,
|
|
||||||
operation: operation,
|
|
||||||
$save: (operation: Operation) => {
|
|
||||||
this.save(operation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user