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.
141 lines
3.7 KiB
141 lines
3.7 KiB
3 years ago
|
<template>
|
||
3 years ago
|
<div class="main justify-center d-flex" style="min-height: 600px; overflow: auto">
|
||
3 years ago
|
<v-form ref="form" v-model="valid" @submit.prevent="renameProject">
|
||
3 years ago
|
<v-card style="width: 530px; margin-top: 100px" class="mx-auto">
|
||
3 years ago
|
<div
|
||
3 years ago
|
style="
|
||
|
position: absolute;
|
||
|
top: -33px;
|
||
|
left: -moz-calc(50% - 33px);
|
||
|
left: -webkit-calc(50% - 33px);
|
||
|
left: calc(50% - 33px);
|
||
|
border-radius: 15px;
|
||
|
"
|
||
3 years ago
|
class="primary"
|
||
|
>
|
||
3 years ago
|
<v-img class="mx-auto" width="66" height="66" :src="require('~/assets/img/icons/512x512-trans.png')" />
|
||
3 years ago
|
</div>
|
||
|
|
||
3 years ago
|
<v-container fluid class="pb-10 px-12" style="padding-top: 43px !important">
|
||
3 years ago
|
<!-- Edit Project -->
|
||
|
<h1 class="mt-4 mb-4 text-center">
|
||
|
{{ $t('activity.editProject') }}
|
||
|
</h1>
|
||
3 years ago
|
<div class="mx-auto" style="width: 350px">
|
||
3 years ago
|
<!-- label="Enter Project Name" -->
|
||
|
<!-- rule text: Required -->
|
||
|
<v-text-field
|
||
|
ref="projectTitleInput"
|
||
|
v-model="projectTitle"
|
||
|
autofocus
|
||
|
:full-width="false"
|
||
|
class="nc-metadb-project-name"
|
||
|
:label="$t('placeholder.projName')"
|
||
|
:rules="form.titleValidationRule"
|
||
|
/>
|
||
|
</div>
|
||
|
<div class="text-center">
|
||
|
<v-btn
|
||
|
v-t="['a:project:edit:rename']"
|
||
|
class="mt-3"
|
||
|
large
|
||
|
:loading="loading"
|
||
|
color="primary"
|
||
|
@click="renameProject"
|
||
|
>
|
||
3 years ago
|
<v-icon class="mr-1 mt-n1"> mdi-rocket-launch-outline </v-icon>
|
||
3 years ago
|
<!-- Edit -->
|
||
|
<span class="mr-1">{{ $t('general.edit') }}</span>
|
||
|
</v-btn>
|
||
|
</div>
|
||
|
</v-container>
|
||
|
</v-card>
|
||
|
</v-form>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
import colors from '@/mixins/colors';
|
||
3 years ago
|
|
||
|
export default {
|
||
|
name: 'EditProject',
|
||
|
mixins: [colors],
|
||
|
data: () => ({
|
||
|
valid: null,
|
||
|
projectTitle: '',
|
||
|
loading: false,
|
||
|
projectType: 'rest',
|
||
|
form: {
|
||
|
titleValidationRule: [
|
||
|
v => !!v || 'Title is required',
|
||
3 years ago
|
v => (v && v.length <= 50) || 'Project name exceeds 50 characters',
|
||
3 years ago
|
],
|
||
|
},
|
||
|
}),
|
||
|
computed: {
|
||
|
pid() {
|
||
3 years ago
|
return this.$route.query.projectId;
|
||
3 years ago
|
},
|
||
|
},
|
||
|
async mounted() {
|
||
|
setTimeout(() => {
|
||
3 years ago
|
this.$refs.projectTitleInput.$el.querySelector('input').focus();
|
||
|
}, 100);
|
||
|
await this.getProject(this.pid);
|
||
3 years ago
|
},
|
||
|
methods: {
|
||
|
async getProject() {
|
||
|
try {
|
||
3 years ago
|
const result = await this.$api.project.read(this.pid);
|
||
|
this.$nextTick(() => {
|
||
|
this.projectTitle = result.title;
|
||
|
});
|
||
|
} catch (e) {
|
||
|
this.$toast.error(await this._extractSdkResponseErrorMsg(e)).goAway(3000);
|
||
|
}
|
||
3 years ago
|
},
|
||
|
async renameProject() {
|
||
|
if (this.$refs.form.validate()) {
|
||
3 years ago
|
this.loading = true;
|
||
3 years ago
|
try {
|
||
|
await this.$api.project.update(this.pid, {
|
||
3 years ago
|
title: this.projectTitle,
|
||
|
});
|
||
3 years ago
|
|
||
3 years ago
|
await this.$store.dispatch('project/ActLoadProjectInfo');
|
||
3 years ago
|
|
||
3 years ago
|
this.projectReloading = false;
|
||
3 years ago
|
|
||
|
this.$router.push({
|
||
|
path: `/nc/${this.pid}`,
|
||
|
query: {
|
||
3 years ago
|
new: 1,
|
||
|
},
|
||
|
});
|
||
3 years ago
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error(await this._extractSdkResponseErrorMsg(e)).goAway(3000);
|
||
3 years ago
|
}
|
||
3 years ago
|
this.loading = false;
|
||
3 years ago
|
} else {
|
||
3 years ago
|
this.$toast.error('Invalid Form');
|
||
3 years ago
|
}
|
||
3 years ago
|
},
|
||
|
},
|
||
|
};
|
||
3 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
/deep/ label {
|
||
3 years ago
|
font-size: 0.75rem;
|
||
3 years ago
|
}
|
||
|
|
||
|
.wrapper {
|
||
|
border: 2px solid var(--v-backgroundColor-base);
|
||
|
border-radius: 4px;
|
||
|
}
|
||
|
|
||
|
.main {
|
||
3 years ago
|
height: calc(100vh - 48px);
|
||
3 years ago
|
}
|
||
|
</style>
|