From d49e013405f324a2ddfc6208d09f93fd017a131b Mon Sep 17 00:00:00 2001 From: FyloZ Date: Sun, 30 May 2021 21:44:04 -0400 Subject: [PATCH] Correction de la pastille de couleur dans la liste des recettes --- .../shared/components/inputs/checkbox.html | 7 ++- .../shared/components/inputs/inputs.module.ts | 19 +++--- .../shared/components/inputs/inputs.ts | 3 + src/app/modules/shared/model/config.model.ts | 1 + .../shared/model/touch-up-kit.model.ts | 5 +- .../modules/touch-up-kit/components/form.ts | 2 + .../touch-up-kit/components/product-editor.ts | 3 +- .../modules/touch-up-kit/pages/banner.html | 1 + .../modules/touch-up-kit/pages/details.html | 29 +++++++-- src/app/modules/touch-up-kit/pages/list.html | 57 ++++++++++++++++- .../modules/touch-up-kit/pages/touchupkit.ts | 61 ++++++++++++++++++- .../service/touch-up-kit.service.ts | 6 +- src/styles.sass | 11 ++++ 13 files changed, 185 insertions(+), 20 deletions(-) diff --git a/src/app/modules/shared/components/inputs/checkbox.html b/src/app/modules/shared/components/inputs/checkbox.html index dbadabf..54370a5 100644 --- a/src/app/modules/shared/components/inputs/checkbox.html +++ b/src/app/modules/shared/components/inputs/checkbox.html @@ -1,3 +1,6 @@ - - {{label}} +{{label}} + diff --git a/src/app/modules/shared/components/inputs/inputs.module.ts b/src/app/modules/shared/components/inputs/inputs.module.ts index 17a81fb..23d624e 100644 --- a/src/app/modules/shared/components/inputs/inputs.module.ts +++ b/src/app/modules/shared/components/inputs/inputs.module.ts @@ -42,15 +42,16 @@ import {MatCheckboxModule} from '@angular/material/checkbox' CreButtonsModule, MatCheckboxModule, ], - exports: [ - CreInputComponent, - CreComboBoxComponent, - CreChipComboBoxComponent, - CreChipInputComponent, - CreAutocompleteInputComponent, - CreFileInputComponent, - CreBoolConfig - ] + exports: [ + CreInputComponent, + CreComboBoxComponent, + CreChipComboBoxComponent, + CreChipInputComponent, + CreAutocompleteInputComponent, + CreFileInputComponent, + CreBoolConfig, + CreCheckboxInputComponent + ] }) export class CreInputsModule { } diff --git a/src/app/modules/shared/components/inputs/inputs.ts b/src/app/modules/shared/components/inputs/inputs.ts index b9ba3ac..bff4c27 100644 --- a/src/app/modules/shared/components/inputs/inputs.ts +++ b/src/app/modules/shared/components/inputs/inputs.ts @@ -187,6 +187,9 @@ export class CreChipComboBoxComponent extends CreChipInputComponent implements O export class CreCheckboxInputComponent { @Input() label: string @Input() control: FormControl + @Input() checked: boolean + + @Output() checkedChange = new EventEmitter() } @Component({ diff --git a/src/app/modules/shared/model/config.model.ts b/src/app/modules/shared/model/config.model.ts index 2d96d4d..6144c2a 100644 --- a/src/app/modules/shared/model/config.model.ts +++ b/src/app/modules/shared/model/config.model.ts @@ -8,6 +8,7 @@ export class Config { static readonly DATABASE_PASSWORD = 'database.password' static readonly DATABASE_VERSION = 'database.version.supported' static readonly TOUCH_UP_KIT_CACHE_PDF = 'touchupkit.pdf.cache' + static readonly TOUCH_UP_KIT_EXPIRATION = 'touchupkit.expiration' static readonly EMERGENCY_MODE = 'env.emergency' static readonly APP_VERSION = 'env.version' static readonly JAVA_VERSION = 'env.java.version' diff --git a/src/app/modules/shared/model/touch-up-kit.model.ts b/src/app/modules/shared/model/touch-up-kit.model.ts index df625e5..7cf0850 100644 --- a/src/app/modules/shared/model/touch-up-kit.model.ts +++ b/src/app/modules/shared/model/touch-up-kit.model.ts @@ -6,6 +6,8 @@ export class TouchUpKit { public company: string, public quantity: number, public shippingDate: string, + public completed: boolean, + public completionDate: string, public finish: string[], public material: string[], public content: TouchUpKitProduct[] @@ -18,7 +20,8 @@ export class TouchUpKitProduct { public id: number, public name: string, public description: string | null, - public quantity: number + public quantity: number, + public ready: boolean ) { } } diff --git a/src/app/modules/touch-up-kit/components/form.ts b/src/app/modules/touch-up-kit/components/form.ts index 6340f72..0a77b7f 100644 --- a/src/app/modules/touch-up-kit/components/form.ts +++ b/src/app/modules/touch-up-kit/components/form.ts @@ -65,6 +65,8 @@ export class TouchUpKitForm extends SubscribingComponent { company: this.controls.company.value, quantity: this.controls.quantity.value, shippingDate: this.controls.shippingDate.value, + completed: false, + completionDate: null, finish: this.selectedFinish, material: this.selectedMaterial, content: this.touchUpKitContent diff --git a/src/app/modules/touch-up-kit/components/product-editor.ts b/src/app/modules/touch-up-kit/components/product-editor.ts index ea2d840..9ea7c89 100644 --- a/src/app/modules/touch-up-kit/components/product-editor.ts +++ b/src/app/modules/touch-up-kit/components/product-editor.ts @@ -51,7 +51,8 @@ export class TouchUpKitProductEditor implements OnInit { id: null, name: '', description: '', - quantity: 1 + quantity: 1, + ready: false } } } diff --git a/src/app/modules/touch-up-kit/pages/banner.html b/src/app/modules/touch-up-kit/pages/banner.html index 4da19bc..531f9dc 100644 --- a/src/app/modules/touch-up-kit/pages/banner.html +++ b/src/app/modules/touch-up-kit/pages/banner.html @@ -14,6 +14,7 @@

Matériel: {{material}}

+ Complété le {{completionDate}} diff --git a/src/app/modules/touch-up-kit/pages/details.html b/src/app/modules/touch-up-kit/pages/details.html index 99bbb6c..bb5b358 100644 --- a/src/app/modules/touch-up-kit/pages/details.html +++ b/src/app/modules/touch-up-kit/pages/details.html @@ -1,10 +1,18 @@
-
- - -
+ + + Retour + PDF + + + Enregistrer + + Compléter + + + @@ -24,5 +32,18 @@ Quantité {{product.quantity}} + + + Prêt + + + + + + +
diff --git a/src/app/modules/touch-up-kit/pages/list.html b/src/app/modules/touch-up-kit/pages/list.html index e5fc496..1cb372b 100644 --- a/src/app/modules/touch-up-kit/pages/list.html +++ b/src/app/modules/touch-up-kit/pages/list.html @@ -5,7 +5,7 @@ - + Project {{touchUpKit.project}} @@ -51,3 +51,58 @@ + + + + Kits de retouche complétés + + + + + Project + {{touchUpKit.project}} + + + + Chariot + {{touchUpKit.buggy}} + + + + Bannière + {{touchUpKit.company}} + + + + Date de livraison + {{shippingDate(touchUpKit)}} + + + + Date de complétion + {{completionDate(touchUpKit)}} + + + + Date d'expiration + {{expirationDate(touchUpKit)}} + + + + + + PDF + + + + + + + + Détails + + + + + + diff --git a/src/app/modules/touch-up-kit/pages/touchupkit.ts b/src/app/modules/touch-up-kit/pages/touchupkit.ts index 2f6b60c..57b3ed5 100644 --- a/src/app/modules/touch-up-kit/pages/touchupkit.ts +++ b/src/app/modules/touch-up-kit/pages/touchupkit.ts @@ -9,6 +9,10 @@ import {ActivatedRoute, Router} from '@angular/router' import {Permission} from '../../shared/model/user' import {RecipeService} from '../../colors/services/recipe.service' import {AppState} from '../../shared/app-state' +import {map} from 'rxjs/operators' +import {LocalDate, Period} from 'js-joda' +import {ConfigService} from '../../shared/service/config.service' +import {Config} from '../../shared/model/config.model' @Component({ selector: 'touchupkit-banner', @@ -24,6 +28,10 @@ export class TouchUpKitBanner { return formatDate(this.touchUpKit.shippingDate) } + get completionDate(): string { + return formatDate(this.touchUpKit.completionDate) + } + get material(): string { return reduceDashes(this.touchUpKit.material) } @@ -35,11 +43,21 @@ export class TouchUpKitBanner { }) export class TouchUpKitList extends ErrorHandlingComponent { touchUpKits$ = this.touchUpKitService.all + completedTouchUpKits$ = this.touchUpKits$.pipe( + map(kits => kits.filter(k => k.completed)) + ) + uncompletedTouchUpKits$ = this.touchUpKits$.pipe( + map(kits => kits.filter(k => !k.completed)) + ) + expirationPeriod: Period | null + columns = ['project', 'buggy', 'company', 'shippingDate', 'pdfButton', 'detailsButton', 'editButton'] + completedColumns = ['project', 'buggy', 'company', 'shippingDate', 'completionDate', 'expirationDate', 'pdfButton', 'detailsButton'] constructor( private touchUpKitService: TouchUpKitService, private accountService: AccountService, + private configService: ConfigService, private appState: AppState, errorService: ErrorService, router: Router, @@ -49,10 +67,32 @@ export class TouchUpKitList extends ErrorHandlingComponent { this.appState.title = 'Kits de retouche' } + ngOnInit() { + super.ngOnInit() + + this.subscribe( + this.configService.get(Config.TOUCH_UP_KIT_EXPIRATION), + config => this.expirationPeriod = Period.parse(config.content) + ) + } + openTouchUpKitPdf(touchUpKit: TouchUpKit) { openTouchUpKit(touchUpKit) } + shippingDate(touchUpKit: TouchUpKit): string { + return formatDate(touchUpKit.shippingDate) + } + + completionDate(touchUpKit: TouchUpKit): string { + return formatDate(touchUpKit.completionDate) + } + + expirationDate(touchUpKit: TouchUpKit): string { + const completionDate = LocalDate.parse(touchUpKit.completionDate) + return formatDate(completionDate.plus(this.expirationPeriod).toString()) + } + get canEditTouchUpKits(): boolean { return this.accountService.hasPermission(Permission.EDIT_TOUCH_UP_KITS) } @@ -64,11 +104,12 @@ export class TouchUpKitList extends ErrorHandlingComponent { }) export class TouchUpKitDetails extends ErrorHandlingComponent { touchUpKit: TouchUpKit | null - contentTableCols = ['name', 'description', 'quantity'] + contentTableCols = ['name', 'description', 'quantity', 'ready'] constructor( private touchUpKitService: TouchUpKitService, private recipeService: RecipeService, + private accountService: AccountService, private appState: AppState, errorService: ErrorService, activatedRoute: ActivatedRoute, @@ -93,6 +134,24 @@ export class TouchUpKitDetails extends ErrorHandlingComponent { openPdf() { openTouchUpKit(this.touchUpKit) } + + save() { + this.subscribeAndNavigate( + this.touchUpKitService.update(this.touchUpKit), + `/misc/touch-up-kit/details/${this.touchUpKit.id}` + ) + } + + complete() { + this.subscribeAndNavigate( + this.touchUpKitService.complete(this.touchUpKit), + '/misc/touch-up-kit' + ) + } + + get canEditTouchUpKits(): boolean { + return this.accountService.hasPermission(Permission.EDIT_TOUCH_UP_KITS) + } } @Component({ diff --git a/src/app/modules/touch-up-kit/service/touch-up-kit.service.ts b/src/app/modules/touch-up-kit/service/touch-up-kit.service.ts index 18aa7b2..99707d3 100644 --- a/src/app/modules/touch-up-kit/service/touch-up-kit.service.ts +++ b/src/app/modules/touch-up-kit/service/touch-up-kit.service.ts @@ -1,7 +1,7 @@ import {Injectable} from '@angular/core' import {ApiService} from '../../shared/service/api.service' import {Observable} from 'rxjs' -import {TouchUpKit, TouchUpKitProduct} from '../../shared/model/touch-up-kit.model' +import {TouchUpKit} from '../../shared/model/touch-up-kit.model' @Injectable({ providedIn: 'root' @@ -28,6 +28,10 @@ export class TouchUpKitService { return this.api.put('/touchupkit', touchUpKit) } + complete(touchUpKit: TouchUpKit): Observable { + return this.api.put(`/touchupkit/${touchUpKit.id}/complete`) + } + delete(id: number): Observable { return this.api.delete(`/touchupkit/${id}`) } diff --git a/src/styles.sass b/src/styles.sass index 218755c..e026f75 100644 --- a/src/styles.sass +++ b/src/styles.sass @@ -41,6 +41,17 @@ mat-card text-transform: uppercase letter-spacing: 1.25px + &.named-table mat-card-content + margin: 0 + padding: 0 + + table + border: none + box-shadow: none + + th + border-radius: 0 !important + table box-shadow: 0 2px 1px -1px rgba(0, 0, 0, 0.2), 0 1px 1px 0 rgba(0, 0, 0, 0.14), 0 1px 3px 0 rgba(0, 0, 0, 0.12) max-width: 90vw