fix: some other forms

This commit is contained in:
Torsten Dittmann committed 2023-03-20 13:15:18 +01:00
1 parent e091f99416
commit 2c2b4ce28a
3 files changed
+7 -25

No files matched your search

+1 -5
View File
@@ -15,11 +15,9 @@
let name: string;
let id: string;
let showCustomId = false;
let loading = false;
async function createProject() {
try {
loading = true;
const org = await createOrganization();
const project = await sdk.forConsole.projects.create(
id ?? ID.unique(),
@@ -34,7 +32,6 @@
teamId: org.$id
});
} catch (error) {
loading = false;
addNotification({
message: error.message,
type: 'error'
@@ -57,7 +54,6 @@
label="Project name"
placeholder="First Appwrite Project"
required
disabled={loading}
bind:value={name} />
{#if !showCustomId}
<div>
@@ -70,7 +66,7 @@
{:else}
<CustomId bind:show={showCustomId} name="Project" bind:id />
{/if}
<Button fullWidth submit disabled={loading || name === ''} event="create_project">
<Button fullWidth submit disabled={name === ''} event="create_project">
Create project
</Button>
</FormList>
@@ -18,11 +18,9 @@
let name: string;
let showCustomId = false;
let error: string;
let isCreating = false;
async function create() {
try {
isCreating = true;
const project = await sdk.forConsole.projects.create(
id ?? ID.unique(),
name,
@@ -40,7 +38,6 @@
});
await goto(`/console/project-${project.$id}`);
} catch (e) {
isCreating = false;
error = e.message;
trackError(e, Submit.ProjectCreate);
}
@@ -50,13 +47,7 @@
<Modal {error} onSubmit={create} size="big" bind:show>
<svelte:fragment slot="header">Create Project</svelte:fragment>
<FormList>
<InputText
id="name"
label="Name"
bind:value={name}
required
autofocus={true}
disabled={isCreating} />
<InputText id="name" label="Name" bind:value={name} required autofocus={true} />
{#if !showCustomId}
<div>
<Pill button on:click={() => (showCustomId = !showCustomId)}>
@@ -71,6 +62,6 @@
</FormList>
<svelte:fragment slot="footer">
<Button secondary on:click={() => (show = false)}>Cancel</Button>
<Button submit disabled={isCreating}>Create</Button>
<Button submit>Create</Button>
</svelte:fragment>
</Modal>
@@ -31,8 +31,8 @@
value: attribute.key,
label: attribute.key
}));
let attributeList = [{ value: '', order: '' }];
let creating = false;
function initialize() {
attributeList = externalAttribute
@@ -47,8 +47,7 @@
initialize();
}
$: addAttributeDisabled =
!attributeList.at(-1)?.value || !attributeList.at(-1)?.order || creating;
$: addAttributeDisabled = !attributeList.at(-1)?.value || !attributeList.at(-1)?.order;
async function create() {
if (!(key && selectedType && !addAttributeDisabled)) {
@@ -56,8 +55,6 @@
return;
}
creating = true;
try {
await sdk.forProject.databases.createIndex(
databaseId,
@@ -81,15 +78,13 @@
type: 'success'
});
trackEvent(Submit.IndexCreate);
showCreateIndex = false;
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.IndexCreate);
} finally {
showCreateIndex = false;
creating = false;
}
}
@@ -156,6 +151,6 @@
</FormList>
<svelte:fragment slot="footer">
<Button secondary on:click={() => (showCreateIndex = false)}>Cancel</Button>
<Button submit disabled={creating}>Create</Button>
<Button submit>Create</Button>
</svelte:fragment>
</Modal>