recheck validity on tag change

This commit is contained in:
Víctor Losada Hernández
2026-10-30 15:44:29 +01:00
parent 124d03f8c1
commit 15aadc3c0d
2 changed files with 8 additions and 17 deletions
+7 -14
View File
@@ -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;
+1 -3
View File
@@ -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 : [