From 67a8c361ddac8f6379efde724607f841b04677f7 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Mon, 9 Mar 2020 20:07:44 -0400 Subject: [PATCH] =?UTF-8?q?Correction:=20Aucune=20validation=20lors=20de?= =?UTF-8?q?=20la=20cr=C3=A9ation=20d'un=20type=20de=20produit=20Correction?= =?UTF-8?q?:=20Impossible=20de=20cr=C3=A9er=20des=20PDFs=20de=20kit=20de?= =?UTF-8?q?=20retouche=20Correction:=20L'ic=C3=B4ne=20de=20l'imprimante=20?= =?UTF-8?q?n'est=20pas=20toujours=20actualis=C3=A9e=20lorsque=20l'extensio?= =?UTF-8?q?n=20bPac=20est=20install=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/model/MaterialTypeService.java | 13 +++++++++++- .../core/utils/PdfBuilder.java | 2 +- .../MaterialTypeCreatorController.java | 7 ++++++- src/main/resources/static/js/main.js | 21 ++++++++++++------- src/main/resources/templates/touchup.html | 2 +- src/main/resources/updates.md | 4 ++++ 6 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MaterialTypeService.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MaterialTypeService.java index b799954..75b6d4b 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MaterialTypeService.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MaterialTypeService.java @@ -12,6 +12,7 @@ import dev.fyloz.trial.colorrecipesexplorer.dao.MaterialTypeDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.validation.constraints.NotNull; import java.util.LinkedList; import java.util.List; import java.util.Optional; @@ -110,12 +111,22 @@ public class MaterialTypeService extends AbstractService found = dao.findByName(name); - if(found.isEmpty()) + if (found.isEmpty()) throw new EntityNotFoundException(type, ModelException.IdentifierType.NAME, name); return found.get(); } + @Override + public MaterialType save(@NotNull MaterialType materialType) { + if (existsByName(materialType.getName())) + throw new EntityAlreadyExistsException(type, ModelException.IdentifierType.NAME, materialType.getName()); + if (existsByPrefix(materialType.getPrefix())) + throw new EntityAlreadyExistsException(type, ModelException.IdentifierType.OTHER, MaterialType.IDENTIFIER_PREFIX_NAME, materialType.getPrefix()); + + return super.save(materialType); + } + public MaterialType update(MaterialTypeEditorDto materialTypeDto) { MaterialType materialType = materialTypeDto.getMaterialType(); diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/utils/PdfBuilder.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/utils/PdfBuilder.java index 42050a4..8abb2f7 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/utils/PdfBuilder.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/utils/PdfBuilder.java @@ -33,7 +33,7 @@ public class PdfBuilder { this.lineSpacing = (int) (this.fontSize * 1.5f); document.addPage(page); - font = PDType0Font.load(document, resourceLoader.getResource(WebsitePaths.FONT_ARIAL_BOLD).getFile()); + font = PDType0Font.load(document, resourceLoader.getResource(WebsitePaths.FONT_ARIAL_BOLD).getInputStream()); } public PdfBuilder addLine(String text, boolean bold, int marginTop) { diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/MaterialTypeCreatorController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/MaterialTypeCreatorController.java index 9ca54bb..3235c97 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/MaterialTypeCreatorController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/MaterialTypeCreatorController.java @@ -1,6 +1,7 @@ package dev.fyloz.trial.colorrecipesexplorer.web.controller.creators; import dev.fyloz.trial.colorrecipesexplorer.core.exception.model.EntityAlreadyExistsException; +import dev.fyloz.trial.colorrecipesexplorer.core.exception.model.ModelException; import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ModelResponseBuilder; import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ResponseCode; import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ResponseDataType; @@ -48,7 +49,11 @@ public class MaterialTypeCreatorController { null ); } catch (EntityAlreadyExistsException ex) { - modelResponseBuilder.addResponseCode(ResponseCode.MATERIAL_TYPE_ALREADY_EXIST, materialType.getName()); + if (ex.getIdentifierType() == ModelException.IdentifierType.NAME) { + modelResponseBuilder.addResponseCode(ResponseCode.MATERIAL_TYPE_ALREADY_EXIST, materialType.getName()); + } else { + modelResponseBuilder.addResponseCode(ResponseCode.MATERIAL_TYPE_ALREADY_EXIST_PREFIX, materialType.getPrefix()); + } } return getPage(modelResponseBuilder.build(), materialType); diff --git a/src/main/resources/static/js/main.js b/src/main/resources/static/js/main.js index b446e3f..5a17b53 100644 --- a/src/main/resources/static/js/main.js +++ b/src/main/resources/static/js/main.js @@ -72,14 +72,19 @@ $(() => { // Imprimante let src = `${baseUrl}/icons/printerError.svg`; let title = printErrorTitle; - if ($(".bpac-extension-installed").length) { - src = `${baseUrl}/icons/printer.svg`; - title = printOkTitle; - } - $("#printStatusIcon").attr({ - src: src, - title: title - }); + const intervalId = setInterval(() => { + if ($(".bpac-extension-installed").length) { + src = `${baseUrl}/icons/printer.svg`; + title = printOkTitle; + + clearInterval(intervalId); + } + + $("#printStatusIcon").attr({ + src: src, + title: title + }); + }, 500); }); function checkSimdutAvailability(materialId) { diff --git a/src/main/resources/templates/touchup.html b/src/main/resources/templates/touchup.html index 8ecf825..aab8576 100644 --- a/src/main/resources/templates/touchup.html +++ b/src/main/resources/templates/touchup.html @@ -9,7 +9,7 @@ } - +
diff --git a/src/main/resources/updates.md b/src/main/resources/updates.md index cc21989..00ef7bf 100644 --- a/src/main/resources/updates.md +++ b/src/main/resources/updates.md @@ -1,6 +1,10 @@ # v1.3.1 ### Corrections * Correction d'un bug qui empêchait d'avoir plus que 2 mélanges avec le même nom. +* Correction d'un bug qui empêchait de modifier des types de produit. +* Correction d'un bug qui empêchait de créer des PDFs de kit de retouche. +* Correction d'un bug qui empêchait les fichiers SIMDUT de fonctionner. +** Correction d'un bug qui empêchait de détecter si un fichier SIMDUT existait. # v1.3.0 (Optimisations back-end) ### Note: Cette mise à jour n'est pas compatible avec les anciennes versions.