From 43ae9f1222851bc8aa5a1684837660d2329c5412 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Wed, 26 Feb 2020 21:02:25 -0500 Subject: [PATCH] =?UTF-8?q?Transition=20compl=C3=A8te=20vers=20jQuery?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/static/js/{ => libs}/bpac.js | 0 src/main/resources/static/js/main.js | 15 +- src/main/resources/static/js/ptouchPrint.js | 2 +- .../resources/static/js/recipeResearch.js | 84 +++++----- src/main/resources/templates/images/add.html | 1 - src/main/resources/templates/inventory.html | 83 ++++------ .../resources/templates/material/created.html | 24 --- .../resources/templates/material/creator.html | 10 +- .../resources/templates/material/editor.html | 10 +- .../resources/templates/material/remover.html | 1 - .../resources/templates/material/simdut.html | 1 - .../templates/materialType/creator.html | 1 - .../templates/materialType/edit.html | 1 - .../templates/materialType/editor.html | 10 +- .../templates/materialType/remover.html | 1 - src/main/resources/templates/recipe/bak.html | 155 ------------------ .../resources/templates/recipe/created.html | 24 --- .../resources/templates/recipe/creator.html | 1 - src/main/resources/templates/recipe/edit.html | 2 +- src/main/resources/templates/updates.html | 7 +- src/main/resources/updates.md | 21 ++- 21 files changed, 123 insertions(+), 331 deletions(-) rename src/main/resources/static/js/{ => libs}/bpac.js (100%) delete mode 100644 src/main/resources/templates/material/created.html delete mode 100644 src/main/resources/templates/recipe/bak.html delete mode 100644 src/main/resources/templates/recipe/created.html diff --git a/src/main/resources/static/js/bpac.js b/src/main/resources/static/js/libs/bpac.js similarity index 100% rename from src/main/resources/static/js/bpac.js rename to src/main/resources/static/js/libs/bpac.js diff --git a/src/main/resources/static/js/main.js b/src/main/resources/static/js/main.js index 8c79908..e382d76 100644 --- a/src/main/resources/static/js/main.js +++ b/src/main/resources/static/js/main.js @@ -180,23 +180,16 @@ function showConfirm(value, prompt = false, continueCallback = () => { }) { const filter = $("#filter"); const node = prompt ? $(promptMsg) : $(confirmMsg); - const nodeInput = prompt ? node.find("#confirmInput") : $(""); + const nodeInput = prompt ? node.find("#confirmInput") : undefined; - if (prompt) { - nodeInput.val(""); - - // Ne fonctionne pas sans - setTimeout(function () { - nodeInput.focus(); - }, 0); - } + if (prompt) nodeInput.val(""); showMessage(node, value, false); filter.show(); filter.animate({opacity: 0.5}, messageBoxesAnimationTime); setTimeout(() => { - nodeInput.on({ + $("body").on({ keyup: function (e) { if (e.which === 13) { // Enter confirmContinue(node, continueCallback); @@ -215,6 +208,8 @@ function showConfirm(value, prompt = false, continueCallback = () => { confirmCancel(node, cancelCallback) } }); + + if (nodeInput) nodeInput.focus(); }, 100); } diff --git a/src/main/resources/static/js/ptouchPrint.js b/src/main/resources/static/js/ptouchPrint.js index f978ac3..f95956d 100644 --- a/src/main/resources/static/js/ptouchPrint.js +++ b/src/main/resources/static/js/ptouchPrint.js @@ -1,4 +1,4 @@ -import * as bpac from "/js/bpac.js"; +import * as bpac from "/js/libs/bpac.js"; export class PtouchPrinter { constructor(object) { diff --git a/src/main/resources/static/js/recipeResearch.js b/src/main/resources/static/js/recipeResearch.js index 6d7f11f..9e35d13 100644 --- a/src/main/resources/static/js/recipeResearch.js +++ b/src/main/resources/static/js/recipeResearch.js @@ -1,64 +1,72 @@ -(() => { - document.querySelectorAll(".recipeRow").forEach(e => { - if (e.dataset.approbationdate === undefined) { - e.classList.add("unapproved"); - e.title = recipeNotApproved; +$(() => { + $(".recipeRow").each(function () { + if (!$(this).data("approbationdate")) { + $(this).addClass("unapproved"); + $(this).attr({title: recipeNotApproved}) } }); -})(); +}); function closeTabs() { - document.querySelectorAll(".recipesList").forEach(l => l.style.display = "none"); + $(".recipesList").each(function () { + $(this).hide(); + }); } function openTabs() { - document.querySelectorAll(".recipesList").forEach(l => l.style.display = ""); + $(".recipesList").each(function () { + $(this).show(); + }); } -const companyRows = document.querySelectorAll(".companyTab"); +const companyRows = $(".companyTab"); function performSearch(searchString) { let found = false; let emptySearch = false; - const recipesContainer = document.querySelector(".recipesContainer:not(.researchEnabled)"); - if (recipesContainer !== undefined && recipesContainer !== null) { - recipesContainer.classList.add("researchEnabled"); - } + const recipesContainer = $(".recipesContainer:not(.researchEnabled)"); + if (recipesContainer) recipesContainer.addClass("researchEnabled"); document.querySelectorAll(".researchResult").forEach(t => { t.classList.remove("researchResult"); }); - companyRows.forEach(c => { - const recipeRows = c.querySelectorAll(".recipeRow"); + companyRows.each(function () { + const company = $(this); + const recipeRows = company.find(".recipeRow"); - if (!searchString || !searchString.replace(/\s/g, '').length) { - c.classList.add("researchResult"); + if (!searchString || !searchString.replace(/\s/g, '').length) { // Si la recherche est vide + company.addClass("researchResult"); - recipeRows.forEach(r => { - r.classList.add("researchResult"); + recipeRows.each(function () { + $(this).addClass("researchResult"); + }); + + found = true; + emptySearch = true; + } else if (searchIn(searchString, company.find("h2").text())) { // Si la recherche correspondant à une bannière + company.addClass("researchResult"); + + recipeRows.each(function () { + $(this).addClass("researchResult"); + }); + + found = true; + } else { // Sinon on fait une recherche dans les recettes + recipeRows.each(function () { + const recipe = $(this); + + $(this).find(".descriptionCell").each(function () { + if (searchIn(searchString, $(this).text())) { + company.addClass("researchResult"); + recipe.addClass("researchResult"); + found = true; + } }); - - found = true; - emptySearch = true; - } else if (searchIn(searchString, c.querySelector("h2").textContent)) { - c.classList.add("researchResult"); - recipeRows.forEach(r => r.classList.add("researchResult")); - found = true; - } else { - recipeRows.forEach(r => { - r.querySelectorAll(".descriptionCell").forEach(d => { - if (searchIn(searchString, d.textContent)) { - r.classList.add("researchResult"); - c.classList.add("researchResult"); - found = true; - } - }); - }); - } + }); } - ); + }); if (!found) showMessage(warningMsg, researchNotFound, false); else hideMessage(warningMsg); diff --git a/src/main/resources/templates/images/add.html b/src/main/resources/templates/images/add.html index f0f0401..4dd70c1 100644 --- a/src/main/resources/templates/images/add.html +++ b/src/main/resources/templates/images/add.html @@ -22,6 +22,5 @@ - diff --git a/src/main/resources/templates/inventory.html b/src/main/resources/templates/inventory.html index 2d50d6d..78a234f 100644 --- a/src/main/resources/templates/inventory.html +++ b/src/main/resources/templates/inventory.html @@ -151,90 +151,79 @@ const defaultLowQuantity = 100; - (() => { + const materialRows = $(".materialRow"); + $(() => { // Rajoute un événement sur les boutons pour modifier les produits pour rediriger l'utilisateur vers la page de modification - document.querySelectorAll(".modifyMaterial").forEach(e => { - e.addEventListener("click", () => { - window.location.href = `/material/editor/${e.dataset.materialid}`; - }); + $(".modifyMaterial").on({ + click: function () { + window.location.href = `/material/editor/${$(this).data("materialid")}`; + } }); - document.querySelector("#lowQuantity").value = defaultLowQuantity; - checkLowQuantity(defaultLowQuantity) - - })(); + $("#lowQuantity").val(defaultLowQuantity); + checkLowQuantity(defaultLowQuantity); + }); // Ajoute la classe "lowQuantity" au produits qui ont une quantité en inventaire inférieur à la quantité limite définie function checkLowQuantity(value) { - document.querySelectorAll(".materialRow").forEach(e => { - - if (parseFloat(e.querySelector(".inventoryQuantity").innerHTML) < value) { - e.classList.add("lowQuantity"); - } else { - e.classList.remove("lowQuantity"); - } - - hide(document.querySelector("#hideOthers").checked); + materialRows.each(function () { + if (parseFloat($(this).find(".inventoryQuantity").text()) < value) $(this).addClass("lowQuantity"); + else $(this).removeClass("lowQuantity"); }); + + hide($("#hideOthers").attr("checked")); } // Cache ou dévoile les produits qui ont la classe "lowQuantity", dépendamment du paramètre "checked" function hide(checked) { if (checked) { - document.querySelectorAll(".materialRow").forEach(e => { - if (!e.classList.contains("lowQuantity")) { - e.classList.add("hidden"); - } else { - e.classList.remove("hidden"); - } + materialRows.each(function () { + if ($(this).hasClass("lowQuantity")) $(this).addClass("hidden"); + else $(this).removeClass("hidden"); }); } else { - document.querySelectorAll(".hidden").forEach(e => { - e.classList.remove("hidden"); + $(".hidden").each(function () { + $(this).removeClass("hidden"); }); } } // Cache les produits qui ne sont pas du type de produit spécifié dans le paramètre "select", si le type de produit n'est pas "Aucun" function hideMaterialTypes(select) { - const value = select.value; - const anyValue = document.querySelector("#anyTypeId").value; + select = $(select); - document.querySelectorAll(".materialRow").forEach(e => { - if (value !== anyValue && e.dataset.materialtype !== value) { - e.classList.add("hiddenWrongType"); - } else { - e.classList.remove("hiddenWrongType"); - } + const value = parseInt(select.val()); + const anyValue = parseInt($("#anyTypeId").val()); + + materialRows.each(function () { + if (value !== anyValue && parseInt($(this).data("materialtype")) !== value) $(this).addClass("hiddenWrongType"); + else $(this).removeClass("hiddenWrongType"); }); } - const materialRows = document.querySelectorAll(".materialRow"); - function performSearch(searchString) { let found = false; - const recipesContainer = document.querySelector(".materialsContainer:not(.researchEnabled)"); - if (recipesContainer !== undefined && recipesContainer !== null) { - recipesContainer.classList.add("researchEnabled"); + const materialsContainer = $(".materialsContainer:not(.researchEnabled)"); + if (materialsContainer) { + materialsContainer.addClass("researchEnabled"); } - document.querySelectorAll(".researchResult").forEach(t => { - t.classList.remove("researchResult"); + $(".researchResult").each(function () { + $(this).removeClass("researchResult"); }); - materialRows.forEach(row => { + materialRows.each(function () { if (!searchString || !searchString.replace(/\s/g, '').length) { - row.classList.add("researchResult"); + $(this).addClass("researchResult"); found = true; } else { - - const materialCode = row.querySelector(".materialCode").textContent; - const materialType = row.querySelector(".materialType").textContent; + const materialCode = $(this).find(".materialCode").text(); + const materialType = $(this).find(".materialType").text(); if (searchIn(searchString, materialCode) || searchIn(searchString, materialType)) { - row.classList.add("researchResult"); + $(this).addClass("researchResult"); found = true; } } diff --git a/src/main/resources/templates/material/created.html b/src/main/resources/templates/material/created.html deleted file mode 100644 index 70302fd..0000000 --- a/src/main/resources/templates/material/created.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - -
- -
-

-

- - -
- - - - - - diff --git a/src/main/resources/templates/material/creator.html b/src/main/resources/templates/material/creator.html index cc1a7f5..9b04664 100644 --- a/src/main/resources/templates/material/creator.html +++ b/src/main/resources/templates/material/creator.html @@ -87,9 +87,11 @@ diff --git a/src/main/resources/templates/material/editor.html b/src/main/resources/templates/material/editor.html index ee7764e..89fd0d6 100644 --- a/src/main/resources/templates/material/editor.html +++ b/src/main/resources/templates/material/editor.html @@ -48,12 +48,10 @@ diff --git a/src/main/resources/updates.md b/src/main/resources/updates.md index 7c5ed43..4b1e01e 100644 --- a/src/main/resources/updates.md +++ b/src/main/resources/updates.md @@ -1,8 +1,23 @@ # v1.3.0 (Optimisations back-end) ### Note: Cette mise à jour n'est pas compatible avec les anciennes versions. ### Corrections -* Réusinage des modèles. (Empêche la compatibilité avec les anciennes versions) -* Réusinage des contrôleurs et des services (Améliore la maintenabilité) +* Réusinage des modèles. (Améliore la maintenabilité, empêche la compatibilité avec les anciennes versions) +* Réusinage des contrôleurs et des services. (Améliore la maintenabilité et permet d'avoir des messages d'erreur plus précis) +* La recherche de produit dans les sélecteurs de produits dans l'éditeur de mélange est fonctionnelle. +* Correction de quelques bugs visuels dans les menus et l'éditeur de mélange. +* Les caractères spéciaux sont maintenant affichés correctement dans les PDFs et les étiquettes P-touch. + +### Ajouts +* Les boites de texte des boites de confirmation prennent le focus automatiquement. +* Appuyez sur Entrer (Enter) lorsqu'une boite de confirmation est présente aura le même effet qu'appuyer sur Continuer. +* Appuyez sur Échapper (Esc) lorsqu'un boite de confirmation est présente aura le même effet qu'appuyer sur Annuler. +* Il n'est plus possible de créer des mélanges dont le type est le même qu'un produit. (Permet d'éviter les conflits) +* Ajout des types de produit par défaut. + * Ceux-ci ne peuvent pas être modifiés ou supprimés. + * Ils peuvent être configurés dans les propriétés du serveur. + +### Dépendances +* Transition complète vers jQuery. # v1.2.0 (Imprimante P-touch) ### Corrections @@ -30,7 +45,7 @@ ### Dépendances * Ajout de jQuery, début de la transition. -* Migration vers Java 11 +* Migration vers Java 11. # v1.1.3 ### Corrections