mirror of
https://github.com/nocodb/nocodb.git
synced 2026-04-30 03:46:35 +00:00
refactor(gui): linting
Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com>
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
<template>
|
||||
<v-dialog v-model="localState" max-width="500">
|
||||
<v-card class="elevation-20">
|
||||
<v-card-title class="grey darken-2 subheading" style="height:30px">
|
||||
</v-card-title>
|
||||
<v-card-title class="grey darken-2 subheading" style="height:30px" />
|
||||
<v-card-text class="pt-4 pl-4">
|
||||
<p class="headline">
|
||||
Create <span class="text-capitalize">{{ show_as }}</span> View
|
||||
@@ -10,16 +9,15 @@
|
||||
<v-form ref="form" v-model="valid" @submit.prevent="createView">
|
||||
<v-text-field
|
||||
ref="name"
|
||||
v-model="view_name"
|
||||
label="View Name"
|
||||
:rules="[v=>!!v || 'View name required']"
|
||||
v-model="view_name"
|
||||
autofocus
|
||||
></v-text-field>
|
||||
|
||||
/>
|
||||
</v-form>
|
||||
</v-card-text>
|
||||
<v-card-actions class="pa-4">
|
||||
<v-spacer></v-spacer>
|
||||
<v-spacer />
|
||||
<v-btn class="" small @click="$emit('input',false)">
|
||||
Cancel
|
||||
</v-btn>
|
||||
@@ -27,9 +25,10 @@
|
||||
small
|
||||
:loading="loading"
|
||||
class="primary "
|
||||
@click="createView"
|
||||
:disabled="!valid"
|
||||
>Submit
|
||||
@click="createView"
|
||||
>
|
||||
Submit
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
@@ -37,21 +36,30 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import table from "@/components/project/table";
|
||||
|
||||
export default {
|
||||
name: 'CreateViewDialog',
|
||||
props: ['value', 'nodes', 'table', 'alias', 'show_as', 'viewsCount', 'primaryValueColumn', 'meta', 'copyView'],
|
||||
name: "createViewDialog",
|
||||
data: () => ({
|
||||
valid: false,
|
||||
view_name: '',
|
||||
loading: false,
|
||||
queryParams: {}
|
||||
}),
|
||||
mounted() {
|
||||
computed: {
|
||||
localState: {
|
||||
get () {
|
||||
return this.value
|
||||
},
|
||||
set (v) {
|
||||
this.$emit('input', v)
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
try {
|
||||
if (this.copyView && this.copyView.query_params) {
|
||||
this.queryParams = {...JSON.parse(this.copyView.query_params)};
|
||||
this.queryParams = { ...JSON.parse(this.copyView.query_params) }
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -59,40 +67,31 @@ export default {
|
||||
this.view_name = `${this.alias || this.table}${this.viewsCount}`
|
||||
|
||||
this.$nextTick(() => {
|
||||
const input = this.$refs.name.$el.querySelector('input');
|
||||
const input = this.$refs.name.$el.querySelector('input')
|
||||
input.setSelectionRange(0, this.view_name.length)
|
||||
input.focus();
|
||||
input.focus()
|
||||
})
|
||||
},
|
||||
computed: {
|
||||
localState: {
|
||||
get() {
|
||||
return this.value;
|
||||
}, set(v) {
|
||||
this.$emit('input', v);
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async createView() {
|
||||
let showFields = null;
|
||||
async createView () {
|
||||
let showFields = null
|
||||
|
||||
if (this.show_as === 'gallery') {
|
||||
showFields = {[this.primaryValueColumn]: true};
|
||||
const attachmentCol = this.meta.columns.find(c => c.uidt === "Attachment");
|
||||
showFields = { [this.primaryValueColumn]: true }
|
||||
const attachmentCol = this.meta.columns.find(c => c.uidt === 'Attachment')
|
||||
if (attachmentCol) {
|
||||
showFields[attachmentCol.cn] = true;
|
||||
showFields[attachmentCol.cn] = true
|
||||
}
|
||||
this.meta.columns.forEach(c => {
|
||||
this.meta.columns.forEach((c) => {
|
||||
if (c.pk) {
|
||||
showFields[c.cn] = true;
|
||||
showFields[c.cn] = true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
this.loading = true
|
||||
try {
|
||||
const view_meta = await this.sqlOp({
|
||||
const viewMeta = await this.sqlOp({
|
||||
dbAlias: this.nodes.dbAlias
|
||||
}, 'xcVirtualTableCreate', {
|
||||
title: this.view_name,
|
||||
@@ -103,13 +102,13 @@ export default {
|
||||
parent_model_title: this.table,
|
||||
show_as: this.show_as
|
||||
})
|
||||
this.$toast.success('View created successfully').goAway(3000);
|
||||
this.$emit('created', view_meta);
|
||||
this.$emit('input', false);
|
||||
this.$toast.success('View created successfully').goAway(3000)
|
||||
this.$emit('created', viewMeta)
|
||||
this.$emit('input', false)
|
||||
} catch (e) {
|
||||
this.$toast.error(e.message).goAway(3000);
|
||||
this.$toast.error(e.message).goAway(3000)
|
||||
}
|
||||
this.loading = false;
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user