Compare commits
2 Commits
3c8abbb600
...
750a0da817
| Author | SHA1 | Date | |
|---|---|---|---|
| 750a0da817 | |||
| a707a33a87 |
@@ -79,20 +79,12 @@ export class DelivererTable implements OnInit {
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
const deliverers = updateDelivererComponent.delivererForm.getRawValue();
|
||||
await firstValueFrom(this.deliverersService.updateDelivererEndpoint(id, deliverers))
|
||||
|
||||
this.notificationService.success(
|
||||
'Success',
|
||||
'Transporteur modifié'
|
||||
)
|
||||
this.notificationService.success('Success', 'Transporteur modifié')
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
this.notificationService.error(
|
||||
'Erreur',
|
||||
'Erreur lors de la modification'
|
||||
)
|
||||
this.notificationService.error('Erreur', 'Erreur lors de la modification')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,25 +116,6 @@ 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', '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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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-label nzSpan="9">
|
||||
Message du devis
|
||||
</nz-form-label>
|
||||
|
||||
<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-item>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</nz-form-label>
|
||||
|
||||
<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-item>
|
||||
</form>
|
||||
|
||||
@@ -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 {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
||||
import {NzInputDirective} from "ng-zorro-antd/input";
|
||||
import {NzColDirective} from "ng-zorro-antd/grid";
|
||||
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
||||
import {NzDatePickerComponent} from "ng-zorro-antd/date-picker";
|
||||
import {GetQuotationDto} from "../../services/api";
|
||||
|
||||
@Component({
|
||||
selector: 'app-quotation-form',
|
||||
@@ -22,8 +22,20 @@ import {NzDatePickerComponent} from "ng-zorro-antd/date-picker";
|
||||
styleUrl: './quotation-form.css',
|
||||
})
|
||||
export class QuotationForm {
|
||||
QuotationForm: FormGroup = new FormGroup({
|
||||
quotationMessage: new FormControl<string>(null),
|
||||
quotationConditionsSale: new FormControl<string>(null),
|
||||
quotationForm: FormGroup = new FormGroup({
|
||||
message: new FormControl<string>(null, [Validators.required]),
|
||||
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,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,21 +52,13 @@
|
||||
</td>
|
||||
<td>
|
||||
<div style="justify-content: center; display: flex">
|
||||
<div>
|
||||
<nz-icon nzType="plus-circle" nzTheme="outline" class="cursor-pointer text-green-700" />
|
||||
</div>
|
||||
<nz-icon nzType="plus-circle" nzTheme="outline" class="cursor-pointer text-green-700" />
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<app-modal-nav nameIcon="edit" name="Modification du devis" class="cursor-pointer">
|
||||
<app-quotation-form></app-quotation-form>
|
||||
</app-modal-nav>
|
||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer" (click)="openEditModal(quotation)"></nz-icon>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<div>
|
||||
<nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-700" (click)="delete(quotation.id)"/>
|
||||
</div>
|
||||
<nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-700" (click)="delete(quotation.id)"/>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<div>
|
||||
<nz-icon nzType="export" (click)="export(quotation.id)" nzTheme="outline" class="cursor-pointer text-green-700"/>
|
||||
</div>
|
||||
<nz-icon nzType="export" (click)="export(quotation.id)" nzTheme="outline" class="cursor-pointer text-green-700"/>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -74,3 +66,8 @@
|
||||
</tbody>
|
||||
</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>
|
||||
@@ -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 {ModalButton} from "../modal-button/modal-button";
|
||||
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 {firstValueFrom} from "rxjs";
|
||||
import {FileService} from "../../services/file.service";
|
||||
import {DelivereryNoteForm} from "../deliverery-note-form/deliverery-note-form";
|
||||
|
||||
@Component({
|
||||
selector: 'app-quotation-table',
|
||||
@@ -19,6 +20,7 @@ import {FileService} from "../../services/file.service";
|
||||
NzIconDirective,
|
||||
NzTableComponent,
|
||||
QuotationForm,
|
||||
DelivereryNoteForm,
|
||||
],
|
||||
templateUrl: './quotation-table.html',
|
||||
styleUrl: './quotation-table.css',
|
||||
@@ -30,6 +32,7 @@ export class QuotationTable implements OnInit {
|
||||
private fileService = inject(FileService);
|
||||
quotations = signal<GetQuotationDto[]>([]);
|
||||
quotationsLoading = signal<boolean>(false);
|
||||
modal = viewChild.required<ModalNav>('modalNav');
|
||||
|
||||
async ngOnInit() {
|
||||
await this.fetchQuotations();
|
||||
@@ -84,5 +87,40 @@ export class QuotationTable implements OnInit {
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ model/patch-ware-house-product-quantity-dto.ts
|
||||
model/update-deliverer-dto.ts
|
||||
model/update-delivery-note-dto.ts
|
||||
model/update-product-dto.ts
|
||||
model/update-quotation-dto.ts
|
||||
model/update-supplier-dto.ts
|
||||
model/update-user-dto.ts
|
||||
param.ts
|
||||
|
||||
@@ -20,6 +20,8 @@ import { Observable } from 'rxjs';
|
||||
import { GetQuotationDto } from '../model/get-quotation-dto';
|
||||
// @ts-ignore
|
||||
import { PatchQuotationConditionsSaleDto } from '../model/patch-quotation-conditions-sale-dto';
|
||||
// @ts-ignore
|
||||
import { UpdateQuotationDto } from '../model/update-quotation-dto';
|
||||
|
||||
// @ts-ignore
|
||||
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
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,5 +37,6 @@ export * from './patch-ware-house-product-quantity-dto';
|
||||
export * from './update-deliverer-dto';
|
||||
export * from './update-delivery-note-dto';
|
||||
export * from './update-product-dto';
|
||||
export * from './update-quotation-dto';
|
||||
export * from './update-supplier-dto';
|
||||
export * from './update-user-dto';
|
||||
|
||||
16
src/app/services/api/model/update-quotation-dto.ts
Normal file
16
src/app/services/api/model/update-quotation-dto.ts
Normal 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user