Skip to content

Commit

Permalink
fix: ne pas afficher les contribs personnalisées
Browse files Browse the repository at this point in the history
  • Loading branch information
m-maillot committed Sep 26, 2024
1 parent 1a16ed6 commit 0acc19d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 53 deletions.
14 changes: 8 additions & 6 deletions targets/frontend/src/components/documents/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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},
Expand Down
41 changes: 0 additions & 41 deletions targets/frontend/src/components/documents/SearchFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
Select,
Stack,
} from "@mui/material";
import { useQuery } from "urql";

import { Button } from "../button";

Expand All @@ -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]:
Expand Down Expand Up @@ -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
}
}
}
`;
9 changes: 3 additions & 6 deletions targets/frontend/src/components/home/UnThemedContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}}
]}
]
}) {
Expand Down

0 comments on commit 0acc19d

Please sign in to comment.