From 73485ac1af1e4aff194fcf303f93420470d8cb12 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Sun, 30 Jul 2017 16:35:15 +0200 Subject: [PATCH] Indent. --- src/operations/operationList.component.ts | 166 +++++++++++----------- 1 file changed, 84 insertions(+), 82 deletions(-) diff --git a/src/operations/operationList.component.ts b/src/operations/operationList.component.ts index 17aa54c..28285e6 100644 --- a/src/operations/operationList.component.ts +++ b/src/operations/operationList.component.ts @@ -1,3 +1,4 @@ +// vim: set tw=80 ts=2 sw=2 sts=2 : import { Component, Inject, OnInit } from '@angular/core'; import { Observable } from 'rxjs/Rx'; @@ -12,14 +13,15 @@ import { OperationService } from './operation.service'; import { OperationEditModalComponent } from './operationEditModal.component'; @Component({ - selector: 'operation-list', - template: ` + selector: 'operation-list', + template: `
+
{ - this.account = account - }); + ngOnInit() { + this.accountService.get(this.accountIdService.get()).subscribe(account => { + this.account = account + }); + } + + /* + * Add an empty operation. + */ + add() { + var operation = new Operation(); + operation.account_id = this.accountIdService.get(); + + return this.modify(operation); + }; + + /* + * Load operations. + */ + load(minDate, maxDate) { + this.minDate = minDate; + this.maxDate = maxDate; + + return this.operationService.query( + this.accountIdService.get(), + minDate, + maxDate + ).subscribe((operations: Operation[]) => { + this.operations = operations.reverse(); + }); + }; + + /* + * Save an operation and return a promise. + */ + save(operation) { + operation.confirmed = true; + + var observable: Observable; + + if(operation.id){ + observable = this.operationService.update(operation); + } else { + observable = this.operationService.create(operation); } - /* - * Add an empty operation. - */ - add() { - var operation = new Operation(); - operation.account_id = this.accountIdService.get(); + return observable.subscribe((operation) => { + this.toastrService.success('Operation #' + operation.id + ' saved.'); - return this.modify(operation); - }; + this.load(this.minDate, this.maxDate); - /* - * Load operations. - */ - load(minDate, maxDate) { - this.minDate = minDate; - this.maxDate = maxDate; + return operation; + }, (result) => { + this.toastrService.error( + 'Error while saving operation: ' + result.message + ); + }); + }; - return this.operationService.query( - this.accountIdService.get(), - minDate, - maxDate - ).subscribe((operations: Operation[]) => { - this.operations = operations.reverse(); - }); - }; + modify(operation) { + // FIXME Alexis Lahouze 2017-06-15 i18n + const modal = this.ngbModal.open(OperationEditModalComponent, { + windowClass: 'in' + }); - /* - * Save an operation and return a promise. - */ - save(operation) { - operation.confirmed = true; + modal.componentInstance.operation = operation; - var observable: Observable; + modal.result.then((operation: Operation) => { + this.save(operation); + }, (reason) => { + }); + }; - if(operation.id){ - observable = this.operationService.update(operation); - } else { - observable = this.operationService.create(operation); - } - - return observable.subscribe((operation) => { - this.toastrService.success('Operation #' + operation.id + ' saved.'); - - this.load(this.minDate, this.maxDate); - - return operation; - }, (result) => { - this.toastrService.error( - 'Error while saving operation: ' + result.message - ); - }); - }; - - modify(operation) { - // FIXME Alexis Lahouze 2017-06-15 i18n - const modal = this.ngbModal.open(OperationEditModalComponent, { - windowClass: 'in' - }); - - modal.componentInstance.operation = operation; - - modal.result.then((operation: Operation) => { - this.save(operation); - }, (reason) => { - }); - }; - - onUpdate(dateRange) { - this.load(dateRange.minDate, dateRange.maxDate); - }; + onUpdate(dateRange) { + this.load(dateRange.minDate, dateRange.maxDate); + }; };