From 0acc19decdd99802ba6386737a810e6b674489cd Mon Sep 17 00:00:00 2001 From: Martial Maillot Date: Thu, 26 Sep 2024 11:49:25 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20ne=20pas=20afficher=20les=20contribs=20p?= =?UTF-8?q?ersonnalis=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/documents/Container.js | 14 ++++--- .../src/components/documents/SearchFilters.js | 41 ------------------- .../src/components/home/UnThemedContent.tsx | 9 ++-- 3 files changed, 11 insertions(+), 53 deletions(-) diff --git a/targets/frontend/src/components/documents/Container.js b/targets/frontend/src/components/documents/Container.js index c8ebf5703..97f18a8c5 100644 --- a/targets/frontend/src/components/documents/Container.js +++ b/targets/frontend/src/components/documents/Container.js @@ -129,9 +129,10 @@ DocumentListContainer.propTypes = { const searchDocumentQuery = ` query documents($source: String, $search: String!, $published: [Boolean!]!, $available: [Boolean!]!, $offset: Int = 0, $limit: Int = 50) { documents(where: { - _not: { - document: {_has_key: "split"} - } + _or: [ + { source: { _neq: "contributions" } } + { source: { _eq: "contributions" }, document: { _contains: { idcc: "0000" } } } + ] _and: { source: {_eq: $source, _neq: "code_du_travail"} title: {_ilike: $search} @@ -149,9 +150,10 @@ query documents($source: String, $search: String!, $published: [Boolean!]!, $ava } documents_aggregate(where: { - _not: { - document: {_has_key: "split"} - } + _or: [ + { source: { _neq: "contributions" } } + { source: { _eq: "contributions" }, document: { _contains: { idcc: "0000" } } } + ] _and: { source: {_eq: $source, _neq: "code_du_travail"} title: {_ilike: $search}, diff --git a/targets/frontend/src/components/documents/SearchFilters.js b/targets/frontend/src/components/documents/SearchFilters.js index 503fad852..23bffb6d8 100644 --- a/targets/frontend/src/components/documents/SearchFilters.js +++ b/targets/frontend/src/components/documents/SearchFilters.js @@ -12,7 +12,6 @@ import { Select, Stack, } from "@mui/material"; -import { useQuery } from "urql"; import { Button } from "../button"; @@ -36,28 +35,8 @@ export function SearchFilters({ initialValues, onSearchUpdate }) { ]; const { handleSubmit, register } = useForm(); - const [result] = useQuery({ - query: sourceQuery, - variables: { - available: - initialValues.available === "yes" - ? [true] - : initialValues.available === "no" - ? [false] - : [true, false], - published: - initialValues.published === "yes" - ? [true] - : initialValues.published === "no" - ? [false] - : [true, false], - search: `%${initialValues.q}%`, - source: initialValues.source || null, - }, - }); function triggerUpdateUrl(event) { - console.log("update filters"); onSearchUpdate({ ...initialValues, [event.target.name]: @@ -201,23 +180,3 @@ SearchFilters.propTypes = { }), onSearchUpdate: PropTypes.func.isRequired, }; - -const sourceQuery = ` -query documents($source: String, $search: String!, $published: [Boolean!]!, $available: [Boolean!]!) { - sources: documents_aggregate(where: { - _not: { - document: {_has_key: "split"} - } - _and: { - source: {_eq: $source, _neq: "code_du_travail"} - title: {_ilike: $search}, - is_published: {_in: $published} - is_available: {_in: $available} - } - }) { - nodes { - source - } - } -} -`; diff --git a/targets/frontend/src/components/home/UnThemedContent.tsx b/targets/frontend/src/components/home/UnThemedContent.tsx index 205056946..0d2a6ea0c 100644 --- a/targets/frontend/src/components/home/UnThemedContent.tsx +++ b/targets/frontend/src/components/home/UnThemedContent.tsx @@ -18,12 +18,9 @@ query getUnthemed($themeSources: [String!]!) { {_not: { relation_b: {type: {_eq: "${RELATIONS.THEME_CONTENT}"} a :{source: {_eq: "${SOURCES.THEMES}"}} } }} - {_and: [ - {_not: {document: {_has_key: "split"}}}, - {_or: [ - {_not: {document: {_has_key: "idcc"}}}, - {document: {_contains: {idcc: "0000"}}} - ]} + {_or: [ + {_not: {document: {_has_key: "idcc"}}}, + {document: {_contains: {idcc: "0000"}}} ]} ] }) {