From 499435387e64912318e703a60947ccb36bc70b09 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Mon, 9 Mar 2020 10:52:57 -0400 Subject: [PATCH] =?UTF-8?q?corrections:=20Impossible=20de=20cr=C3=A9er=20p?= =?UTF-8?q?lus=20que=20un=20(deux=3F)=20m=C3=A9langes=20avec=20le=20m?= =?UTF-8?q?=C3=AAme=20nom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/model/MixType.java | 6 ++--- .../core/services/model/MixService.java | 1 + .../files/SIMDUTFilesController.java | 4 ++-- src/main/resources/static/js/main.js | 22 +++++++++++++------ .../resources/templates/material/edit.html | 3 +++ src/main/resources/templates/recipe/edit.html | 2 +- .../resources/templates/recipe/explore.html | 2 +- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/MixType.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/MixType.java index 6a914ee..3de3e44 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/MixType.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/MixType.java @@ -38,12 +38,12 @@ public class MixType implements IModel { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; MixType mixType = (MixType) o; - return Objects.equals(id, mixType.id) && - Objects.equals(name, mixType.name); + return Objects.equals(name, mixType.name) && + Objects.equals(material, mixType.material); } @Override public int hashCode() { - return Objects.hash(id, name); + return Objects.hash(name, material); } } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MixService.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MixService.java index cfe66b8..ee9b668 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MixService.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MixService.java @@ -120,6 +120,7 @@ public class MixService extends AbstractService { if (materialService.existsByName(mixType.getName()) && !materialService.getByName(mixType.getName()).isMixType()) throw new EntityAlreadyExistsException(type, ModelException.IdentifierType.OTHER, MixType.IDENTIFIER_MATERIAL_NAME, mixType.getName()); + mixTypeService.update(mixType); update(mix); } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/files/SIMDUTFilesController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/files/SIMDUTFilesController.java index 50d27f7..3a2c173 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/files/SIMDUTFilesController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/files/SIMDUTFilesController.java @@ -37,10 +37,10 @@ public class SIMDUTFilesController { headers.setContentType(MediaType.APPLICATION_PDF); return new ResponseEntity<>(simdutContent, headers, HttpStatus.OK); } else { - headers.add("Location", request.getHeader("referer")); + headers.add("Location", "/" + CLOSE_TAB); } } catch (EntityNotFoundException ex) { - headers.add("Location", "/" + CLOSE_TAB); + headers.add("Location", request.getHeader("referer")); } return new ResponseEntity<>(headers, HttpStatus.FOUND); diff --git a/src/main/resources/static/js/main.js b/src/main/resources/static/js/main.js index e382d76..b446e3f 100644 --- a/src/main/resources/static/js/main.js +++ b/src/main/resources/static/js/main.js @@ -14,13 +14,10 @@ $(() => { const materialID = row.data("materialid"); // SIMDUT - axios.post(`/simdut/${materialID}`) - .catch(function (err) { - if (err.response.status === 404) { - row.parent().addClass("nosimdut"); - row.parent().title = simdutNotFoundText; - } - }); + if (!checkSimdutAvailability(materialID)) { + row.parent().addClass("nosimdut"); + row.parent().title = simdutNotFoundText; + } }); $(".messageBox").each(function () { checkMessageBoxesDisplay($(this)[0]) @@ -85,6 +82,17 @@ $(() => { }); }); +function checkSimdutAvailability(materialId) { + axios.post(`/simdut/${materialId}`) + .then(function (d) { + return true; + }) + .catch(function (err) { + if (err.response.status === 404) return false; + else return false; + }); +} + function confirmDatabaseExport() { showConfirm(exportAllWarningText, false, () => { window.location.href = "./recipe/xls"; diff --git a/src/main/resources/templates/material/edit.html b/src/main/resources/templates/material/edit.html index b238ebf..01b79d3 100644 --- a/src/main/resources/templates/material/edit.html +++ b/src/main/resources/templates/material/edit.html @@ -102,6 +102,9 @@ window.location.href = `/material/simdut/${materialId}`; } }); + + console.log(checkSimdutAvailability(materialId)); + if (!checkSimdutAvailability(materialId)) $("#showSIMDUT").hide(); }); function switchUnits(unitSelect) { diff --git a/src/main/resources/templates/recipe/edit.html b/src/main/resources/templates/recipe/edit.html index bc96c44..e4d07fc 100644 --- a/src/main/resources/templates/recipe/edit.html +++ b/src/main/resources/templates/recipe/edit.html @@ -133,7 +133,7 @@ - diff --git a/src/main/resources/templates/recipe/explore.html b/src/main/resources/templates/recipe/explore.html index 5e89261..e1d72ab 100644 --- a/src/main/resources/templates/recipe/explore.html +++ b/src/main/resources/templates/recipe/explore.html @@ -121,7 +121,7 @@ class="materialRow" th:data-materialtypename="${material.materialType.name}" th:id="'material-' + ${material.id}"> -