From 33f0158a7091b48f6ccf6b6db5509dc154f60893 Mon Sep 17 00:00:00 2001 From: "julian.denis" Date: Thu, 20 May 2021 19:42:57 +0200 Subject: [PATCH 01/21] :construction:group assignments by year not finish --- .../assignment-chooser.component.html | 120 ++++++--------- .../assignment-chooser.component.ts | 141 +++++++++++++++++- 2 files changed, 181 insertions(+), 80 deletions(-) diff --git a/src/app/components/home/assignment-chooser/assignment-chooser.component.html b/src/app/components/home/assignment-chooser/assignment-chooser.component.html index 4ba0594..736d886 100644 --- a/src/app/components/home/assignment-chooser/assignment-chooser.component.html +++ b/src/app/components/home/assignment-chooser/assignment-chooser.component.html @@ -1,78 +1,44 @@
- - - - - - - - - - - < - {{ row.lastModificationDate | date: 'short' }} - - - - - -
- - - - -
- -
- -
- - - -
-
-
-
-
- - - - - - - -{{ 'HOME.CREATE-ASSIGNMENT-TOOLTIP' | translate }} -{{ 'HOME.SELECT-ASSIGNMENT-TOOLTIP' | translate }} -{{ 'HOME.EDIT-ASSIGNMENT-TOOLTIP' | translate }} -{{ 'HOME.DELETE-ASSIGNMENT-TOOLTIP' | translate }} -{{ 'EXPORT-ASSIGNMENTS-TOOLTIP' | translate }} -{{ 'IMPORT-ASSIGNMENTS-TOOLTIP' | translate }} \ No newline at end of file + + \ No newline at end of file diff --git a/src/app/components/home/assignment-chooser/assignment-chooser.component.ts b/src/app/components/home/assignment-chooser/assignment-chooser.component.ts index e095770..5e823d6 100644 --- a/src/app/components/home/assignment-chooser/assignment-chooser.component.ts +++ b/src/app/components/home/assignment-chooser/assignment-chooser.component.ts @@ -20,12 +20,23 @@ import { ToastService } from "@services/toast.service"; styleUrls: ["./assignment-chooser.component.scss"], // changeDetection: ChangeDetectionStrategy.OnPush }) + export class AssignmentChooserComponent implements OnInit { - @ViewChild("importConfirmation") + @ViewChild("importConfirmation") table: any; private importConfirmation: TemplateRef; assignments: Assignment[]; modalRef: NgbModalRef; + funder = []; + calculated = []; + pending = []; + groups = []; + + editing = {}; + rows = []; + + + constructor( private databaseService: DatabaseService, private dataService: DataService, @@ -37,7 +48,8 @@ export class AssignmentChooserComponent implements OnInit { public activeModalService: NgbActiveModal, private assignmentsService: AssignmentsService, private configurationService: ConfigurationService - ) {} + ) {this.assignments = []; + this.loadAssignments();} ngOnInit(): void { this.assignments = []; @@ -120,4 +132,127 @@ export class AssignmentChooserComponent implements OnInit { this.modalRef = this.modalService.open(this.importConfirmation); return this.modalRef.result; } -} + + getGroupRowHeight(group, rowHeight) { + let style = {}; + + style = { + height: group.length * 40 + 'px', + width: '100%' + }; + + return style; + } + + checkGroup(event, row, rowIndex, group) { + let groupStatus = 'Pending'; + let expectedPaymentDealtWith = true; + + row.exppayyes = 0; + row.exppayno = 0; + row.exppaypending = 0; + + if (event.target.checked) { + if (event.target.value === '0') { + // expected payment yes selected + row.exppayyes = 1; + } else if (event.target.value === '1') { + // expected payment yes selected + row.exppayno = 1; + } else if (event.target.value === '2') { + // expected payment yes selected + row.exppaypending = 1; + } + } + + if (group.length === 2) { + // There are only 2 lines in a group + // tslint:disable-next-line:max-line-length + if ( + ['Calculated', 'Funder'].indexOf(group[0].comment) > -1 && + ['Calculated', 'Funder'].indexOf(group[1].comment) > -1 + ) { + // Sources are funder and calculated + // tslint:disable-next-line:max-line-length + if (group[0].startdate === group[1].startdate && group[0].enddate === group[1].enddate) { + // Start dates and end dates match + for (let index = 0; index < group.length; index++) { + if (group[index].comment !== row.comment) { + if (event.target.value === '0') { + // expected payment yes selected + group[index].exppayyes = 0; + group[index].exppaypending = 0; + group[index].exppayno = 1; + } + } + + if (group[index].exppayyes === 0 && group[index].exppayno === 0 && group[index].exppaypending === 0) { + expectedPaymentDealtWith = false; + } + console.log('expectedPaymentDealtWith', expectedPaymentDealtWith); + } + } + } + } else { + for (let index = 0; index < group.length; index++) { + if (group[index].exppayyes === 0 && group[index].exppayno === 0 && group[index].exppaypending === 0) { + expectedPaymentDealtWith = false; + } + console.log('expectedPaymentDealtWith', expectedPaymentDealtWith); + } + } + + // check if there is a pending selected payment or a row that does not have any expected payment selected + if ( + group.filter(rowFilter => rowFilter.exppaypending === 1).length === 0 && + group.filter(rowFilter => rowFilter.exppaypending === 0 && rowFilter.exppayyes === 0 && rowFilter.exppayno === 0) + .length === 0 + ) { + console.log('expected payment dealt with'); + + // check if can set the group status + const numberOfExpPayYes = group.filter(rowFilter => rowFilter.exppayyes === 1).length; + const numberOfSourceFunder = group.filter(rowFilter => rowFilter.exppayyes === 1 && rowFilter.source === 'Funder') + .length; + const numberOfSourceCalculated = group.filter( + rowFilter => rowFilter.exppayyes === 1 && rowFilter.source === 'Calculated' + ).length; + const numberOfSourceManual = group.filter(rowFilter => rowFilter.exppayyes === 1 && rowFilter.source === 'Manual') + .length; + + console.log('numberOfExpPayYes', numberOfExpPayYes); + console.log('numberOfSourceFunder', numberOfSourceFunder); + console.log('numberOfSourceCalculated', numberOfSourceCalculated); + console.log('numberOfSourceManual', numberOfSourceManual); + + if (numberOfExpPayYes > 0) { + if (numberOfExpPayYes === numberOfSourceFunder) { + groupStatus = 'Funder Selected'; + } else if (numberOfExpPayYes === numberOfSourceCalculated) { + groupStatus = 'Calculated Selected'; + } else if (numberOfExpPayYes === numberOfSourceManual) { + groupStatus = 'Manual Selected'; + } else { + groupStatus = 'Hybrid Selected'; + } + } + } + + group[0].groupstatus = groupStatus; + } + + updateValue(event, cell, rowIndex) { + this.editing[rowIndex + '-' + cell] = false; + this.assignments[rowIndex][cell] = event.target.value; + this.assignments = [...this.assignments]; + } + + toggleExpandGroup(group) { + console.log('Toggled Expand Group!', group); + this.table.groupHeader.toggleExpandGroup(group); + } + + onDetailToggle(event) { + console.log('Detail Toggled', event); + } +} \ No newline at end of file From af771fdf42bbef91074f9306d61d3c17f9e9f8cf Mon Sep 17 00:00:00 2001 From: "julian.denis" Date: Mon, 31 May 2021 14:42:03 +0200 Subject: [PATCH 02/21] =?UTF-8?q?=E2=9A=97=EF=B8=8F=20groupping=20rows=20w?= =?UTF-8?q?ork=20in=20progress?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assignment-chooser.component.html | 106 ++++++++++---- .../assignment-chooser.component.ts | 132 +----------------- 2 files changed, 81 insertions(+), 157 deletions(-) diff --git a/src/app/components/home/assignment-chooser/assignment-chooser.component.html b/src/app/components/home/assignment-chooser/assignment-chooser.component.html index 736d886..62f67a2 100644 --- a/src/app/components/home/assignment-chooser/assignment-chooser.component.html +++ b/src/app/components/home/assignment-chooser/assignment-chooser.component.html @@ -1,44 +1,90 @@
-
\ No newline at end of file + + + + + + + + +{{ 'HOME.CREATE-ASSIGNMENT-TOOLTIP' | translate }} +{{ 'HOME.SELECT-ASSIGNMENT-TOOLTIP' | translate }} +{{ 'HOME.EDIT-ASSIGNMENT-TOOLTIP' | translate }} +{{ 'HOME.DELETE-ASSIGNMENT-TOOLTIP' | translate }} +{{ 'EXPORT-ASSIGNMENTS-TOOLTIP' | translate }} +{{ 'IMPORT-ASSIGNMENTS-TOOLTIP' | translate }} \ No newline at end of file diff --git a/src/app/components/home/assignment-chooser/assignment-chooser.component.ts b/src/app/components/home/assignment-chooser/assignment-chooser.component.ts index 5e823d6..6ba635b 100644 --- a/src/app/components/home/assignment-chooser/assignment-chooser.component.ts +++ b/src/app/components/home/assignment-chooser/assignment-chooser.component.ts @@ -27,16 +27,6 @@ export class AssignmentChooserComponent implements OnInit { assignments: Assignment[]; modalRef: NgbModalRef; - funder = []; - calculated = []; - pending = []; - groups = []; - - editing = {}; - rows = []; - - - constructor( private databaseService: DatabaseService, private dataService: DataService, @@ -48,8 +38,7 @@ export class AssignmentChooserComponent implements OnInit { public activeModalService: NgbActiveModal, private assignmentsService: AssignmentsService, private configurationService: ConfigurationService - ) {this.assignments = []; - this.loadAssignments();} + ) {} ngOnInit(): void { this.assignments = []; @@ -95,6 +84,7 @@ export class AssignmentChooserComponent implements OnInit { } importDB(blob: Blob) { + console.log(blob); let translations = this.translateService.instant([ "SUCCESS", "ERROR", @@ -119,6 +109,7 @@ export class AssignmentChooserComponent implements OnInit { } changeListener($event): void { + console.log($event); let file = $event.target.files[0]; if (file) { this.openImportConfirmation().then( @@ -133,122 +124,9 @@ export class AssignmentChooserComponent implements OnInit { return this.modalRef.result; } - getGroupRowHeight(group, rowHeight) { - let style = {}; - - style = { - height: group.length * 40 + 'px', - width: '100%' - }; - - return style; - } - - checkGroup(event, row, rowIndex, group) { - let groupStatus = 'Pending'; - let expectedPaymentDealtWith = true; - - row.exppayyes = 0; - row.exppayno = 0; - row.exppaypending = 0; - - if (event.target.checked) { - if (event.target.value === '0') { - // expected payment yes selected - row.exppayyes = 1; - } else if (event.target.value === '1') { - // expected payment yes selected - row.exppayno = 1; - } else if (event.target.value === '2') { - // expected payment yes selected - row.exppaypending = 1; - } - } - - if (group.length === 2) { - // There are only 2 lines in a group - // tslint:disable-next-line:max-line-length - if ( - ['Calculated', 'Funder'].indexOf(group[0].comment) > -1 && - ['Calculated', 'Funder'].indexOf(group[1].comment) > -1 - ) { - // Sources are funder and calculated - // tslint:disable-next-line:max-line-length - if (group[0].startdate === group[1].startdate && group[0].enddate === group[1].enddate) { - // Start dates and end dates match - for (let index = 0; index < group.length; index++) { - if (group[index].comment !== row.comment) { - if (event.target.value === '0') { - // expected payment yes selected - group[index].exppayyes = 0; - group[index].exppaypending = 0; - group[index].exppayno = 1; - } - } - - if (group[index].exppayyes === 0 && group[index].exppayno === 0 && group[index].exppaypending === 0) { - expectedPaymentDealtWith = false; - } - console.log('expectedPaymentDealtWith', expectedPaymentDealtWith); - } - } - } - } else { - for (let index = 0; index < group.length; index++) { - if (group[index].exppayyes === 0 && group[index].exppayno === 0 && group[index].exppaypending === 0) { - expectedPaymentDealtWith = false; - } - console.log('expectedPaymentDealtWith', expectedPaymentDealtWith); - } - } - - // check if there is a pending selected payment or a row that does not have any expected payment selected - if ( - group.filter(rowFilter => rowFilter.exppaypending === 1).length === 0 && - group.filter(rowFilter => rowFilter.exppaypending === 0 && rowFilter.exppayyes === 0 && rowFilter.exppayno === 0) - .length === 0 - ) { - console.log('expected payment dealt with'); - - // check if can set the group status - const numberOfExpPayYes = group.filter(rowFilter => rowFilter.exppayyes === 1).length; - const numberOfSourceFunder = group.filter(rowFilter => rowFilter.exppayyes === 1 && rowFilter.source === 'Funder') - .length; - const numberOfSourceCalculated = group.filter( - rowFilter => rowFilter.exppayyes === 1 && rowFilter.source === 'Calculated' - ).length; - const numberOfSourceManual = group.filter(rowFilter => rowFilter.exppayyes === 1 && rowFilter.source === 'Manual') - .length; - - console.log('numberOfExpPayYes', numberOfExpPayYes); - console.log('numberOfSourceFunder', numberOfSourceFunder); - console.log('numberOfSourceCalculated', numberOfSourceCalculated); - console.log('numberOfSourceManual', numberOfSourceManual); - - if (numberOfExpPayYes > 0) { - if (numberOfExpPayYes === numberOfSourceFunder) { - groupStatus = 'Funder Selected'; - } else if (numberOfExpPayYes === numberOfSourceCalculated) { - groupStatus = 'Calculated Selected'; - } else if (numberOfExpPayYes === numberOfSourceManual) { - groupStatus = 'Manual Selected'; - } else { - groupStatus = 'Hybrid Selected'; - } - } - } - - group[0].groupstatus = groupStatus; - } - - updateValue(event, cell, rowIndex) { - this.editing[rowIndex + '-' + cell] = false; - this.assignments[rowIndex][cell] = event.target.value; - this.assignments = [...this.assignments]; - } - toggleExpandGroup(group) { - console.log('Toggled Expand Group!', group); + console.log(this.table, this.table?.groupHeader); + console.log('Toggled Expand Group!', group, group.value[0], group.value[1], group.value[0].metadata.startDate); this.table.groupHeader.toggleExpandGroup(group); } From 270e9e4721a9447ba945581ab755f2db52ca92e3 Mon Sep 17 00:00:00 2001 From: "julian.denis" Date: Mon, 31 May 2021 15:09:03 +0200 Subject: [PATCH 03/21] =?UTF-8?q?=E2=9A=97=EF=B8=8F=20Fix=20import=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assignment-chooser.component.html | 4 ++-- .../assignment-chooser/assignment-chooser.component.ts | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/app/components/home/assignment-chooser/assignment-chooser.component.html b/src/app/components/home/assignment-chooser/assignment-chooser.component.html index 62f67a2..3a7f657 100644 --- a/src/app/components/home/assignment-chooser/assignment-chooser.component.html +++ b/src/app/components/home/assignment-chooser/assignment-chooser.component.html @@ -1,11 +1,11 @@