Skip to content

Commit

Permalink
feat(faq): changement de model de données
Browse files Browse the repository at this point in the history
  • Loading branch information
olivocto committed Mar 14, 2023
1 parent 617a480 commit 3080106
Show file tree
Hide file tree
Showing 13 changed files with 1,504 additions and 4,220 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,20 @@ Feel free to check out the [Strapi GitHub repository](https://github.com/strapi/
- [Awesome Strapi](https://github.com/strapi/awesome-strapi) - A curated list of awesome things related to Strapi.

---

## Creation d’un Collection Type

Après avoir lancé Strapi en local il va falloir générer un nouveau Content-Type dans l'interface avec le plugin Content-Type Builder
- Seléctionner `+` Create new collection type
- Configurer la nouvelle Collection selon votre besoin
- Une fois votre Collection déclarée il va falloir gérer la synchronisation de la config dans la codebase: dans `config/config-sync/core-stores-config-files-to-exclude.ts` ajouter la configuration liée à votre nouvelle Collection: `"core-store.plugin_content_manager_configuration_content_types::api::[Collection].[Collection]"`
- Maintenant ajouter les droits des utilisateurs sur votre nouvelle Collection: dans `config/config-sync/files/user-role.public.json`. Par exemple pour les droits de lecture ajouter:
```
{
"action": "api::[Collection].[Collection].find"
},
{
"action": "api::[Collection].[Collection].findOne"
}
```
- Votre nouvelle Collection est utilisable.
2 changes: 1 addition & 1 deletion config/config-sync/core-stores-config-files-to-exclude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default [
"core-store.plugin_content_manager_configuration_content_types::api::entreprise.entreprise",
"core-store.plugin_content_manager_configuration_content_types::api::evenement.evenement",
"core-store.plugin_content_manager_configuration_content_types::api::fiche-metier.fiche-metier",
"core-store.plugin_content_manager_configuration_content_types::api::foire-a-la-question.foire-a-la-question",
"core-store.plugin_content_manager_configuration_content_types::api::faq.faq",
"core-store.plugin_content_manager_configuration_content_types::api::les-mesures-employeurs.les-mesures-employeurs",
"core-store.plugin_content_manager_configuration_content_types::api::mention-legale.mention-legale",
"core-store.plugin_content_manager_configuration_content_types::api::mesure-jeune.mesure-jeune",
Expand Down
4 changes: 2 additions & 2 deletions config/config-sync/files/user-role.public.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
"action": "api::evenement.evenement.findOne"
},
{
"action": "api::foire-a-la-question.foire-a-la-question.find"
"action": "api::faq.faq.find"
},
{
"action": "api::foire-a-la-question.foire-a-la-question.findOne"
"action": "api::faq.faq.findOne"
},
{
"action": "api::fiche-metier.fiche-metier.find"
Expand Down
31 changes: 31 additions & 0 deletions src/api/faq/content-types/faq/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"kind": "collectionType",
"collectionName": "faqs",
"info": {
"singularName": "faq",
"pluralName": "faqs",
"displayName": "Faq",
"description": ""
},
"options": {
"draftAndPublish": true
},
"attributes": {
"problematique": {
"type": "string",
"required": true
},
"titre": {
"type": "string",
"required": true
},
"contenu": {
"type": "richtext",
"required": true
},
"slug": {
"type": "uid",
"required": true
}
}
}
7 changes: 7 additions & 0 deletions src/api/faq/controllers/faq.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* faq controller
*/

import { factories } from '@strapi/strapi'

export default factories.createCoreController('api::faq.faq');
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"/foire-aux-questions": {
"/faqs": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/FoireALaQuestionListResponse"
"$ref": "#/components/schemas/FaqListResponse"
}
}
}
Expand Down Expand Up @@ -64,7 +64,7 @@
}
},
"tags": [
"Foire-a-la-question"
"Faq"
],
"parameters": [
{
Expand Down Expand Up @@ -169,7 +169,7 @@
}
}
],
"operationId": "get/foire-aux-questions"
"operationId": "get/faqs"
},
"post": {
"responses": {
Expand All @@ -178,7 +178,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/FoireALaQuestionResponse"
"$ref": "#/components/schemas/FaqResponse"
}
}
}
Expand Down Expand Up @@ -235,31 +235,31 @@
}
},
"tags": [
"Foire-a-la-question"
"Faq"
],
"parameters": [],
"operationId": "post/foire-aux-questions",
"operationId": "post/faqs",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/FoireALaQuestionRequest"
"$ref": "#/components/schemas/FaqRequest"
}
}
}
}
}
},
"/foire-aux-questions/{id}": {
"/faqs/{id}": {
"get": {
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/FoireALaQuestionResponse"
"$ref": "#/components/schemas/FaqResponse"
}
}
}
Expand Down Expand Up @@ -316,7 +316,7 @@
}
},
"tags": [
"Foire-a-la-question"
"Faq"
],
"parameters": [
{
Expand All @@ -330,7 +330,7 @@
}
}
],
"operationId": "get/foire-aux-questions/{id}"
"operationId": "get/faqs/{id}"
},
"put": {
"responses": {
Expand All @@ -339,7 +339,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/FoireALaQuestionResponse"
"$ref": "#/components/schemas/FaqResponse"
}
}
}
Expand Down Expand Up @@ -396,7 +396,7 @@
}
},
"tags": [
"Foire-a-la-question"
"Faq"
],
"parameters": [
{
Expand All @@ -410,13 +410,13 @@
}
}
],
"operationId": "put/foire-aux-questions/{id}",
"operationId": "put/faqs/{id}",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/FoireALaQuestionRequest"
"$ref": "#/components/schemas/FaqRequest"
}
}
}
Expand Down Expand Up @@ -487,7 +487,7 @@
}
},
"tags": [
"Foire-a-la-question"
"Faq"
],
"parameters": [
{
Expand All @@ -501,7 +501,7 @@
}
}
],
"operationId": "delete/foire-aux-questions/{id}"
"operationId": "delete/faqs/{id}"
}
}
}
7 changes: 7 additions & 0 deletions src/api/faq/routes/faq.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* faq router
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreRouter('api::faq.faq');
7 changes: 7 additions & 0 deletions src/api/faq/services/faq.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* faq service
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreService('api::faq.faq');

This file was deleted.

This file was deleted.

7 changes: 0 additions & 7 deletions src/api/foire-a-la-question/routes/foire-a-la-question.ts

This file was deleted.

7 changes: 0 additions & 7 deletions src/api/foire-a-la-question/services/foire-a-la-question.ts

This file was deleted.

Loading

0 comments on commit 3080106

Please sign in to comment.