Fix recherche de produit dans l'éditeur de mélange

This commit is contained in:
FyloZ 2020-02-26 11:00:56 -05:00
parent aa115b08c1
commit 446233dbc0
3 changed files with 15 additions and 9 deletions

View File

@ -3,6 +3,7 @@ package dev.fyloz.trial.colorrecipesexplorer.web.controller;
import dev.fyloz.trial.colorrecipesexplorer.core.exception.model.EntityNotFoundException;
import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ModelResponseBuilder;
import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ResponseCode;
import dev.fyloz.trial.colorrecipesexplorer.core.model.Material;
import dev.fyloz.trial.colorrecipesexplorer.core.services.files.MarkdownFilesService;
import dev.fyloz.trial.colorrecipesexplorer.core.services.model.MixService;
import dev.fyloz.trial.colorrecipesexplorer.core.services.model.RecipeService;
@ -16,6 +17,9 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import java.util.Collection;
import java.util.List;
import static dev.fyloz.trial.colorrecipesexplorer.web.StringBank.MATERIALS;
import static dev.fyloz.trial.colorrecipesexplorer.web.WebsitePaths.*;

View File

@ -10,7 +10,7 @@ let recipeID;
$(() => {
recipeID = $("#recipeId").val();
const mixIDInput = $("#mixID");
const mixIDInput = $("#mixId");
const mixID = mixIDInput.val() ? mixIDInput.val() : -1;
axios.get(`/mix/selector/${recipeID}/${mixID}`)
@ -207,13 +207,14 @@ function selectMaterial(material) {
}
function searchMaterial(input) {
input = $(input);
const filter = input.val();
const materials = input.parent().find(".materialList p");
materials.each(function () {
const node = $(this);
if (searchIn(filter, node.text()) || searchIn(filter, node.data("materialtype"))) node.hide();
else node.show();
if (searchIn(filter, node.text()) || searchIn(filter, node.data("materialtype"))) node.show();
else node.hide();
});
const found = input.parent().find(`.materialList p[data-materialcode="${filter}"]`);

View File

@ -78,19 +78,20 @@
<script src="/js/mix.js"></script>
<script>
/*<![CDATA[*/
(() => {
$(() => {
// Récupère les matériaux sous forme JSON depuis le thymeleaf et le valide.
const materialsText = "[[${materialsJson}]]";
materials = JSON.parse(materialsText.replace(/&quot;/g, '"').replace(/&#39;/g, '\'').replace(/\r\n/g, ""));
removeText = "[[#{keyword.remove}]]";
document.querySelector("#removeMix").addEventListener("click", () => {
showMessage(errorMsg);
checkPassword(null, () => window.location.href = `/mix/remover/[[${mix.id}]]`);
$("#removeMix").on({
click: function() {
showMessage(errorMsg);
checkPassword(null, () => window.location.href = `/mix/remover/[[${mix.id}]]`);
}
});
})();
});
function init() {
const mixText = "[[${mixJson}]]";