From b6ccff3e098cd160506d7e9c570e847227259d02 Mon Sep 17 00:00:00 2001 From: bnitsch Date: Tue, 6 Aug 2024 14:15:36 +0200 Subject: [PATCH] #434: Add detailed information (observation title) in configuration exception where the config is wrong. * Update StudyManagerAPI yaml to be align with BE yaml. --- openapi/StudyManagerAPI.yaml | 117 +++++++++++++++------------------ src/composable/toastService.ts | 26 +++++--- src/i18n/de.json | 3 +- src/i18n/en.json | 3 +- 4 files changed, 75 insertions(+), 74 deletions(-) diff --git a/openapi/StudyManagerAPI.yaml b/openapi/StudyManagerAPI.yaml index 71066ec..be8085c 100644 --- a/openapi/StudyManagerAPI.yaml +++ b/openapi/StudyManagerAPI.yaml @@ -11,21 +11,13 @@ servers: description: Local Test Server paths: /components/{componentType}: + parameters: + - $ref: '#/components/parameters/ComponentType' get: tags: - components operationId: listComponents description: List component of certain type - parameters: - - name: componentType - in: path - schema: - type: string - enum: - - action - - trigger - - observation - required: true responses: '200': description: Components successfully returned @@ -37,26 +29,18 @@ paths: $ref: '#/components/schemas/ComponentFactory' /components/{componentType}/{componentId}/validate: + parameters: + - $ref: '#/components/parameters/ComponentType' + - name: componentId + in: path + schema: + type: string + required: true post: tags: - components description: check if properties are valid for component operationId: validateProperties - parameters: - - name: componentType - in: path - schema: - type: string - enum: - - action - - trigger - - observation - required: true - - name: componentId - in: path - schema: - type: string - required: true requestBody: content: application/json: @@ -73,31 +57,23 @@ paths: description: Not found /components/{componentType}/{componentId}/api/{slug}: + parameters: + - $ref: '#/components/parameters/ComponentType' + - name: componentId + in: path + schema: + type: string + required: true + - name: slug + in: path + schema: + type: string + required: true post: tags: - components operationId: accessModuleSpecificEndpoint description: access module specific endpoint - parameters: - - name: componentType - in: path - schema: - type: string - enum: - - action - - trigger - - observation - required: true - - name: componentId - in: path - schema: - type: string - required: true - - name: slug - in: path - schema: - type: string - required: true requestBody: required: true content: @@ -117,26 +93,18 @@ paths: description: Error /components/{componentType}/{componentId}/web-component.js: + parameters: + - $ref: '#/components/parameters/ComponentType' + - name: componentId + in: path + schema: + type: string + required: true get: tags: - components operationId: getWebComponentScript description: Get web component script - parameters: - - name: componentType - in: path - schema: - type: string - enum: - - action - - trigger - - observation - required: true - - name: componentId - in: path - schema: - type: string - required: true responses: '200': description: Returned script successfully @@ -253,10 +221,20 @@ paths: schema: $ref: '#/components/schemas/StatusChange' responses: - '202': - description: Status changed deleted + '200': + description: Study status changed + content: + application/json: + schema: + $ref: '#/components/schemas/Study' '400': - description: Bad request + description: The requested transition is not allowed + '409': + description: Could not update status due to configuration error + content: + application/json: + schema: + $ref: '#/components/schemas/ValidationReport' /studies/{studyId}/collaborators: parameters: @@ -1482,6 +1460,8 @@ components: type: string propertyId: type: string + componentTitle: + type: string type: type: string @@ -1565,7 +1545,6 @@ components: - active - paused - closed - readOnly: true default: draft StudyGroup: @@ -2226,6 +2205,16 @@ components: additionalProperties: true parameters: + ComponentType: + name: componentType + in: path + schema: + type: string + enum: + - action + - trigger + - observation + required: true StudyId: name: studyId in: path diff --git a/src/composable/toastService.ts b/src/composable/toastService.ts index 00be450..193d444 100644 --- a/src/composable/toastService.ts +++ b/src/composable/toastService.ts @@ -37,19 +37,29 @@ export function useToastService(): any { const warnings: string[] = []; report.errors?.forEach((error: ValidationReportItem) => { - const errorMessage = error.message - ? t(error.message, { value: error.propertyId }) - : null; - if (errorMessage) { + let errorMessage = ''; + + if (error.message) { + if (error.componentTitle) { + errorMessage = t('global.error.inComponentTitle', { + title: error.componentTitle, + }); + } + errorMessage += t(error.message, { value: error.propertyId }); errors.push(errorMessage); } }); report.warnings?.forEach((warning: ValidationReportItem) => { - const warningMessage = warning.message - ? t(warning.message, { value: warning.propertyId }) - : null; - if (warningMessage) { + let warningMessage = ''; + + if (warning.message) { + if (warning.componentTitle) { + warningMessage = t('global.error.inComponentTitle', { + title: warning.componentTitle, + }); + } + warningMessage += t(warning.message, { value: warning.propertyId }); warnings.push(warningMessage); } }); diff --git a/src/i18n/de.json b/src/i18n/de.json index 64e94b5..bb14525 100644 --- a/src/i18n/de.json +++ b/src/i18n/de.json @@ -64,7 +64,8 @@ }, "general": "Ein allgemeiner Fehler ist aufgetreten.", "required": "Erforderlicher Wert '{value}' fehlt.", - "immutable": "Der Wert von '{value}' darf nicht geändert werden." + "immutable": "Der Wert von '{value}' darf nicht geändert werden.", + "inComponentTitle": "In Aufzeichnung '{title}': " } }, diff --git a/src/i18n/en.json b/src/i18n/en.json index ca889c3..a3a3895 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -64,7 +64,8 @@ }, "general": "A General error occurred.", "required": "Required value '{value}' missing.", - "immutable": "The value '{value}' is immutable and cannot be changed." + "immutable": "The value '{value}' is immutable and cannot be changed.", + "inComponentTitle": "In Observation '{title}': " } },