mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
2.8 KiB
111 lines
2.8 KiB
2 years ago
|
<script lang="ts" setup>
|
||
|
import type { Form } from 'ant-design-vue'
|
||
2 years ago
|
import type { ProjectType } from 'nocodb-sdk'
|
||
2 years ago
|
import type { VNodeRef } from '@vue/runtime-core'
|
||
2 years ago
|
import type { RuleObject } from 'ant-design-vue/es/form'
|
||
2 years ago
|
import {
|
||
|
extractSdkResponseErrorMsg,
|
||
2 years ago
|
iconMap,
|
||
2 years ago
|
message,
|
||
2 years ago
|
navigateTo,
|
||
|
projectTitleValidator,
|
||
|
reactive,
|
||
|
ref,
|
||
2 years ago
|
storeToRefs,
|
||
2 years ago
|
useProject,
|
||
2 years ago
|
useRoute,
|
||
|
} from '#imports'
|
||
2 years ago
|
|
||
|
const route = useRoute()
|
||
|
|
||
2 years ago
|
const projectStore = useProject()
|
||
|
|
||
2 years ago
|
const { loadProject, updateProject } = projectStore
|
||
|
const { project, isLoading } = storeToRefs(projectStore)
|
||
2 years ago
|
|
||
2 years ago
|
const nameValidationRules = [
|
||
|
{
|
||
|
required: true,
|
||
2 years ago
|
message: 'Project name is required',
|
||
2 years ago
|
},
|
||
|
projectTitleValidator,
|
||
2 years ago
|
] as RuleObject[]
|
||
2 years ago
|
|
||
2 years ago
|
const form = ref<typeof Form>()
|
||
|
|
||
2 years ago
|
const formState = reactive<Partial<ProjectType>>({
|
||
2 years ago
|
title: '',
|
||
|
})
|
||
|
|
||
|
const renameProject = async () => {
|
||
|
try {
|
||
2 years ago
|
await updateProject(formState)
|
||
2 years ago
|
|
||
2 years ago
|
navigateTo(`/nc/${route.params.projectId}`)
|
||
2 years ago
|
} catch (e: any) {
|
||
2 years ago
|
message.error(await extractSdkResponseErrorMsg(e))
|
||
2 years ago
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
onBeforeMount(async () => {
|
||
|
await loadProject(false)
|
||
|
|
||
|
formState.title = project.value?.title
|
||
|
})
|
||
|
|
||
2 years ago
|
const focus: VNodeRef = (el) => (el as HTMLInputElement)?.focus()
|
||
2 years ago
|
</script>
|
||
|
|
||
|
<template>
|
||
2 years ago
|
<div
|
||
2 years ago
|
class="update-project relative flex-auto flex flex-col justify-center gap-2 p-8 md:(bg-white rounded-lg border-1 border-gray-200 shadow)"
|
||
2 years ago
|
>
|
||
2 years ago
|
<LazyGeneralNocoIcon class="color-transition hover:(ring ring-accent)" :animate="isLoading" />
|
||
2 years ago
|
|
||
2 years ago
|
<div
|
||
2 years ago
|
class="color-transition transform group absolute top-5 left-5 text-4xl rounded-full cursor-pointer"
|
||
2 years ago
|
@click="navigateTo('/')"
|
||
2 years ago
|
>
|
||
2 years ago
|
<component :is="iconMap.chevronLeft" class="text-black group-hover:(text-accent scale-110)" />
|
||
2 years ago
|
</div>
|
||
2 years ago
|
|
||
|
<h1 class="prose-2xl font-bold self-center my-4">{{ $t('activity.editProject') }}</h1>
|
||
|
|
||
2 years ago
|
<a-skeleton v-if="isLoading" />
|
||
2 years ago
|
|
||
2 years ago
|
<a-form
|
||
2 years ago
|
v-else
|
||
2 years ago
|
ref="form"
|
||
|
:model="formState"
|
||
|
name="basic"
|
||
|
layout="vertical"
|
||
|
class="lg:max-w-3/4 w-full !mx-auto"
|
||
|
no-style
|
||
|
autocomplete="off"
|
||
|
@finish="renameProject"
|
||
|
>
|
||
2 years ago
|
<a-form-item :label="$t('labels.projName')" name="title" :rules="nameValidationRules">
|
||
2 years ago
|
<a-input :ref="focus" v-model:value="formState.title" name="title" class="nc-metadb-project-name" />
|
||
2 years ago
|
</a-form-item>
|
||
|
|
||
|
<div class="text-center">
|
||
2 years ago
|
<button v-e="['a:project:edit:rename']" type="submit" class="scaling-btn bg-opacity-100">
|
||
2 years ago
|
<span class="flex items-center gap-2">
|
||
|
<MaterialSymbolsRocketLaunchOutline />
|
||
|
{{ $t('general.edit') }}
|
||
|
</span>
|
||
|
</button>
|
||
|
</div>
|
||
|
</a-form>
|
||
2 years ago
|
</div>
|
||
2 years ago
|
</template>
|
||
2 years ago
|
|
||
2 years ago
|
<style lang="scss" scoped>
|
||
2 years ago
|
.update-project {
|
||
|
.ant-input-affix-wrapper,
|
||
|
.ant-input {
|
||
2 years ago
|
@apply !appearance-none my-1 border-1 border-solid border-primary border-opacity-50 rounded;
|
||
2 years ago
|
}
|
||
|
}
|
||
|
</style>
|