From cb35f8e5952161753317f73970e73e407e182092 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Tue, 6 Apr 2021 10:51:41 -0400 Subject: [PATCH] =?UTF-8?q?Les=20produits=20dans=20l'=C3=A9diteur=20de=20m?= =?UTF-8?q?=C3=A9lange=20sont=20maintenant=20tri=C3=A9s.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mix-editor/mix-editor.component.html | 2 +- .../mix-editor/mix-editor.component.ts | 26 ++++++++++++++++++- .../material/service/material.service.ts | 4 +-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/app/modules/colors/components/mix-editor/mix-editor.component.html b/src/app/modules/colors/components/mix-editor/mix-editor.component.html index 34a267b..7417836 100644 --- a/src/app/modules/colors/components/mix-editor/mix-editor.component.html +++ b/src/app/modules/colors/components/mix-editor/mix-editor.component.html @@ -75,7 +75,7 @@ [value]="mixMaterial.materialId" (valueChange)="setMixMaterialMaterial(mixMaterial, $event)"> {{materialDisplayName(material)}} diff --git a/src/app/modules/colors/components/mix-editor/mix-editor.component.ts b/src/app/modules/colors/components/mix-editor/mix-editor.component.ts index 961e3dc..a0bdfef 100644 --- a/src/app/modules/colors/components/mix-editor/mix-editor.component.ts +++ b/src/app/modules/colors/components/mix-editor/mix-editor.component.ts @@ -4,7 +4,7 @@ import { MixMaterial, MixMaterialDto, mixMaterialsAsMixMaterialsDto, - Recipe, RecipeStep, + Recipe, sortMixMaterialsDto } from '../../../shared/model/recipe.model' import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component' @@ -162,6 +162,30 @@ export class MixEditorComponent extends ErrorHandlingComponent { return material.name } + sortedMaterials(materials: Material[]): Material[] { + return materials.sort((a, b) => { + const aPrefixName = a.materialType.prefix.toLowerCase() + const bPrefixName = b.materialType.prefix.toLowerCase() + + if (aPrefixName < bPrefixName) { + return -1 + } else if (aPrefixName > bPrefixName) { + return 1 + } else { + const aName = a.name.toLowerCase() + const bName = b.name.toLowerCase() + + if (aName < bName) { + return -1 + } else if (aName > bName) { + return 1 + } else { + return 0 + } + } + }) + } + get canDeleteMix() { return this.accountService.hasPermission(EmployeePermission.REMOVE_RECIPES) } diff --git a/src/app/modules/material/service/material.service.ts b/src/app/modules/material/service/material.service.ts index ddf0ca4..709f0f1 100644 --- a/src/app/modules/material/service/material.service.ts +++ b/src/app/modules/material/service/material.service.ts @@ -45,7 +45,7 @@ export class MaterialService { const body = new FormData() body.append('name', name) body.append('inventoryQuantity', inventoryQuantity.toString()) - body.append('materialType', materialType.toString()) + body.append('materialTypeId', materialType.toString()) if (simdutFile && simdutFile.files) { body.append('simdutFile', simdutFile.files[0]) } @@ -57,7 +57,7 @@ export class MaterialService { body.append('id', id.toString()) body.append('name', name) body.append('inventoryQuantity', inventoryQuantity.toString()) - body.append('materialType', materialType.toString()) + body.append('materialTypeId', materialType.toString()) if (simdutFile) { body.append('simdutFile', simdutFile) }