Files
speckle-server/packages/frontend-2/components/projects/AddDialog.vue
T
andrewwallacespeckle e3f90377b5 feat(fe2): workspace project list (#2616)
* Create and Use ProjectList

* ProjectList and WorkspaceList

* Workspace Header

* Header Actions Menu

* Add projects to Workspace

* Add middleware

* Remove unused title

* Rename WorkspaceList

* useDebouncedSearch

* Merge ProjectList into Dashboard

* Make workspaceId reactive

* Remove unneeded useSubscription

* Merge Dashboard into index

* Add fragments

* Cache updates

* gql

* GQL

* Linting updates

* Updates from CR

* Changes from CR

* Changes from PR. Middleware added

* Updates from CR

* GQL

* Updates from CR

* Updates from CR

* Updates from CR

* Add id to WorkspaceHeader_Workspace

* GQL

* Fragment naming

* Use identifier

* Comment buttons not yet ready

* Fix problem with pagination
2024-08-14 15:21:38 +01:00

93 lines
2.4 KiB
Vue

<template>
<LayoutDialog v-model:open="open" max-width="sm" :buttons="dialogButtons">
<template #header>Create new project</template>
<form class="flex flex-col text-foreground" @submit="onSubmit">
<div class="flex flex-col gap-3 mb-6">
<FormTextInput
name="name"
label="Project name"
placeholder="Project name"
color="foundation"
:rules="[isRequired, isStringOfLength({ maxLength: 512 })]"
show-required
auto-focus
autocomplete="off"
/>
<FormTextArea
name="description"
label="Project description"
placeholder="Description (optional)"
color="foundation"
size="lg"
:rules="[isStringOfLength({ maxLength: 65536 })]"
/>
</div>
<h3 class="label mb-3">Access permissions</h3>
<ProjectVisibilitySelect
v-model="visibility"
class="sm:max-w-none w-full"
mount-menu-on-body
/>
</form>
</LayoutDialog>
</template>
<script setup lang="ts">
import type { LayoutDialogButton } from '@speckle/ui-components'
import { useForm } from 'vee-validate'
import { ProjectVisibility } from '~~/lib/common/generated/gql/graphql'
import { isRequired, isStringOfLength } from '~~/lib/common/helpers/validation'
import { useMixpanel } from '~~/lib/core/composables/mp'
import { useCreateProject } from '~~/lib/projects/composables/projectManagement'
type FormValues = {
name: string
description?: string
}
const props = defineProps<{
workspaceId?: string
}>()
const emit = defineEmits<{
(e: 'created'): void
}>()
const createProject = useCreateProject()
const { handleSubmit } = useForm<FormValues>()
const visibility = ref(ProjectVisibility.Unlisted)
const open = defineModel<boolean>('open', { required: true })
const mp = useMixpanel()
const onSubmit = handleSubmit(async (values) => {
await createProject({
...values,
visibility: visibility.value,
workspaceId: props.workspaceId
})
emit('created')
mp.track('Stream Action', { type: 'action', name: 'create' })
open.value = false
})
const dialogButtons = computed((): LayoutDialogButton[] => [
{
text: 'Cancel',
props: { color: 'outline', fullWidth: true },
onClick: () => {
open.value = false
}
},
{
text: 'Create',
props: {
fullWidth: true,
submit: true
},
onClick: onSubmit
}
])
</script>