From d019189ec177693ae7c66643cc2cb0d6289cc832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Tue, 22 Aug 2023 21:13:47 +0200 Subject: [PATCH] Layer detail refactor --- Frontend/src/app/models/layer.model.ts | 6 +-- .../layer-detail/layer-detail.component.html | 41 ++++++++----------- .../layer-detail/layer-detail.component.ts | 18 ++++---- .../layers-list/layers-list.component.html | 4 +- .../layers-list/layers-list.component.ts | 3 +- Frontend/src/styles.scss | 5 ++- 6 files changed, 33 insertions(+), 44 deletions(-) diff --git a/Frontend/src/app/models/layer.model.ts b/Frontend/src/app/models/layer.model.ts index a03d5b6..9cd0472 100644 --- a/Frontend/src/app/models/layer.model.ts +++ b/Frontend/src/app/models/layer.model.ts @@ -6,7 +6,7 @@ import { map } from 'rxjs'; import { Record } from 'src/app/models/record.model'; export enum LayerType { - Ipmort, + Import, Processed, Administration, Dictionary @@ -19,7 +19,7 @@ export class Layer extends Base { name?: string; records: Record[] = []; created?: string; - type?: LayerType = LayerType.Ipmort; + type?: LayerType; constructor(data: Partial = {}) { super(); @@ -28,8 +28,6 @@ export class Layer extends Base { // eslint-disable-next-line @typescript-eslint/no-explicit-any override deserialize(input: any): this { Object.assign(this, Object.assign(this, super.deserialize(input))); - console.log(input.type); - console.log(this.type); if (this.records) { this.records = this.records.map(x => new Record().deserialize(x)); } return this; } diff --git a/Frontend/src/app/modules/layers/layer-detail/layer-detail.component.html b/Frontend/src/app/modules/layers/layer-detail/layer-detail.component.html index d5e3bcb..2a2edba 100644 --- a/Frontend/src/app/modules/layers/layer-detail/layer-detail.component.html +++ b/Frontend/src/app/modules/layers/layer-detail/layer-detail.component.html @@ -1,7 +1,8 @@ -
+ - Layer details + Layer details +  
@@ -22,39 +23,29 @@
Created - +
- - + + - Code - {{item.code}} + + - Value1 - {{item.value1 | number:'1.2-2'}} - + + - - - Account - {{item.desc1}} - - - - - - - + + + +
Code {{row.code}} Value1 {{row.value1 | number:'1.2-2'}}
+
+ {{valueSum}}
\ No newline at end of file diff --git a/Frontend/src/app/modules/layers/layer-detail/layer-detail.component.ts b/Frontend/src/app/modules/layers/layer-detail/layer-detail.component.ts index f33b2ca..69d6c39 100644 --- a/Frontend/src/app/modules/layers/layer-detail/layer-detail.component.ts +++ b/Frontend/src/app/modules/layers/layer-detail/layer-detail.component.ts @@ -1,8 +1,8 @@ -import { DatePipe, NgIf, DecimalPipe } from '@angular/common'; +import { DatePipe, NgIf, DecimalPipe, JsonPipe } from '@angular/common'; import { HttpClient } from '@angular/common/http'; -import { Component, OnInit, ViewChild } from '@angular/core'; +import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core'; import { UntypedFormGroup, UntypedFormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { MatSort, MatSortModule } from '@angular/material/sort'; +import { MatSort, MatSortModule, MatSortable } from '@angular/material/sort'; import { MatTableDataSource, MatTableModule } from '@angular/material/table'; import { ActivatedRoute } from '@angular/router'; import { Layer } from 'src/app/models/layer.model'; @@ -23,7 +23,7 @@ import { MatCardModule } from '@angular/material/card'; standalone: true, imports: [FormsModule, ReactiveFormsModule, MatCardModule, MatToolbarModule, MatButtonModule, MatGridListModule, MatFormFieldModule, MatInputModule, - NgIf, MatTableModule, MatSortModule, DecimalPipe], + NgIf, MatTableModule, MatSortModule, DecimalPipe, JsonPipe], providers: [DatePipe] }) export class LayerDetailComponent implements OnInit { @@ -44,25 +44,23 @@ export class LayerDetailComponent implements OnInit { private route$: ActivatedRoute, private datePipe: DatePipe, private notifications$: NotificationsService - ) { } + ) { + this.form = Layer.getForm(this.fb$); + } async ngOnInit() { - this.form = Layer.getForm(this.fb$); this.document = await this.load(); this.dataSource = new MatTableDataSource(this.document.records); this.dataSource.sort = this.sort; this.document.fillForm(this.form); this.form.disable(); this.document.created = `${this.datePipe.transform(this.document.createdAt?.toDate(), 'short')}, ${this.document.createdBy?.userName}`; - // this.dataSource.sort.sort({ id: 'code', start: 'desc' } as MatSortable); this.valueSum = this.document.records.map(t => t.value1 || 0).reduce((acc, value) => acc + value, 0); } private async load(): Promise { return await Layer.getById(this.route$.snapshot.paramMap.get('id') || "", this.http$); } - trackByUid(index : number, item : Record) { - return item.id; - } + async export() { if (await Layer.exportToGoogleSheet(this.document.id || "", this.http$)) { this.notifications$.add({ diff --git a/Frontend/src/app/modules/layers/layers-list/layers-list.component.html b/Frontend/src/app/modules/layers/layers-list/layers-list.component.html index 031988d..f2b99d6 100644 --- a/Frontend/src/app/modules/layers/layers-list/layers-list.component.html +++ b/Frontend/src/app/modules/layers/layers-list/layers-list.component.html @@ -12,10 +12,10 @@ Type - {{element.type}} + {{LayerType[element.type]}} - + \ No newline at end of file diff --git a/Frontend/src/app/modules/layers/layers-list/layers-list.component.ts b/Frontend/src/app/modules/layers/layers-list/layers-list.component.ts index 36e93a6..e4c00b5 100644 --- a/Frontend/src/app/modules/layers/layers-list/layers-list.component.ts +++ b/Frontend/src/app/modules/layers/layers-list/layers-list.component.ts @@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http'; import { Component, HostListener, OnInit } from '@angular/core'; import { MatSortModule } from '@angular/material/sort'; import { MatTableModule } from '@angular/material/table'; -import { Layer } from 'src/app/models/layer.model'; +import { Layer, LayerType } from 'src/app/models/layer.model'; import { MatInputModule } from '@angular/material/input'; import { MatFormFieldModule } from '@angular/material/form-field'; import { RouterLink } from '@angular/router'; @@ -26,6 +26,7 @@ import { NgFor } from '@angular/common'; export class LayersListComponent implements OnInit { displayedColumns = ['number', 'name', 'type']; dataSource!: Layer[]; + LayerType = LayerType; start = 0; limit = 50; diff --git a/Frontend/src/styles.scss b/Frontend/src/styles.scss index f189912..1d781b1 100644 --- a/Frontend/src/styles.scss +++ b/Frontend/src/styles.scss @@ -84,6 +84,7 @@ app-root:empty+.AppLoading { margin-right: 0; } -.list-container { - width: 100%; +input[disabled] { + color: black; + -webkit-text-fill-color: black; } \ No newline at end of file