From b3b9ac4e4ffd3bb4122cb5c2c9cd5084f11d86d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa?= Date: Mon, 16 Sep 2024 10:15:46 +0200 Subject: [PATCH 1/2] toast to upload image --- client/src/containers/collaborators/form/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/containers/collaborators/form/index.tsx b/client/src/containers/collaborators/form/index.tsx index ce953292..e6862761 100644 --- a/client/src/containers/collaborators/form/index.tsx +++ b/client/src/containers/collaborators/form/index.tsx @@ -319,6 +319,7 @@ export default function CollaboratorForm() { .then((data) => { form.setValue("image", data[0].id); setImageId(data[0].id); + toast.success(`Image ${data?.[0].name} uploaded successfully`); }) .catch((error) => { console.error("Error uploading image:", error[0]?.message); From 22b3e8d644e1e1a35f34db9ff456890f837ef1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa?= Date: Mon, 16 Sep 2024 10:35:30 +0200 Subject: [PATCH 2/2] objectives dropdown --- ...ntent_types##api##objective.objective.json | 116 ++++ .../content-types/objective/schema.json | 19 + .../api/objective/controllers/objective.ts | 7 + .../documentation/1.0.0/objective.json | 508 ++++++++++++++++++ cms/src/api/objective/routes/objective.ts | 7 + cms/src/api/objective/services/objective.ts | 7 + .../project/content-types/project/schema.json | 4 +- cms/types/generated/contentTypes.d.ts | 38 +- 8 files changed, 704 insertions(+), 2 deletions(-) create mode 100644 cms/config/sync/core-store.plugin_content_manager_configuration_content_types##api##objective.objective.json create mode 100644 cms/src/api/objective/content-types/objective/schema.json create mode 100644 cms/src/api/objective/controllers/objective.ts create mode 100644 cms/src/api/objective/documentation/1.0.0/objective.json create mode 100644 cms/src/api/objective/routes/objective.ts create mode 100644 cms/src/api/objective/services/objective.ts diff --git a/cms/config/sync/core-store.plugin_content_manager_configuration_content_types##api##objective.objective.json b/cms/config/sync/core-store.plugin_content_manager_configuration_content_types##api##objective.objective.json new file mode 100644 index 00000000..7e4167a8 --- /dev/null +++ b/cms/config/sync/core-store.plugin_content_manager_configuration_content_types##api##objective.objective.json @@ -0,0 +1,116 @@ +{ + "key": "plugin_content_manager_configuration_content_types::api::objective.objective", + "value": { + "uid": "api::objective.objective", + "settings": { + "bulkable": true, + "filterable": true, + "searchable": true, + "pageSize": 10, + "mainField": "type", + "defaultSortBy": "type", + "defaultSortOrder": "ASC" + }, + "metadatas": { + "id": { + "edit": {}, + "list": { + "label": "id", + "searchable": true, + "sortable": true + } + }, + "type": { + "edit": { + "label": "type", + "description": "", + "placeholder": "", + "visible": true, + "editable": true + }, + "list": { + "label": "type", + "searchable": true, + "sortable": true + } + }, + "createdAt": { + "edit": { + "label": "createdAt", + "description": "", + "placeholder": "", + "visible": false, + "editable": true + }, + "list": { + "label": "createdAt", + "searchable": true, + "sortable": true + } + }, + "updatedAt": { + "edit": { + "label": "updatedAt", + "description": "", + "placeholder": "", + "visible": false, + "editable": true + }, + "list": { + "label": "updatedAt", + "searchable": true, + "sortable": true + } + }, + "createdBy": { + "edit": { + "label": "createdBy", + "description": "", + "placeholder": "", + "visible": false, + "editable": true, + "mainField": "firstname" + }, + "list": { + "label": "createdBy", + "searchable": true, + "sortable": true + } + }, + "updatedBy": { + "edit": { + "label": "updatedBy", + "description": "", + "placeholder": "", + "visible": false, + "editable": true, + "mainField": "firstname" + }, + "list": { + "label": "updatedBy", + "searchable": true, + "sortable": true + } + } + }, + "layouts": { + "list": [ + "id", + "createdAt", + "updatedAt", + "type" + ], + "edit": [ + [ + { + "name": "type", + "size": 6 + } + ] + ] + } + }, + "type": "object", + "environment": null, + "tag": null +} \ No newline at end of file diff --git a/cms/src/api/objective/content-types/objective/schema.json b/cms/src/api/objective/content-types/objective/schema.json new file mode 100644 index 00000000..6291b658 --- /dev/null +++ b/cms/src/api/objective/content-types/objective/schema.json @@ -0,0 +1,19 @@ +{ + "kind": "collectionType", + "collectionName": "objectives", + "info": { + "singularName": "objective", + "pluralName": "objectives", + "displayName": "Objective", + "description": "" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": {}, + "attributes": { + "type": { + "type": "string" + } + } +} diff --git a/cms/src/api/objective/controllers/objective.ts b/cms/src/api/objective/controllers/objective.ts new file mode 100644 index 00000000..7cd09646 --- /dev/null +++ b/cms/src/api/objective/controllers/objective.ts @@ -0,0 +1,7 @@ +/** + * objective controller + */ + +import { factories } from '@strapi/strapi' + +export default factories.createCoreController('api::objective.objective'); diff --git a/cms/src/api/objective/documentation/1.0.0/objective.json b/cms/src/api/objective/documentation/1.0.0/objective.json new file mode 100644 index 00000000..a9137205 --- /dev/null +++ b/cms/src/api/objective/documentation/1.0.0/objective.json @@ -0,0 +1,508 @@ +{ + "/objectives": { + "get": { + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ObjectiveListResponse" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not Found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + }, + "tags": [ + "Objective" + ], + "parameters": [ + { + "name": "sort", + "in": "query", + "description": "Sort by attributes ascending (asc) or descending (desc)", + "deprecated": false, + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "pagination[withCount]", + "in": "query", + "description": "Return page/pageSize (default: true)", + "deprecated": false, + "required": false, + "schema": { + "type": "boolean" + } + }, + { + "name": "pagination[page]", + "in": "query", + "description": "Page number (default: 0)", + "deprecated": false, + "required": false, + "schema": { + "type": "integer" + } + }, + { + "name": "pagination[pageSize]", + "in": "query", + "description": "Page size (default: 25)", + "deprecated": false, + "required": false, + "schema": { + "type": "integer" + } + }, + { + "name": "pagination[start]", + "in": "query", + "description": "Offset value (default: 0)", + "deprecated": false, + "required": false, + "schema": { + "type": "integer" + } + }, + { + "name": "pagination[limit]", + "in": "query", + "description": "Number of entities to return (default: 25)", + "deprecated": false, + "required": false, + "schema": { + "type": "integer" + } + }, + { + "name": "fields", + "in": "query", + "description": "Fields to return (ex: title,author)", + "deprecated": false, + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "populate", + "in": "query", + "description": "Relations to return", + "deprecated": false, + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "filters", + "in": "query", + "description": "Filters to apply", + "deprecated": false, + "required": false, + "schema": { + "type": "object", + "additionalProperties": true + }, + "style": "deepObject" + }, + { + "name": "locale", + "in": "query", + "description": "Locale to apply", + "deprecated": false, + "required": false, + "schema": { + "type": "string" + } + } + ], + "operationId": "get/objectives" + }, + "post": { + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ObjectiveResponse" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not Found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + }, + "tags": [ + "Objective" + ], + "parameters": [], + "operationId": "post/objectives", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ObjectiveRequest" + } + } + } + } + } + }, + "/objectives/{id}": { + "get": { + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ObjectiveResponse" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not Found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + }, + "tags": [ + "Objective" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "description": "", + "deprecated": false, + "required": true, + "schema": { + "type": "number" + } + } + ], + "operationId": "get/objectives/{id}" + }, + "put": { + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ObjectiveResponse" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not Found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + }, + "tags": [ + "Objective" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "description": "", + "deprecated": false, + "required": true, + "schema": { + "type": "number" + } + } + ], + "operationId": "put/objectives/{id}", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ObjectiveRequest" + } + } + } + } + }, + "delete": { + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "404": { + "description": "Not Found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + } + } + }, + "tags": [ + "Objective" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "description": "", + "deprecated": false, + "required": true, + "schema": { + "type": "number" + } + } + ], + "operationId": "delete/objectives/{id}" + } + } +} diff --git a/cms/src/api/objective/routes/objective.ts b/cms/src/api/objective/routes/objective.ts new file mode 100644 index 00000000..ab06a100 --- /dev/null +++ b/cms/src/api/objective/routes/objective.ts @@ -0,0 +1,7 @@ +/** + * objective router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::objective.objective'); diff --git a/cms/src/api/objective/services/objective.ts b/cms/src/api/objective/services/objective.ts new file mode 100644 index 00000000..4ccd7437 --- /dev/null +++ b/cms/src/api/objective/services/objective.ts @@ -0,0 +1,7 @@ +/** + * objective service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::objective.objective'); diff --git a/cms/src/api/project/content-types/project/schema.json b/cms/src/api/project/content-types/project/schema.json index f3785dca..7efb3f8f 100644 --- a/cms/src/api/project/content-types/project/schema.json +++ b/cms/src/api/project/content-types/project/schema.json @@ -52,7 +52,9 @@ "type": "string" }, "objective": { - "type": "text" + "type": "relation", + "relation": "oneToOne", + "target": "api::objective.objective" }, "info": { "type": "string" diff --git a/cms/types/generated/contentTypes.d.ts b/cms/types/generated/contentTypes.d.ts index cba7dabe..ae359cd3 100644 --- a/cms/types/generated/contentTypes.d.ts +++ b/cms/types/generated/contentTypes.d.ts @@ -1101,6 +1101,37 @@ export interface ApiLayerLayer extends Schema.CollectionType { }; } +export interface ApiObjectiveObjective extends Schema.CollectionType { + collectionName: 'objectives'; + info: { + singularName: 'objective'; + pluralName: 'objectives'; + displayName: 'Objective'; + description: ''; + }; + options: { + draftAndPublish: true; + }; + attributes: { + type: Attribute.String; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + publishedAt: Attribute.DateTime; + createdBy: Attribute.Relation< + 'api::objective.objective', + 'oneToOne', + 'admin::user' + > & + Attribute.Private; + updatedBy: Attribute.Relation< + 'api::objective.objective', + 'oneToOne', + 'admin::user' + > & + Attribute.Private; + }; +} + export interface ApiOrganizationTypeOrganizationType extends Schema.CollectionType { collectionName: 'organization_types'; @@ -1282,7 +1313,11 @@ export interface ApiProjectProject extends Schema.CollectionType { status: Attribute.String; source_country: Attribute.String; organization_type: Attribute.String; - objective: Attribute.Text; + objective: Attribute.Relation< + 'api::project.project', + 'oneToOne', + 'api::objective.objective' + >; info: Attribute.String; project_edit_suggestions: Attribute.Relation< 'api::project.project', @@ -1659,6 +1694,7 @@ declare module '@strapi/types' { 'api::dataset-value.dataset-value': ApiDatasetValueDatasetValue; 'api::download-email.download-email': ApiDownloadEmailDownloadEmail; 'api::layer.layer': ApiLayerLayer; + 'api::objective.objective': ApiObjectiveObjective; 'api::organization-type.organization-type': ApiOrganizationTypeOrganizationType; 'api::other-tool.other-tool': ApiOtherToolOtherTool; 'api::other-tools-category.other-tools-category': ApiOtherToolsCategoryOtherToolsCategory;