From 3f6d60bb5098dc739391645cdab9427c98402cb1 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Sun, 30 Jul 2017 15:50:14 +0200 Subject: [PATCH] Add Operation Form component. --- src/operations/operation.module.ts | 3 ++ src/operations/operationForm.component.ts | 63 +++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/operations/operationForm.component.ts diff --git a/src/operations/operation.module.ts b/src/operations/operation.module.ts index 834f3f1..7cd9bbd 100644 --- a/src/operations/operation.module.ts +++ b/src/operations/operation.module.ts @@ -15,6 +15,7 @@ import { CategoryService } from './category.service'; import { OperationService } from './operation.service'; import { OperationListComponent } from './operationList.component'; import { OperationDeleteModalComponent } from './operationDeleteModal.component'; +import { OperationFormComponent } from './operationForm.component'; export function $modalServiceFactory(i: any) { return i.get('$modal'); @@ -51,6 +52,7 @@ export function accountIdServiceFactory(i: any) { OperationRowComponent, OperationListComponent, OperationDeleteModalComponent, + OperationFormComponent, ], entryComponents: [ BalanceChartComponent, @@ -58,6 +60,7 @@ export function accountIdServiceFactory(i: any) { OperationRowComponent, OperationListComponent, OperationDeleteModalComponent, + OperationFormComponent, ] }) export class OperationModule {} diff --git a/src/operations/operationForm.component.ts b/src/operations/operationForm.component.ts new file mode 100644 index 0000000..a0669c1 --- /dev/null +++ b/src/operations/operationForm.component.ts @@ -0,0 +1,63 @@ +// vim: set tw=80 ts=2 sw=2 sts=2 : +import { AfterViewChecked, Component, EventEmitter, Input, Output, ViewChild } from '@angular/core'; +import { NgForm } from '@angular/forms'; + +import { Operation } from './operation'; + +@Component({ + selector: 'operation-form', + template: ` +
+
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+
+ ` +}) +export class OperationFormComponent implements AfterViewChecked { + @Input() operation: Operation; + @Output() onValid: EventEmitter = new EventEmitter(); + @ViewChild('form') form: NgForm; + + //dateMask = [/\d{4}/, '-', /0[1-9]|1[0-2]/, '-', /[0-2]\d|3[0-1]/]; + dateMask = ['2', '0', /\d/, /\d/, '-', /[0-1]/, /\d/, '-', /[0-3]/, /\d/]; + + constructor() {} + + ngAfterViewChecked() { + this.onValid.emit(this.form.form.valid); + } +}