diff --git a/frontend/src/app/features/calculator/calculator-page.component.ts b/frontend/src/app/features/calculator/calculator-page.component.ts index afc5aea..c6d469c 100644 --- a/frontend/src/app/features/calculator/calculator-page.component.ts +++ b/frontend/src/app/features/calculator/calculator-page.component.ts @@ -1,4 +1,4 @@ -import { Component, signal } from '@angular/core'; +import { Component, signal, ViewChild } from '@angular/core'; import { CommonModule } from '@angular/common'; import { TranslateModule } from '@ngx-translate/core'; @@ -37,6 +37,7 @@ import { Router } from '@angular/router'; } @else if (result()) { - + } @else {

{{ 'CALC.BENEFITS_TITLE' | translate }}

@@ -177,6 +182,8 @@ export class CalculatorPageComponent { uploadProgress = signal(0); result = signal(null); error = signal(false); + + @ViewChild('uploadForm') uploadForm!: UploadFormComponent; constructor(private estimator: QuoteEstimatorService, private router: Router) {} diff --git a/frontend/src/app/features/calculator/components/quote-result/quote-result.component.ts b/frontend/src/app/features/calculator/components/quote-result/quote-result.component.ts index 134a7f7..cf325c4 100644 --- a/frontend/src/app/features/calculator/components/quote-result/quote-result.component.ts +++ b/frontend/src/app/features/calculator/components/quote-result/quote-result.component.ts @@ -15,7 +15,32 @@ import { QuoteResult, QuoteItem } from '../../services/quote-estimator.service';

{{ 'CALC.RESULT' | translate }}

- + +
+ + {{ totals().price | currency:result().currency }} + + + + {{ totals().hours }}h {{ totals().minutes }}m + + + + {{ totals().weight }}g + +
+ +
+ * Include {{ result().setupCost | currency:result().currency }} Setup Cost +
+ +
+ +
@for (item of items(); track item.fileName; let i = $index) {
@@ -44,31 +69,6 @@ import { QuoteResult, QuoteItem } from '../../services/quote-estimator.service'; }
-
- - -
- - {{ totals().price | currency:result().currency }} - - - - {{ totals().hours }}h {{ totals().minutes }}m - - - - {{ totals().weight }}g - -
- -
- * Include {{ result().setupCost | currency:result().currency }} Setup Cost -
-
{{ 'CALC.ORDER' | translate }} {{ 'CALC.CONSULT' | translate }} @@ -159,6 +159,7 @@ import { QuoteResult, QuoteItem } from '../../services/quote-estimator.service'; export class QuoteResultComponent { result = input.required(); consult = output(); + itemChange = output<{fileName: string, quantity: number}>(); // Local mutable state for items to handle quantity changes items = signal([]); @@ -180,6 +181,11 @@ export class QuoteResultComponent { updated[index] = { ...updated[index], quantity: qty }; return updated; }); + + this.itemChange.emit({ + fileName: this.items()[index].fileName, + quantity: qty + }); } totals = computed(() => { diff --git a/frontend/src/app/features/calculator/components/upload-form/upload-form.component.ts b/frontend/src/app/features/calculator/components/upload-form/upload-form.component.ts index 99eb7b5..f3319f5 100644 --- a/frontend/src/app/features/calculator/components/upload-form/upload-form.component.ts +++ b/frontend/src/app/features/calculator/components/upload-form/upload-form.component.ts @@ -31,15 +31,16 @@ interface FormItem {
} - - - - + + @if (items().length === 0) { + + + } @if (items().length > 0) { @@ -69,6 +70,14 @@ interface FormItem {
} + + +
+ + + + {{ 'CALC.ADD_FILES' | translate }} + +
} @if (items().length === 0 && form.get('itemsTouched')?.value) { @@ -363,6 +372,26 @@ export class UploadFormComponent { } } + onAdditionalFilesSelected(event: Event) { + const input = event.target as HTMLInputElement; + if (input.files && input.files.length > 0) { + this.onFilesDropped(Array.from(input.files)); + // Reset input so same files can be selected again if needed + input.value = ''; + } + } + + updateItemQuantityByName(fileName: string, quantity: number) { + this.items.update(current => { + return current.map(item => { + if (item.file.name === fileName) { + return { ...item, quantity }; + } + return item; + }); + }); + } + selectFile(file: File) { if (this.selectedFile() === file) { // toggle off? no, keep active