|
|
@@ -1,5 +1,5 @@
|
|
|
import { Component, Inject, inject } from '@angular/core';
|
|
|
-import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
|
+import { MatDialogRef, MAT_DIALOG_DATA, MatDialog, MatDialogModule } from '@angular/material/dialog';
|
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
@@ -12,6 +12,8 @@ import { webConfig } from '../../config';
|
|
|
import { MatIconModule } from '@angular/material/icon';
|
|
|
import { FFBProduction } from '../../ffb/ffb-production.interface';
|
|
|
|
|
|
+import { CreateFfbProductionDialogComponent } from '../../components/ffb-production-dialog/create-ffb-production-dialog.component';
|
|
|
+
|
|
|
@Component({
|
|
|
selector: 'app-ffb-vector-search-dialog',
|
|
|
templateUrl: './ffb-vector-search-dialog.component.html',
|
|
|
@@ -25,11 +27,13 @@ import { FFBProduction } from '../../ffb/ffb-production.interface';
|
|
|
MatButtonModule,
|
|
|
MatProgressSpinnerModule,
|
|
|
MatTableModule,
|
|
|
- MatIconModule
|
|
|
+ MatIconModule,
|
|
|
+ MatDialogModule
|
|
|
],
|
|
|
})
|
|
|
export class FfbVectorSearchDialogComponent {
|
|
|
private http = inject(HttpClient);
|
|
|
+ private dialog = inject(MatDialog);
|
|
|
dialogRef = inject(MatDialogRef<FfbVectorSearchDialogComponent>);
|
|
|
|
|
|
queryControl = new FormControl('');
|
|
|
@@ -40,7 +44,7 @@ export class FfbVectorSearchDialogComponent {
|
|
|
|
|
|
displayedColumns: string[] = ['productionDate', 'site', 'phase', 'block', 'weight', 'quantity', 'score'];
|
|
|
|
|
|
- constructor(@Inject(MAT_DIALOG_DATA) public data: any) {}
|
|
|
+ constructor(@Inject(MAT_DIALOG_DATA) public data: any) { }
|
|
|
|
|
|
search() {
|
|
|
const q = this.queryControl.value?.trim();
|
|
|
@@ -79,4 +83,25 @@ export class FfbVectorSearchDialogComponent {
|
|
|
const d = new Date(date);
|
|
|
return d.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: '2-digit' });
|
|
|
}
|
|
|
+
|
|
|
+ openDetails(harvest: FFBProduction) {
|
|
|
+ const dialogRef = this.dialog.open(CreateFfbProductionDialogComponent, {
|
|
|
+ width: '800px',
|
|
|
+ data: {
|
|
|
+ harvest,
|
|
|
+ allSites: this.data.allSites || [],
|
|
|
+ allPhases: this.data.allPhases || [],
|
|
|
+ allBlocks: this.data.allBlocks || [],
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ dialogRef.afterClosed().subscribe(result => {
|
|
|
+ // Ideally we might want to refresh the search results if edited,
|
|
|
+ // but for now we just let them close it.
|
|
|
+ if (result === 'refresh') {
|
|
|
+ // We could re-trigger search if we want to reflect changes immediately
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|