Skip to content

Commit

Permalink
fix: tuile modeles recherche contenant des tags html (#1396)
Browse files Browse the repository at this point in the history
* feat: update description -> intro

* fix: ajout des champs dans le document

* chore: clean

* fix: creation models

* Revert "fix: creation models"

This reverts commit 8c02af0.

---------

Co-authored-by: Victor <[email protected]>
  • Loading branch information
Viczei and Victor authored May 23, 2024
1 parent 28b972e commit a042702
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class DocumentsService {
source: "modeles_de_courriers",
meta_description: data.metaDescription,
title: data.title,
text: data.description,
text: data.intro,
slug: document?.slug ?? slugify(data.title),
is_searchable: document ? document.is_searchable : true,
is_published: document ? document.is_published : true,
Expand All @@ -153,7 +153,8 @@ export class DocumentsService {
type: "external",
}))
),
description: data.description,
description: data.metaDescription,
intro: data.intro,
filename: data.file.url,
filesize: parseInt(data.file.size ?? "0"),
html: data.previewHTML,
Expand Down
2 changes: 1 addition & 1 deletion targets/frontend/src/modules/models/api/modelsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const modelsQuery = gql`
title
metaTitle
type
description
intro
metaDescription
previewHTML
createdAt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Props = {
const defaultValues: FormData = {
title: "",
metaTitle: "",
description: "",
intro: "",
metaDescription: "",
type: undefined,
previewHTML: "",
Expand Down Expand Up @@ -115,7 +115,7 @@ export const ModelForm = ({
id: newData.id!,
title: newData.title!,
metaTitle: newData.metaTitle!,
description: newData.description!,
intro: newData.intro!,
metaDescription: newData.metaDescription!,
type: newData.type!,
file: newData.newFile
Expand Down Expand Up @@ -232,8 +232,8 @@ export const ModelForm = ({
</FormControl>
<FormControl>
<FormEditionField
label="Description"
name="description"
label="Introduction"
name="intro"
control={control}
/>
</FormControl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const useModelInsertMutation = (): MutationFn => {
title: data.title,
metaTitle: data.metaTitle,
type: data.type,
description: data.description,
intro: data.intro,
metaDescription: data.metaDescription,
file: {
data: data.file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const updateModelQuery = gql`
update_columns: [
title
metaTitle
description
intro
metaDescription
type
previewHTML
Expand Down Expand Up @@ -62,7 +62,7 @@ export const useModelUpdateMutation = (): MutationFn => {
id: data.id,
title: data.title,
metaTitle: data.metaTitle,
description: data.description,
intro: data.intro,
metaDescription: data.metaDescription,
type: data.type,
file: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const listModelsQuery = gql`
title
metaTitle
type
description
intro
metaDescription
previewHTML
createdAt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export type ModelModelsOtherReferencesArrRelInsertInput = {

export type ModelModelsInsertInput = {
createdAt?: string;
description?: string;
intro?: string;
file?: FilesObjRelInsertInput;
fileId?: string;
id?: string;
Expand Down
6 changes: 3 additions & 3 deletions targets/frontend/src/modules/models/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export const modelSchema = z.object({
metaTitle: z
.string({ required_error: "Un titre meta doit être renseigné" })
.min(1, "Un titre meta doit être renseigné"),
description: z
intro: z
.string({
required_error: "Une description doit être renseignée",
required_error: "Une introduction doit être renseignée",
})
.min(1, "Une description doit être renseignée"),
.min(1, "Une introduction doit être renseignée"),
metaDescription: z
.string({
required_error: "Une description meta doit être renseignée",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ insert_permissions:
- created_at
- updated_at
- title
- description
- intro
- meta_title
- meta_description
- type
Expand All @@ -61,7 +61,7 @@ select_permissions:
- role: super
permission:
columns:
- description
- intro
- meta_description
- meta_title
- preview_html
Expand All @@ -77,7 +77,7 @@ update_permissions:
permission:
columns:
- created_at
- description
- intro
- file_id
- meta_description
- meta_title
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "model"."models" rename column "intro" to "description";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "model"."models" rename column "description" to "intro";
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- On renomme intro en description
update documents set document = jsonb_set(document #- '{intro}',
'{description}',
document#>'{intro}')
where source = 'modeles_de_courriers';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- On renomme description en intro
update documents set document = jsonb_set(document #- '{description}',
'{intro}',
document#>'{description}')
where source = 'modeles_de_courriers';

--On Remet un champs description avec le contenu de la meta_description
update documents set document = jsonb_set(document, '{description}', to_jsonb(meta_description))
where source = 'modeles_de_courriers';

0 comments on commit a042702

Please sign in to comment.