2 Commits

Author SHA1 Message Date
750a0da817 added edit function 2025-12-12 21:46:16 +01:00
a707a33a87 first commit 2025-12-12 21:19:39 +01:00
10 changed files with 176 additions and 50 deletions

View File

@@ -79,20 +79,12 @@ export class DelivererTable implements OnInit {
} }
try { try {
const deliverers = updateDelivererComponent.delivererForm.getRawValue(); const deliverers = updateDelivererComponent.delivererForm.getRawValue();
await firstValueFrom(this.deliverersService.updateDelivererEndpoint(id, deliverers)) await firstValueFrom(this.deliverersService.updateDelivererEndpoint(id, deliverers))
this.notificationService.success( this.notificationService.success('Success', 'Transporteur modifié')
'Success',
'Transporteur modifié'
)
} catch (e) { } catch (e) {
console.error(e); this.notificationService.error('Erreur', 'Erreur lors de la modification')
this.notificationService.error(
'Erreur',
'Erreur lors de la modification'
)
} }
} }

View File

@@ -116,25 +116,6 @@ export class DelivereryNoteTable implements OnInit {
this.deliveryNotesLoading.set(false) 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) { async edit(id: number, updateDelivereryNoteComponent: DelivereryNoteForm) {
if (updateDelivereryNoteComponent.deliveryNoteForm.invalid) { if (updateDelivereryNoteComponent.deliveryNoteForm.invalid) {
this.notificationService.error('Erreur', 'Formulaire invalide'); this.notificationService.error('Erreur', 'Formulaire invalide');
@@ -176,4 +157,22 @@ export class DelivereryNoteTable implements OnInit {
} }
} }
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;
}
} }

View File

@@ -1,11 +1,11 @@
<form nz-form nzLayout="horizontal" [formGroup]="QuotationForm"> <form nz-form nzLayout="horizontal" [formGroup]="quotationForm">
<nz-form-item nz-flex> <nz-form-item nz-flex>
<nz-form-label nzSpan="9"> <nz-form-label nzSpan="9">
Message du devis Message du devis
</nz-form-label> </nz-form-label>
<nz-form-control nzSpan="12"> <nz-form-control nzSpan="12">
<input nz-input placeholder="Message du devis" formControlName="quotationMessage"> <input nz-input placeholder="Message du devis" formControlName="message">
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
@@ -15,7 +15,7 @@
</nz-form-label> </nz-form-label>
<nz-form-control nzSpan="12"> <nz-form-control nzSpan="12">
<input nz-input placeholder="Conditions de vente" formControlName="quotationConditionsSale"> <input nz-input placeholder="Conditions de vente" formControlName="conditionsSale">
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</form> </form>

View File

@@ -1,10 +1,10 @@
import { Component } from '@angular/core'; import {Component, effect, input} from '@angular/core';
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms"; import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form"; import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {NzInputDirective} from "ng-zorro-antd/input"; import {NzInputDirective} from "ng-zorro-antd/input";
import {NzColDirective} from "ng-zorro-antd/grid"; import {NzColDirective} from "ng-zorro-antd/grid";
import {NzFlexDirective} from "ng-zorro-antd/flex"; import {NzFlexDirective} from "ng-zorro-antd/flex";
import {NzDatePickerComponent} from "ng-zorro-antd/date-picker"; import {GetQuotationDto} from "../../services/api";
@Component({ @Component({
selector: 'app-quotation-form', selector: 'app-quotation-form',
@@ -22,8 +22,20 @@ import {NzDatePickerComponent} from "ng-zorro-antd/date-picker";
styleUrl: './quotation-form.css', styleUrl: './quotation-form.css',
}) })
export class QuotationForm { export class QuotationForm {
QuotationForm: FormGroup = new FormGroup({ quotationForm: FormGroup = new FormGroup({
quotationMessage: new FormControl<string>(null), message: new FormControl<string>(null, [Validators.required]),
quotationConditionsSale: new FormControl<string>(null), conditionsSale: new FormControl<string>(null, [Validators.required]),
}) })
quotation= input<GetQuotationDto>();
constructor() {
effect(() => {
if (this.quotation()) {
this.quotationForm.patchValue({
message: this.quotation().message,
conditionsSale: this.quotation().conditionsSale,
});
}
});
}
} }

View File

@@ -52,25 +52,22 @@
</td> </td>
<td> <td>
<div style="justify-content: center; display: flex"> <div style="justify-content: center; display: flex">
<div>
<nz-icon nzType="plus-circle" nzTheme="outline" class="cursor-pointer text-green-700" /> <nz-icon nzType="plus-circle" nzTheme="outline" class="cursor-pointer text-green-700" />
</div>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<app-modal-nav nameIcon="edit" name="Modification du devis" class="cursor-pointer"> <nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer" (click)="openEditModal(quotation)"></nz-icon>
<app-quotation-form></app-quotation-form>
</app-modal-nav>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<div>
<nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-700" (click)="delete(quotation.id)"/> <nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-700" (click)="delete(quotation.id)"/>
</div>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<div>
<nz-icon nzType="export" (click)="export(quotation.id)" nzTheme="outline" class="cursor-pointer text-green-700"/> <nz-icon nzType="export" (click)="export(quotation.id)" nzTheme="outline" class="cursor-pointer text-green-700"/>
</div> </div>
</div>
</td> </td>
</tr> </tr>
} }
</tbody> </tbody>
</nz-table> </nz-table>
<div class="hidden">
<app-modal-nav #modalNav nameIcon="edit" [name]="'Modification du devis'" (ok)="onModalOk(selectedQuotation.id, quotationForm, modalNav)" (cancel)="onModalCancel(modalNav)">
<app-quotation-form #quotationForm [quotation]="selectedQuotation"></app-quotation-form>
</app-modal-nav>
</div>

View File

@@ -1,4 +1,4 @@
import {Component, inject, OnInit, signal} from '@angular/core'; import {Component, inject, OnInit, signal, viewChild} from '@angular/core';
import {NzTableComponent} from "ng-zorro-antd/table"; import {NzTableComponent} from "ng-zorro-antd/table";
import {ModalButton} from "../modal-button/modal-button"; import {ModalButton} from "../modal-button/modal-button";
import {ModalNav} from "../modal-nav/modal-nav"; import {ModalNav} from "../modal-nav/modal-nav";
@@ -9,6 +9,7 @@ import {GetQuotationDto, QuotationsService} from "../../services/api";
import {NzNotificationService} from "ng-zorro-antd/notification"; import {NzNotificationService} from "ng-zorro-antd/notification";
import {firstValueFrom} from "rxjs"; import {firstValueFrom} from "rxjs";
import {FileService} from "../../services/file.service"; import {FileService} from "../../services/file.service";
import {DelivereryNoteForm} from "../deliverery-note-form/deliverery-note-form";
@Component({ @Component({
selector: 'app-quotation-table', selector: 'app-quotation-table',
@@ -19,6 +20,7 @@ import {FileService} from "../../services/file.service";
NzIconDirective, NzIconDirective,
NzTableComponent, NzTableComponent,
QuotationForm, QuotationForm,
DelivereryNoteForm,
], ],
templateUrl: './quotation-table.html', templateUrl: './quotation-table.html',
styleUrl: './quotation-table.css', styleUrl: './quotation-table.css',
@@ -30,6 +32,7 @@ export class QuotationTable implements OnInit {
private fileService = inject(FileService); private fileService = inject(FileService);
quotations = signal<GetQuotationDto[]>([]); quotations = signal<GetQuotationDto[]>([]);
quotationsLoading = signal<boolean>(false); quotationsLoading = signal<boolean>(false);
modal = viewChild.required<ModalNav>('modalNav');
async ngOnInit() { async ngOnInit() {
await this.fetchQuotations(); await this.fetchQuotations();
@@ -84,5 +87,40 @@ export class QuotationTable implements OnInit {
} }
this.quotationsLoading.set(false) this.quotationsLoading.set(false)
} }
async edit(id: number, updateQuotationComponent: QuotationForm) {
if (updateQuotationComponent.quotationForm.invalid) {
this.notificationService.error('Erreur', 'Formulaire invalide');
return;
}
try {
const quotations = updateQuotationComponent.quotationForm.getRawValue();
await firstValueFrom(this.quotationsService.updateQuotationEndpoint(id, quotations));
this.notificationService.success('Success', 'Devis modifié')
} catch (e) {
console.error(e)
this.notificationService.error('Erreur', 'Erreur lors de la modification')
}
}
selectedQuotation: GetQuotationDto | null = null;
openEditModal(quotation: GetQuotationDto) {
this.selectedQuotation = { ...quotation };
this.modal().showModal();
}
async onModalOk(id: number, updateQuotationComponent: QuotationForm, modal: ModalNav) {
if (!this.selectedQuotation) return;
await this.edit(id, updateQuotationComponent);
updateQuotationComponent.quotationForm.reset();
modal.isVisible = false;
await this.fetchQuotations();
}
onModalCancel(modal: ModalNav) {
modal.isVisible = false;
}
} }

View File

@@ -59,6 +59,7 @@ model/patch-ware-house-product-quantity-dto.ts
model/update-deliverer-dto.ts model/update-deliverer-dto.ts
model/update-delivery-note-dto.ts model/update-delivery-note-dto.ts
model/update-product-dto.ts model/update-product-dto.ts
model/update-quotation-dto.ts
model/update-supplier-dto.ts model/update-supplier-dto.ts
model/update-user-dto.ts model/update-user-dto.ts
param.ts param.ts

View File

@@ -20,6 +20,8 @@ import { Observable } from 'rxjs';
import { GetQuotationDto } from '../model/get-quotation-dto'; import { GetQuotationDto } from '../model/get-quotation-dto';
// @ts-ignore // @ts-ignore
import { PatchQuotationConditionsSaleDto } from '../model/patch-quotation-conditions-sale-dto'; import { PatchQuotationConditionsSaleDto } from '../model/patch-quotation-conditions-sale-dto';
// @ts-ignore
import { UpdateQuotationDto } from '../model/update-quotation-dto';
// @ts-ignore // @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
@@ -305,4 +307,72 @@ export class QuotationsService extends BaseService {
); );
} }
/**
* @endpoint put /API/quotations/{id}
* @param id
* @param updateQuotationDto
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public updateQuotationEndpoint(id: number, updateQuotationDto: UpdateQuotationDto, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<GetQuotationDto>;
public updateQuotationEndpoint(id: number, updateQuotationDto: UpdateQuotationDto, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<GetQuotationDto>>;
public updateQuotationEndpoint(id: number, updateQuotationDto: UpdateQuotationDto, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<GetQuotationDto>>;
public updateQuotationEndpoint(id: number, updateQuotationDto: UpdateQuotationDto, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling updateQuotationEndpoint.');
}
if (updateQuotationDto === null || updateQuotationDto === undefined) {
throw new Error('Required parameter updateQuotationDto was null or undefined when calling updateQuotationEndpoint.');
}
let localVarHeaders = this.defaultHeaders;
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
// to determine the Content-Type header
const consumes: string[] = [
'application/json'
];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected);
}
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/API/quotations/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int32"})}`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<GetQuotationDto>('put', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
body: updateQuotationDto,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
} }

View File

@@ -37,5 +37,6 @@ export * from './patch-ware-house-product-quantity-dto';
export * from './update-deliverer-dto'; export * from './update-deliverer-dto';
export * from './update-delivery-note-dto'; export * from './update-delivery-note-dto';
export * from './update-product-dto'; export * from './update-product-dto';
export * from './update-quotation-dto';
export * from './update-supplier-dto'; export * from './update-supplier-dto';
export * from './update-user-dto'; export * from './update-user-dto';

View File

@@ -0,0 +1,16 @@
/**
* PyroFetes
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export interface UpdateQuotationDto {
message?: string | null;
conditionsSale?: string | null;
}