Skip to content

Commit

Permalink
Hide actions if no projects to select
Browse files Browse the repository at this point in the history
  • Loading branch information
myieye committed Oct 24, 2024
1 parent b882a12 commit e314496
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
19 changes: 11 additions & 8 deletions frontend/src/lib/components/modals/FormModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -97,14 +98,16 @@
<slot name="extraActions" />
</svelte:fragment>
<svelte:fragment slot="actions" let:submitting>
{#if !done}
<SubmitButton form="modalForm" variant={submitVariant} loading={submitting}>
<slot name="submitText" />
</SubmitButton>
{:else}
<Button variant="btn-primary" on:click={close}>
<slot name="closeText" />
</Button>
{#if !hideActions}
{#if !done}
<SubmitButton form="modalForm" variant={submitVariant} loading={submitting}>
<slot name="submitText" />
</SubmitButton>
{:else}
<Button variant="btn-primary" on:click={close}>
<slot name="closeText" />
</Button>
{/if}
{/if}
</svelte:fragment>
</Modal>
1 change: 1 addition & 0 deletions frontend/src/lib/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand All @@ -58,7 +60,7 @@
<span class="i-mdi-plus text-2xl" />
</Button>

<FormModal bind:this={formModal} {schema}>
<FormModal bind:this={formModal} {schema} hideActions={!newProjects.length}>
<span slot="title">
{$t('org_page.add_my_projects.title')}
</span>
Expand Down

0 comments on commit e314496

Please sign in to comment.