From 15aadc3c0d5c438b1c306a24aac002e4eeeb151f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Losada=20Hern=C3=A1ndez?= Date: Fri, 30 Oct 2026 15:44:29 +0100 Subject: [PATCH] recheck validity on tag change --- client/homebrew/pages/vaultPage/vaultPage.jsx | 21 +++++++------------ server/vault.api.js | 4 +--- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/client/homebrew/pages/vaultPage/vaultPage.jsx b/client/homebrew/pages/vaultPage/vaultPage.jsx index bfb20bd77..fd0333c21 100644 --- a/client/homebrew/pages/vaultPage/vaultPage.jsx +++ b/client/homebrew/pages/vaultPage/vaultPage.jsx @@ -64,13 +64,14 @@ const VaultPage = (props)=>{ loadPage(pageState, true, props.query.sort, props.query.dir); }, []); + useEffect(()=>{disableSubmitIfFormInvalid()},[tagsListAnd, tagsListOr, tagsListNot]) + const updateStateWithBrews = (brews, page)=>{ setBrewCollection(brews || null); setPageState(parseInt(page) || 1); setSearching(false); }; - const buildQueryParams = (entries)=>{ const params = new URLSearchParams(); @@ -84,20 +85,9 @@ const VaultPage = (props)=>{ return params.toString(); }; - - const updateUrl = (params)=>{ - const url = new URL(window.location.href); - - url.search = params; - - window.history.replaceState(null, '', url.toString()); - }; - - const performSearch = async (formContents, page, sort, dir)=>{ const { title, author, count, v3, legacy, tagsAnd, tagsOr, tagsNot } = formContents; - const params = buildQueryParams([ ['title', title], ['author', author], @@ -112,7 +102,9 @@ const VaultPage = (props)=>{ ['dir', dir] ]); - updateUrl(params); + const url = new URL(window.location.href); + url.search = params; + window.history.replaceState(null, '', url.toString()); const response = await request.get(`/api/vault?${params}`) .catch((error)=>{ @@ -127,7 +119,7 @@ const VaultPage = (props)=>{ }; const loadTotal = async (formContents)=>{ - const { title, author, count, v3, legacy, tagsAnd, tagsOr, tagsNot } = formContents; + const { title, author, v3, legacy, tagsAnd, tagsOr, tagsNot } = formContents; setTotalBrews(null); @@ -208,6 +200,7 @@ const VaultPage = (props)=>{ const isAuthorValid = authorRef.current.validity.valid && authorRef.current.value; const isCheckboxChecked = legacyRef.current.checked || v3Ref.current.checked; const isTagsValid = tagsListAnd.length >= 1 || tagsListOr.length >= 1; + //if a search is done with only negative tags, the planner crashes const isFormValid = (isTitleValid || isAuthorValid || isTagsValid) && isCheckboxChecked; diff --git a/server/vault.api.js b/server/vault.api.js index 4f6dd26a3..6d8556398 100644 --- a/server/vault.api.js +++ b/server/vault.api.js @@ -32,8 +32,6 @@ const rendererConditions = (legacy, v3)=>{ const tagConditions = (tagsAnd, tagsOr, tagsNot) => { const conditions = {}; - console.log(tagsAnd.length, tagsOr.length, tagsNot.length); - if (tagsAnd.length > 0) { conditions.$and = tagsAnd.map(tag => ({ tags: tag.trim() @@ -73,7 +71,7 @@ const findBrews = async (req, res)=>{ const sort = req.query.sort || 'title'; const dir = req.query.dir || 'asc'; - console.log(`Title: ${title}, Author: ${author}, page: ${page}, count: ${count}, tagsAnd: ${tagsAnd}, tagsOr: ${tagsOr} tagsNot: ${tagsNot}`); + //console.log(`Title: ${title}, Author: ${author}, page: ${page}, count: ${count}, tagsAnd: ${tagsAnd}, tagsOr: ${tagsOr} tagsNot: ${tagsNot}`); const combinedQuery = { $and : [