From 0ea0e94af74d500ba397dbe42669cbfc7c64c030 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Thu, 5 Dec 2024 12:01:34 +0100 Subject: [PATCH] feat: workshop 2 --- backend/ebios_rm/serializers.py | 2 +- backend/ebios_rm/views.py | 4 + frontend/messages/en.json | 9 +- .../src/lib/components/Forms/ModelForm.svelte | 3 + .../Forms/ModelForm/RoToForm.svelte | 93 +++++++++++++++ frontend/src/lib/utils/crud.ts | 18 +++ frontend/src/lib/utils/schemas.ts | 16 ++- frontend/src/lib/utils/table.ts | 18 +++ frontend/src/lib/utils/types.ts | 3 +- .../[model=urlmodel]/+page.server.ts | 9 +- .../[id=uuid]/+page.server.ts | 5 +- .../ebios-rm/[id=uuid]/+page.svelte | 18 ++- .../workshop-two/ro-to/+page.server.ts | 107 ++++++++++++++++++ .../[id=uuid]/workshop-two/ro-to/+page.svelte | 67 +++++++++++ 14 files changed, 361 insertions(+), 11 deletions(-) create mode 100644 frontend/src/lib/components/Forms/ModelForm/RoToForm.svelte create mode 100644 frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-two/ro-to/+page.server.ts create mode 100644 frontend/src/routes/(app)/(internal)/ebios-rm/[id=uuid]/workshop-two/ro-to/+page.svelte diff --git a/backend/ebios_rm/serializers.py b/backend/ebios_rm/serializers.py index 15da633fc..62ab8aa03 100644 --- a/backend/ebios_rm/serializers.py +++ b/backend/ebios_rm/serializers.py @@ -92,7 +92,7 @@ class RoToReadSerializer(BaseModelSerializer): str = serializers.CharField(source="__str__") ebios_rm_study = FieldsRelatedField() folder = FieldsRelatedField() - feared_events = FieldsRelatedField(many=True) + feared_events = FieldsRelatedField(["folder", "id"], many=True) class Meta: model = RoTo diff --git a/backend/ebios_rm/views.py b/backend/ebios_rm/views.py index af0360603..8fcaf6ce9 100644 --- a/backend/ebios_rm/views.py +++ b/backend/ebios_rm/views.py @@ -77,6 +77,10 @@ def gravity(self, request, pk): class RoToViewSet(BaseModelViewSet): model = RoTo + filterset_fields = [ + "ebios_rm_study", + ] + @action(detail=False, name="Get risk origin choices", url_path="risk-origin") def risk_origin(self, request): return Response(dict(RoTo.RiskOrigin.choices)) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 11b1f8bf3..707f7435e 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -384,7 +384,7 @@ "exportDatabase": "Export database", "upload": "Upload", "add": "Add", - "undefined": "--", + "undefined": "undefined", "production": "Production", "design": "Design", "development": "Development", @@ -937,5 +937,10 @@ "fearedEvent": "Feared event", "fearedEvents": "Feared events", "isSelected": "Is selected", - "ebiosRM": "Ebios RM" + "ebiosRM": "Ebios RM", + "riskOrigin": "Risk origin", + "targetObjective": "Target objective", + "motivation": "Motivation", + "resources": "Resources", + "pertinence": "Pertinence" } diff --git a/frontend/src/lib/components/Forms/ModelForm.svelte b/frontend/src/lib/components/Forms/ModelForm.svelte index 7f30a2a71..3866c9d84 100644 --- a/frontend/src/lib/components/Forms/ModelForm.svelte +++ b/frontend/src/lib/components/Forms/ModelForm.svelte @@ -28,6 +28,7 @@ import GeneralSettingsForm from './ModelForm/GeneralSettingForm.svelte'; import EbiosRmForm from './ModelForm/EbiosRmForm.svelte'; import FearedEventForm from './ModelForm/FearedEventForm.svelte'; + import RoToForm from './ModelForm/RoToForm.svelte'; import AutocompleteSelect from './AutocompleteSelect.svelte'; @@ -261,6 +262,8 @@ {:else if URLModel === 'feared-events'} + {:else if URLModel === 'ro-to'} + {/if}
{#if closeModal} diff --git a/frontend/src/lib/components/Forms/ModelForm/RoToForm.svelte b/frontend/src/lib/components/Forms/ModelForm/RoToForm.svelte new file mode 100644 index 000000000..cdbc7544e --- /dev/null +++ b/frontend/src/lib/components/Forms/ModelForm/RoToForm.svelte @@ -0,0 +1,93 @@ + + +