Skip to content

Commit

Permalink
#434: Add detailed information (observation title) in configuration e…
Browse files Browse the repository at this point in the history
…xception where the config is wrong.

* Update StudyManagerAPI yaml to be align with BE yaml.
  • Loading branch information
benitsch committed Aug 8, 2024
1 parent 27e5d1f commit b6ccff3
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 74 deletions.
117 changes: 53 additions & 64 deletions openapi/StudyManagerAPI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -1482,6 +1460,8 @@ components:
type: string
propertyId:
type: string
componentTitle:
type: string
type:
type: string

Expand Down Expand Up @@ -1565,7 +1545,6 @@ components:
- active
- paused
- closed
readOnly: true
default: draft

StudyGroup:
Expand Down Expand Up @@ -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
Expand Down
26 changes: 18 additions & 8 deletions src/composable/toastService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}': "
}
},

Expand Down
3 changes: 2 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}': "
}
},

Expand Down

0 comments on commit b6ccff3

Please sign in to comment.