Compare commits
7 Commits
01848b3920
...
feature/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c33b3eaf6 | ||
| dfaea894e4 | |||
| 35f1909ca0 | |||
|
|
b71a9d5d6e | ||
|
|
8d98a01c22 | ||
| a3a6b6d626 | |||
|
|
25de3eae4b |
@@ -1,11 +1,11 @@
|
||||
import {Component, inject, signal} from '@angular/core';
|
||||
import {Component, effect, inject, input, OnInit, signal} from '@angular/core';
|
||||
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
|
||||
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
||||
import {NzColDirective} from "ng-zorro-antd/grid";
|
||||
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
||||
import {NzDatePickerComponent} from "ng-zorro-antd/date-picker";
|
||||
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
|
||||
import {DeliverersService, GetDelivererDto} from "../../services/api";
|
||||
import {DeliverersService, GetDelivererDto, GetDeliveryNoteDto} from "../../services/api";
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
|
||||
@@ -21,13 +21,14 @@ import {firstValueFrom} from "rxjs";
|
||||
ReactiveFormsModule,
|
||||
NzDatePickerComponent,
|
||||
NzSelectComponent,
|
||||
NzOptionComponent
|
||||
NzOptionComponent,
|
||||
],
|
||||
templateUrl: './deliverery-note-form.html',
|
||||
styleUrl: './deliverery-note-form.css',
|
||||
})
|
||||
export class DelivereryNoteForm {
|
||||
export class DelivereryNoteForm implements OnInit {
|
||||
deliveryNoteForm: FormGroup = new FormGroup({
|
||||
trackingNumber: new FormControl<string>("TRK-" + Date.now),
|
||||
deliverer: new FormControl<string>(null,[Validators.required]),
|
||||
expeditionDate: new FormControl(null,[Validators.required]),
|
||||
estimatedDate: new FormControl(null),
|
||||
@@ -54,4 +55,20 @@ export class DelivereryNoteForm {
|
||||
filter(input: string, option: any) {
|
||||
return option.nzLabel.toLowerCase().includes(input.toLowerCase());
|
||||
}
|
||||
|
||||
deliveryNote= input<GetDeliveryNoteDto>();
|
||||
constructor() {
|
||||
effect(() => {
|
||||
if (this.deliveryNote()) {
|
||||
this.deliveryNoteForm.patchValue({
|
||||
trackingNumber: this.deliveryNote().trackingNumber,
|
||||
expeditionDate: this.deliveryNote().expeditionDate,
|
||||
realDeliveryDate: this.deliveryNote().expeditionDate,
|
||||
estimatedDate: this.deliveryNote().expeditionDate,
|
||||
deliverer: this.deliveryNote().delivererId
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,24 +48,22 @@
|
||||
</td>
|
||||
<td>
|
||||
<div style="justify-content: center; display: flex">
|
||||
<div>
|
||||
<nz-icon nzType="check" nzTheme="outline" (click)="validate(deliveryNote.id)" class="cursor-pointer text-green-700"/>
|
||||
</div>
|
||||
<nz-icon nzType="check" nzTheme="outline" (click)="validate(deliveryNote.id)" class="cursor-pointer text-green-700"/>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<app-modal-nav nameIcon="edit" name="Modification du bon de livraison" class="cursor-pointer">
|
||||
<app-deliverery-note-form></app-deliverery-note-form>
|
||||
</app-modal-nav>
|
||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer" (click)="openEditModal(deliveryNote)"></nz-icon>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<div>
|
||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(deliveryNote.id)" class="cursor-pointer text-red-700"/>
|
||||
</div>
|
||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(deliveryNote.id)" class="cursor-pointer text-red-700"/>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<div>
|
||||
<nz-icon nzType="export" nzTheme="outline" (click)="export(deliveryNote.id)" class="cursor-pointer text-green-700"/>
|
||||
</div>
|
||||
<nz-icon nzType="export" nzTheme="outline" (click)="export(deliveryNote.id)" class="cursor-pointer text-green-700"/>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</nz-table>
|
||||
|
||||
<div class="hidden">
|
||||
<app-modal-nav #modalNav nameIcon="edit" [name]="'Modifier un bon de livraison'" (ok)="onModalOk(selectedDeliveryNote.id, deliveryNoteForm, modalNav)" (cancel)="onModalCancel(modalNav)">
|
||||
<app-deliverery-note-form #deliveryNoteForm [deliveryNote]="selectedDeliveryNote"></app-deliverery-note-form>
|
||||
</app-modal-nav>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||
import {Component, inject, OnInit, signal, viewChild} from '@angular/core';
|
||||
import {DatePipe} from "@angular/common";
|
||||
import {ModalButton} from "../modal-button/modal-button";
|
||||
import {ModalNav} from "../modal-nav/modal-nav";
|
||||
@@ -32,6 +32,7 @@ export class DelivereryNoteTable implements OnInit {
|
||||
private fileService = inject(FileService);
|
||||
deliveryNotes = signal<GetDeliveryNoteDto[]>([]);
|
||||
deliveryNotesLoading = signal<boolean>(false);
|
||||
modal = viewChild.required<ModalNav>('modalNav');
|
||||
|
||||
async ngOnInit() {
|
||||
await this.fetchDeliveryNotes();
|
||||
@@ -107,7 +108,6 @@ export class DelivereryNoteTable implements OnInit {
|
||||
);
|
||||
this.fileService.downloadBlob(pdf)
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
this.notificationService.error(
|
||||
'Erreur',
|
||||
'Impossible de générer un PDF'
|
||||
@@ -115,4 +115,51 @@ export class DelivereryNoteTable implements OnInit {
|
||||
}
|
||||
this.deliveryNotesLoading.set(false)
|
||||
}
|
||||
|
||||
selectedDeliveryNote: GetDeliveryNoteDto | null = null;
|
||||
openEditModal(deliveryNote: GetDeliveryNoteDto) {
|
||||
this.selectedDeliveryNote = { ...deliveryNote };
|
||||
this.modal().showModal();
|
||||
}
|
||||
|
||||
async onModalOk(id: number, updateDelivereryNoteComponent: DelivereryNoteForm, modal: ModalNav) {
|
||||
if (!this.selectedDeliveryNote) return;
|
||||
|
||||
await this.edit(id, updateDelivereryNoteComponent);
|
||||
updateDelivereryNoteComponent.deliveryNoteForm.reset();
|
||||
modal.isVisible = false;
|
||||
await this.fetchDeliveryNotes();
|
||||
}
|
||||
|
||||
onModalCancel(modal: ModalNav) {
|
||||
modal.isVisible = false;
|
||||
}
|
||||
|
||||
async edit(id: number, updateDelivereryNoteComponent: DelivereryNoteForm) {
|
||||
if (updateDelivereryNoteComponent.deliveryNoteForm.invalid) {
|
||||
this.notificationService.error(
|
||||
'Erreur',
|
||||
'Erreur d\'écriture dans le formulaire'
|
||||
)
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
const deliveryNotes = updateDelivereryNoteComponent.deliveryNoteForm.getRawValue();
|
||||
await firstValueFrom(this.deliveryNotesService.updateDeliveryNoteEndpoint(id, deliveryNotes))
|
||||
|
||||
this.notificationService.success(
|
||||
'Success',
|
||||
'Bon de livraison modifié'
|
||||
)
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
this.notificationService.error(
|
||||
'Erreur',
|
||||
'Erreur lors de la modification'
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<form nz-form nzLayout="horizontal" [formGroup]="searchForm" (ngSubmit)="submitForm()">
|
||||
<form nz-form nzLayout="horizontal" [formGroup]="searchForm">
|
||||
<nz-form-item nz-flex>
|
||||
<nz-form-control nzSpan="12">
|
||||
<div class="group">
|
||||
<nz-icon nzType="search" nzTheme="outline" class="mr-2 text-xl"></nz-icon>
|
||||
<input class="input" placeholder="Rechercher" formControlName="searchValue"/>
|
||||
<nz-icon nzType="search" nzTheme="outline" class="mr-2 text-xl" (click)="OnSearch()"></nz-icon>
|
||||
<input class="input" placeholder="Rechercher" formControlName="searchValue" (input)="OnSearch()"/>
|
||||
</div>
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, output } from '@angular/core';
|
||||
import {NzIconDirective} from "ng-zorro-antd/icon";
|
||||
import {NzColDirective} from "ng-zorro-antd/grid";
|
||||
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
||||
@@ -24,14 +24,12 @@ export class Search {
|
||||
searchValue: new FormControl<string>(null)
|
||||
})
|
||||
|
||||
submitForm() {
|
||||
// Pour annuler si le formulaire est invalide
|
||||
if (this.searchForm.invalid) return;
|
||||
searchEvent = output<string>();
|
||||
|
||||
// Pour obtenir la valeur du formulaire
|
||||
console.log(this.searchForm.getRawValue())
|
||||
OnSearch(): void {
|
||||
const raw = this.searchForm.controls['searchValue'].value ?? '';
|
||||
const value = String(raw).trim();
|
||||
this.searchEvent.emit(value);
|
||||
|
||||
// Pour vider le formulaire
|
||||
this.searchForm.reset()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<nz-table
|
||||
[nzData]="products()"
|
||||
[nzData]="filteredProducts()"
|
||||
[nzFrontPagination]="false"
|
||||
[nzLoading]="productsLoading()"
|
||||
(nzCurrentPageDataChange)="onCurrentPageDataChange($event)"
|
||||
@@ -27,7 +27,7 @@
|
||||
</thead>
|
||||
|
||||
<tbody class="text-center">
|
||||
@for (product of products(); track product.id) {
|
||||
@for (product of filteredProducts(); track product.id) {
|
||||
<tr>
|
||||
<td nzWidth="40px">
|
||||
<label
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, inject, OnInit, output, signal, viewChild} from '@angular/core';
|
||||
import {Component, computed, inject, OnInit, output, signal, viewChild} from '@angular/core';
|
||||
import {NzTableComponent, NzThMeasureDirective} from "ng-zorro-antd/table";
|
||||
import {ModalNav} from "../modal-nav/modal-nav";
|
||||
import {NzIconDirective} from "ng-zorro-antd/icon";
|
||||
@@ -45,6 +45,22 @@ export class StockTable implements OnInit {
|
||||
selectionChange = output<boolean>()
|
||||
currentPageData: GetProductDto[] = [];
|
||||
|
||||
private searchQuery = signal<string>('');
|
||||
|
||||
filteredProducts = computed(() => {
|
||||
const q = this.searchQuery().toLowerCase().trim();
|
||||
|
||||
if (!q) return this.products();
|
||||
|
||||
return this.products().filter(s => {
|
||||
const name = (s.name ?? '').toLowerCase();
|
||||
return name.includes(q);
|
||||
});
|
||||
});
|
||||
|
||||
applySearch(query: string) {
|
||||
this.searchQuery.set(query);
|
||||
}
|
||||
get hasSelection(): boolean {
|
||||
return this.setOfCheckedId.size > 0;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<nz-table [nzData]="suppliers()"
|
||||
<nz-table [nzData]="filteredSuppliers()"
|
||||
[nzLoading]="suppliersLoading()"
|
||||
[nzFrontPagination]="false">
|
||||
<thead>
|
||||
@@ -15,7 +15,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody style="text-align: center">
|
||||
@for (supplier of suppliers(); track supplier.id) {
|
||||
@for (supplier of filteredSuppliers(); track supplier.id) {
|
||||
<tr>
|
||||
<td>{{ supplier.name }}</td>
|
||||
<td>{{ supplier.phone }}</td>
|
||||
@@ -26,7 +26,7 @@
|
||||
<td>{{ supplier.deliveryDelay }} jours</td>
|
||||
<td>
|
||||
<app-modal-button type="link" [name]="'Voir les produits'" size="45%">
|
||||
<nz-table [nzData]="suppliers()" [nzFrontPagination]="false">
|
||||
<nz-table [nzData]="filteredSuppliers()" [nzFrontPagination]="false">
|
||||
<thead>
|
||||
<tr class="text-center">
|
||||
<th>Produit</th>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, inject, OnInit, signal, viewChild} from '@angular/core';
|
||||
import {Component, computed, inject, OnInit, signal, viewChild} from '@angular/core';
|
||||
import {ModalNav} from "../modal-nav/modal-nav";
|
||||
import {NzDividerComponent} from "ng-zorro-antd/divider";
|
||||
import {NzIconDirective} from "ng-zorro-antd/icon";
|
||||
@@ -42,6 +42,23 @@ export class SupplierTable implements OnInit {
|
||||
await this.fetchSuppliers();
|
||||
}
|
||||
|
||||
private searchQuery = signal<string>('');
|
||||
|
||||
filteredSuppliers = computed(() => {
|
||||
const q = this.searchQuery().toLowerCase().trim();
|
||||
|
||||
if (!q) return this.suppliers();
|
||||
|
||||
return this.suppliers().filter(s => {
|
||||
const name = (s.name ?? '').toLowerCase();
|
||||
return name.includes(q);
|
||||
});
|
||||
});
|
||||
|
||||
applySearch(query: string) {
|
||||
this.searchQuery.set(query);
|
||||
}
|
||||
|
||||
async fetchSuppliers() {
|
||||
this.suppliersLoading.set(true);
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<nz-table [nzData]="users()"
|
||||
<nz-table [nzData]="filteredUsers()"
|
||||
[nzLoading]="usersLoading()"
|
||||
[nzFrontPagination]="false"
|
||||
class="mr-7">
|
||||
@@ -11,7 +11,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-center">
|
||||
@for (user of users(); track user.id) {
|
||||
@for (user of filteredUsers(); track user.id) {
|
||||
<tr>
|
||||
<td>{{user.name}}</td>
|
||||
<td>{{user.email}}</td>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, inject, OnInit, signal, viewChild} from '@angular/core';
|
||||
import {Component, computed, inject, OnInit, signal, viewChild} from '@angular/core';
|
||||
import {ModalNav} from "../modal-nav/modal-nav";
|
||||
import {NzIconDirective} from "ng-zorro-antd/icon";
|
||||
import {NzTableComponent} from "ng-zorro-antd/table";
|
||||
@@ -32,6 +32,22 @@ export class UserTable implements OnInit {
|
||||
await this.fetchUsers();
|
||||
}
|
||||
|
||||
private searchQuery = signal<string>('');
|
||||
|
||||
filteredUsers = computed(() => {
|
||||
const q = this.searchQuery().toLowerCase().trim();
|
||||
|
||||
if (!q) return this.users();
|
||||
|
||||
return this.users().filter(s => {
|
||||
const name = (s.name ?? '').toLowerCase();
|
||||
return name.includes(q);
|
||||
});
|
||||
});
|
||||
|
||||
applySearch(query: string) {
|
||||
this.searchQuery.set(query);
|
||||
}
|
||||
async fetchUsers() {
|
||||
this.usersLoading.set(true)
|
||||
|
||||
@@ -105,4 +121,7 @@ export class UserTable implements OnInit {
|
||||
onModalCancel(modal: ModalNav) {
|
||||
modal.isVisible = false;
|
||||
}
|
||||
filterUser(input: string, option: any) {
|
||||
return option.nzLabel.toLowerCase().includes(input.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
}
|
||||
|
||||
<div class="ml-95 w-150">
|
||||
<app-search class="w-full"></app-search>
|
||||
<app-search (searchEvent)="onProductSearch($event)"></app-search>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@ export class Stock {
|
||||
private productsService = inject(ProductsService);
|
||||
private notificationService = inject(NzNotificationService)
|
||||
|
||||
onProductSearch(query: string) {
|
||||
this.productTable().applySearch(query);
|
||||
}
|
||||
// async onModalOk() {
|
||||
// await this.addSupplier()
|
||||
// this.createSupplier().supplierForm.reset();
|
||||
|
||||
@@ -8,9 +8,8 @@
|
||||
|
||||
<app-supplier-form #supplierForm></app-supplier-form>
|
||||
</app-modal-button>
|
||||
|
||||
<div class="ml-95 w-150">
|
||||
<app-search></app-search>
|
||||
<app-search (searchEvent)="onSupplierSearch($event)"></app-search>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@ export class Supplier {
|
||||
this.modal().isVisible = false;
|
||||
}
|
||||
|
||||
onSupplierSearch(query: string) {
|
||||
this.supplierTable().applySearch(query);
|
||||
}
|
||||
|
||||
async addSupplier() {
|
||||
if (this.createSupplier().supplierForm.invalid)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
</app-modal-button>
|
||||
|
||||
<div class="ml-95 w-150">
|
||||
<app-search></app-search>
|
||||
<app-search (searchEvent)="onUserSearch($event)"></app-search>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -32,6 +32,9 @@ export class User {
|
||||
await this.usersTable().fetchUsers()
|
||||
}
|
||||
|
||||
onUserSearch(query: string) {
|
||||
this.usersTable().applySearch(query);
|
||||
}
|
||||
onModalCancel() {
|
||||
this.modal().isVisible = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user