From e3144966c6a7350179af8dd741fd7c958fa6023a Mon Sep 17 00:00:00 2001 From: Tim Haasdyk Date: Thu, 24 Oct 2024 09:13:55 +0200 Subject: [PATCH] Hide actions if no projects to select --- .../lib/components/modals/FormModal.svelte | 19 +++++++++++-------- frontend/src/lib/i18n/locales/en.json | 1 + .../[org_id]/AddMyProjectsToOrgModal.svelte | 8 +++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/frontend/src/lib/components/modals/FormModal.svelte b/frontend/src/lib/components/modals/FormModal.svelte index 071b986f1..3372e7db9 100644 --- a/frontend/src/lib/components/modals/FormModal.svelte +++ b/frontend/src/lib/components/modals/FormModal.svelte @@ -28,6 +28,7 @@ export let schema: Schema; export let submitVariant: SubmitVariant = 'btn-primary'; + export let hideActions: boolean = false; const superForm = lexSuperForm(schema, () => modal.submitModal()); const { form: _form, errors, reset, message, enhance, formState, tainted } = superForm; @@ -97,14 +98,16 @@ - {#if !done} - - - - {:else} - + {#if !hideActions} + {#if !done} + + + + {:else} + + {/if} {/if} diff --git a/frontend/src/lib/i18n/locales/en.json b/frontend/src/lib/i18n/locales/en.json index 96e00099f..7df8cdb59 100644 --- a/frontend/src/lib/i18n/locales/en.json +++ b/frontend/src/lib/i18n/locales/en.json @@ -283,6 +283,7 @@ Lexbox is free and [open source](https://github.com/sillsdev/languageforge-lexbo "submit_button": "Add Projects", "all_projects_already_added": "The {count, plural, one {# project} other {# projects}} you manage {count, plural, one {is} other {are}} already in this organization", "no_projects_managed": "You don't manage any projects", + "no_projects_selected": "No projects selected", }, "bulk_add_members": { "add_button": "Bulk Add Members", diff --git a/frontend/src/routes/(authenticated)/org/[org_id]/AddMyProjectsToOrgModal.svelte b/frontend/src/routes/(authenticated)/org/[org_id]/AddMyProjectsToOrgModal.svelte index 49dca4d79..224c5d031 100644 --- a/frontend/src/routes/(authenticated)/org/[org_id]/AddMyProjectsToOrgModal.svelte +++ b/frontend/src/routes/(authenticated)/org/[org_id]/AddMyProjectsToOrgModal.svelte @@ -39,10 +39,12 @@ } else { newProjects.push(proj); } - }) + }); const { response } = await formModal.open(undefined, async () => { - if (!selectedProjects.length) return 'No projects selected'; + if (!selectedProjects.length) { + return $t('org_page.add_my_projects.no_projects_selected'); + } const result = await _addProjectsToOrg(org.id as UUID, selectedProjects); if (result.error?.message) return result.error.message; }); @@ -58,7 +60,7 @@ - + {$t('org_page.add_my_projects.title')}