From 4929dd7262fb89f660d3487c3f7a902150bc87ad Mon Sep 17 00:00:00 2001 From: FyloZ Date: Thu, 1 Apr 2021 16:58:22 -0400 Subject: [PATCH 1/6] =?UTF-8?q?La=20valeur=20par=20d=C3=A9faut=20du=20lust?= =?UTF-8?q?re=20d'une=20recette=20est=20maintenant=200.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/modules/colors/pages/add/add.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/modules/colors/pages/add/add.component.ts b/src/app/modules/colors/pages/add/add.component.ts index 4b98990..f79b33f 100644 --- a/src/app/modules/colors/pages/add/add.component.ts +++ b/src/app/modules/colors/pages/add/add.component.ts @@ -52,7 +52,7 @@ export class AddComponent extends ErrorHandlingComponent { type: 'slider', min: 0, max: 100, - defaultValue: 10, + defaultValue: 0, required: true, errorMessages: [ {conditionFn: errors => errors.required, message: 'Le lustre de la couleur est requis'} From ebfd4c96964c2e9bdb5c33eb42b8b270f9bcb8f8 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Thu, 1 Apr 2021 17:02:59 -0400 Subject: [PATCH 2/6] =?UTF-8?q?Correction=20d'une=20erreur=20dans=20l'?= =?UTF-8?q?=C3=A9diteur=20de=20recette.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` can't access property "name", ctx.recipe is undefined (edit.component.html:55) ``` --- src/app/modules/colors/pages/edit/edit.component.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/modules/colors/pages/edit/edit.component.html b/src/app/modules/colors/pages/edit/edit.component.html index 8ec157a..2c6c22a 100644 --- a/src/app/modules/colors/pages/edit/edit.component.html +++ b/src/app/modules/colors/pages/edit/edit.component.html @@ -52,4 +52,8 @@ - + + From eef6eea40e67db62cb09c4deda1c91ce88866ab9 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Thu, 1 Apr 2021 17:15:38 -0400 Subject: [PATCH 3/6] =?UTF-8?q?Correction=20d'un=20bug=20qui=20emp=C3=AAch?= =?UTF-8?q?ait=20la=20recherche=20de=20recette=20de=20fonctionner.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/modules/colors/pages/list/list.component.html | 10 +++++++--- src/app/modules/colors/pages/list/list.component.ts | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/modules/colors/pages/list/list.component.html b/src/app/modules/colors/pages/list/list.component.html index 72e59aa..6c00852 100644 --- a/src/app/modules/colors/pages/list/list.component.html +++ b/src/app/modules/colors/pages/list/list.component.html @@ -11,8 +11,11 @@ - + {{companyRecipes.company}} @@ -40,7 +43,8 @@ Couleur -
+
diff --git a/src/app/modules/colors/pages/list/list.component.ts b/src/app/modules/colors/pages/list/list.component.ts index 0476275..68fd86e 100644 --- a/src/app/modules/colors/pages/list/list.component.ts +++ b/src/app/modules/colors/pages/list/list.component.ts @@ -41,7 +41,7 @@ export class ListComponent extends ErrorHandlingComponent { } const positive = this.searchString(recipe.name) || this.searchString(recipe.description) || - this.searchString(recipe.sample.toString()) + (recipe.sample && this.searchString(recipe.sample.toString())) this.recipesHidden[recipe.id] = !positive return positive } From fb28c63867fac4b0f32d06861377a6d411ef6a11 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Thu, 1 Apr 2021 17:29:34 -0400 Subject: [PATCH 4/6] =?UTF-8?q?Correction=20de=20l'erreur=20de=20d=C3=A9te?= =?UTF-8?q?ction=20des=20changements=20lors=20d'une=20recherche=20dans=20l?= =?UTF-8?q?a=20liste=20des=20recettes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../colors/pages/list/list.component.html | 17 ++++++-- .../colors/pages/list/list.component.ts | 39 ++++++++++++------- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/app/modules/colors/pages/list/list.component.html b/src/app/modules/colors/pages/list/list.component.html index 6c00852..3d536af 100644 --- a/src/app/modules/colors/pages/list/list.component.html +++ b/src/app/modules/colors/pages/list/list.component.html @@ -1,8 +1,17 @@
Recherche - - @@ -13,7 +22,7 @@ @@ -84,6 +93,6 @@ - + diff --git a/src/app/modules/colors/pages/list/list.component.ts b/src/app/modules/colors/pages/list/list.component.ts index 68fd86e..5000b6a 100644 --- a/src/app/modules/colors/pages/list/list.component.ts +++ b/src/app/modules/colors/pages/list/list.component.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core' +import {ChangeDetectorRef, Component} from '@angular/core' import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component' import {RecipeService} from '../../services/recipe.service' import {EmployeePermission} from '../../../shared/model/employee' @@ -13,17 +13,18 @@ import {ErrorModel, ErrorService} from '../../../shared/service/error.service' styleUrls: ['./list.component.sass'] }) export class ListComponent extends ErrorHandlingComponent { - recipes$ = this.recipeService.allSortedByCompany + recipes: { company: string, recipes: Recipe[] }[] = [] tableCols = ['name', 'description', 'color', 'gloss', 'sample', 'iconNotApproved', 'buttonView', 'buttonEdit'] - searchQuery = "" + searchQuery = '' panelForcedExpanded = false - recipesHidden = [] + hiddenRecipes = [] handledErrorModels: ErrorModel[] constructor( private recipeService: RecipeService, private accountService: AccountService, + private cdRef: ChangeDetectorRef, errorService: ErrorService, router: Router, activatedRoute: ActivatedRoute @@ -32,22 +33,27 @@ export class ListComponent extends ErrorHandlingComponent { } ngOnInit() { - super.ngOnInit(); + super.ngOnInit() + + this.subscribe( + this.recipeService.allSortedByCompany, + recipes => this.recipes = recipes + ) } - searchRecipe(recipe: Recipe) { - if (this.searchQuery.length > 0) { + searchRecipes() { + if (this.searchQuery.length > 0 && !this.panelForcedExpanded) { this.panelForcedExpanded = true + this.cdRef.detectChanges() } - const positive = this.searchString(recipe.name) || - this.searchString(recipe.description) || - (recipe.sample && this.searchString(recipe.sample.toString())) - this.recipesHidden[recipe.id] = !positive - return positive + + this.recipes + .flatMap(r => r.recipes) + .forEach(r => this.recipeMatchesSearchQuery(r)) } isCompanyHidden(companyRecipes: Recipe[]): boolean { - return (this.searchQuery && this.searchQuery.length > 0) && companyRecipes.map(r => this.recipesHidden[r.id]).filter(r => !r).length <= 0 + return (this.searchQuery && this.searchQuery.length > 0) && companyRecipes.map(r => this.hiddenRecipes[r.id]).filter(r => !r).length <= 0 } isLightColor(recipe: Recipe): boolean { @@ -66,6 +72,13 @@ export class ListComponent extends ErrorHandlingComponent { return this.accountService.hasPermission(EmployeePermission.EDIT_RECIPE) } + private recipeMatchesSearchQuery(recipe: Recipe) { + const matches = this.searchString(recipe.name) || + this.searchString(recipe.description) || + (recipe.sample && this.searchString(recipe.sample.toString())) + this.hiddenRecipes[recipe.id] = !matches + } + private searchString(value: string): boolean { return value.toLowerCase().indexOf(this.searchQuery.toLowerCase()) >= 0 } From 6666bb2f1a52492f791ba024ac7c6d7ef5de2a83 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Thu, 1 Apr 2021 17:32:53 -0400 Subject: [PATCH 5/6] =?UTF-8?q?G=C3=A9n=C3=A9ralisation=20de=20la=20foncti?= =?UTF-8?q?on=20getRecipeLuma()=20qui=20=C3=A9tait=20dupliqu=C3=A9e=20dans?= =?UTF-8?q?=20plusieurs=20composants.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recipe-info/recipe-info.component.html | 2 +- .../recipe-info/recipe-info.component.ts | 14 +++----------- .../modules/colors/pages/list/list.component.html | 2 +- .../modules/colors/pages/list/list.component.ts | 14 +++----------- src/app/modules/shared/model/recipe.model.ts | 11 +++++++++++ 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/app/modules/colors/components/recipe-info/recipe-info.component.html b/src/app/modules/colors/components/recipe-info/recipe-info.component.html index 6fd3a80..cf8819f 100644 --- a/src/app/modules/colors/components/recipe-info/recipe-info.component.html +++ b/src/app/modules/colors/components/recipe-info/recipe-info.component.html @@ -3,7 +3,7 @@

{{recipe.company.name}} - {{recipe.name}}

{{recipe.gloss}}%
diff --git a/src/app/modules/colors/components/recipe-info/recipe-info.component.ts b/src/app/modules/colors/components/recipe-info/recipe-info.component.ts index f87ef6a..6ff2509 100644 --- a/src/app/modules/colors/components/recipe-info/recipe-info.component.ts +++ b/src/app/modules/colors/components/recipe-info/recipe-info.component.ts @@ -1,5 +1,5 @@ import {AfterViewInit, Component, Input} from '@angular/core' -import {Recipe} from '../../../shared/model/recipe.model' +import {getRecipeLuma, Recipe} from '../../../shared/model/recipe.model' @Component({ selector: 'cre-recipe-info', @@ -17,15 +17,7 @@ export class RecipeInfoComponent implements AfterViewInit { this.isBPacExtensionInstalled = document.querySelectorAll('.bpac-extension-installed').length > 0 } - get darkColor(): boolean { - // https://stackoverflow.com/questions/12043187/how-to-check-if-hex-color-is-too-black - const c = this.recipe.color.substring(1) // strip # - const rgb = parseInt(c, 16) // convert rrggbb to decimal - const r = (rgb >> 16) & 0xff // extract red - const g = (rgb >> 8) & 0xff // extract green - const b = (rgb >> 0) & 0xff // extract blue - - const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b // per ITU-R BT.709 - return luma < 100 + get isDarkColor(): boolean { + return getRecipeLuma(this.recipe) < 100 } } diff --git a/src/app/modules/colors/pages/list/list.component.html b/src/app/modules/colors/pages/list/list.component.html index 3d536af..2116ae1 100644 --- a/src/app/modules/colors/pages/list/list.component.html +++ b/src/app/modules/colors/pages/list/list.component.html @@ -52,7 +52,7 @@ Couleur -
diff --git a/src/app/modules/colors/pages/list/list.component.ts b/src/app/modules/colors/pages/list/list.component.ts index 5000b6a..a877447 100644 --- a/src/app/modules/colors/pages/list/list.component.ts +++ b/src/app/modules/colors/pages/list/list.component.ts @@ -3,7 +3,7 @@ import {ErrorHandlingComponent} from '../../../shared/components/subscribing.com import {RecipeService} from '../../services/recipe.service' import {EmployeePermission} from '../../../shared/model/employee' import {AccountService} from '../../../accounts/services/account.service' -import {Recipe} from '../../../shared/model/recipe.model' +import {getRecipeLuma, Recipe} from '../../../shared/model/recipe.model' import {ActivatedRoute, Router} from '@angular/router' import {ErrorModel, ErrorService} from '../../../shared/service/error.service' @@ -56,16 +56,8 @@ export class ListComponent extends ErrorHandlingComponent { return (this.searchQuery && this.searchQuery.length > 0) && companyRecipes.map(r => this.hiddenRecipes[r.id]).filter(r => !r).length <= 0 } - isLightColor(recipe: Recipe): boolean { - // https://stackoverflow.com/questions/12043187/how-to-check-if-hex-color-is-too-black - const c = recipe.color.substring(1) // strip # - const rgb = parseInt(c, 16) // convert rrggbb to decimal - const r = (rgb >> 16) & 0xff // extract red - const g = (rgb >> 8) & 0xff // extract green - const b = (rgb >> 0) & 0xff // extract blue - - const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b // per ITU-R BT.709 - return luma > 200 + isLight(recipe: Recipe): boolean { + return getRecipeLuma(recipe) > 200 } get hasEditPermission(): boolean { diff --git a/src/app/modules/shared/model/recipe.model.ts b/src/app/modules/shared/model/recipe.model.ts index 3355946..9e9c13c 100644 --- a/src/app/modules/shared/model/recipe.model.ts +++ b/src/app/modules/shared/model/recipe.model.ts @@ -113,3 +113,14 @@ export function sortMixMaterialsDto(mixMaterials: MixMaterialDto[]): MixMaterial return mixMaterials.sort((a, b) => a.position - b.position) } +export function getRecipeLuma(recipe: Recipe): number { + // https://stackoverflow.com/questions/12043187/how-to-check-if-hex-color-is-too-black + const c = recipe.color.substring(1) // strip # + const rgb = parseInt(c, 16) // convert rrggbb to decimal + const r = (rgb >> 16) & 0xff // extract red + const g = (rgb >> 8) & 0xff // extract green + const b = (rgb >> 0) & 0xff // extract blue + + return 0.2126 * r + 0.7152 * g + 0.0722 * b // per ITU-R BT.709 +} + From 0135c457fa560e968c9f7c2011dca46f55920572 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Thu, 1 Apr 2021 17:36:55 -0400 Subject: [PATCH 6/6] =?UTF-8?q?R=C3=A9arrangement=20du=20code=20de=20l'?= =?UTF-8?q?=C3=A9diteur=20de=20recette.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../colors/pages/edit/edit.component.html | 16 +++++++++++++--- .../entity-edit/entity-edit.component.ts | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/app/modules/colors/pages/edit/edit.component.html b/src/app/modules/colors/pages/edit/edit.component.html index 2c6c22a..6e15d0a 100644 --- a/src/app/modules/colors/pages/edit/edit.component.html +++ b/src/app/modules/colors/pages/edit/edit.component.html @@ -3,10 +3,20 @@
- + -
Unités diff --git a/src/app/modules/shared/components/entity-edit/entity-edit.component.ts b/src/app/modules/shared/components/entity-edit/entity-edit.component.ts index 04374fe..41864b1 100644 --- a/src/app/modules/shared/components/entity-edit/entity-edit.component.ts +++ b/src/app/modules/shared/components/entity-edit/entity-edit.component.ts @@ -1,4 +1,4 @@ -import {Component, EventEmitter, Input, Output} from '@angular/core' +import {ChangeDetectorRef, Component, EventEmitter, Input, Output} from '@angular/core' import {FormBuilder, FormControl, FormGroup} from '@angular/forms' import {FormField} from '../entity-add/entity-add.component' import {EmployeePermission} from '../../model/employee'