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.
1226 lines
41 KiB
1226 lines
41 KiB
4 years ago
|
<template>
|
||
|
<div class="">
|
||
3 years ago
|
<v-overlay v-if="isMetaTable" absolute>
|
||
3 years ago
|
<v-alert type="info"> Meta tables are not editable </v-alert>
|
||
4 years ago
|
</v-overlay>
|
||
|
<v-card class="elevation-0">
|
||
|
<v-toolbar height="42" flat class="toolbar-border-bottom">
|
||
|
<v-toolbar-title>
|
||
3 years ago
|
<v-breadcrumbs
|
||
3 years ago
|
:items="[
|
||
|
{
|
||
|
text: nodes.env,
|
||
|
disabled: true,
|
||
|
href: '#',
|
||
|
},
|
||
|
{
|
||
|
text: nodes.dbAlias,
|
||
|
disabled: true,
|
||
|
href: '#',
|
||
|
},
|
||
|
{
|
||
|
text: nodes.title + ' (table)',
|
||
|
disabled: true,
|
||
|
href: '#',
|
||
|
},
|
||
|
]"
|
||
3 years ago
|
divider=">"
|
||
|
small
|
||
|
class="title"
|
||
|
>
|
||
|
<template #divider>
|
||
3 years ago
|
<v-icon small color="grey lighten-2"> forward </v-icon>
|
||
4 years ago
|
</template>
|
||
|
</v-breadcrumbs>
|
||
|
</v-toolbar-title>
|
||
3 years ago
|
<v-spacer />
|
||
4 years ago
|
|
||
3 years ago
|
<x-btn
|
||
3 years ago
|
v-ge="['columns', 'reload']"
|
||
3 years ago
|
tooltip="Reload Columns from database"
|
||
|
outlined
|
||
|
color="primary"
|
||
|
small
|
||
|
@click="reload"
|
||
4 years ago
|
>
|
||
3 years ago
|
<v-icon small left> refresh </v-icon>
|
||
4 years ago
|
Re<u>l</u>oad
|
||
|
</x-btn>
|
||
3 years ago
|
<x-btn v-ge="['columns', 'new']" tooltip="Adds new column" outlined color="primary" small @click="addColumn">
|
||
|
<v-icon small> mdi-plus </v-icon> <u>N</u>ew Column
|
||
3 years ago
|
</x-btn>
|
||
4 years ago
|
|
||
|
<x-btn
|
||
3 years ago
|
v-if="$store.state.settings.scaffoldOnSave && projectIsGraphql && !isNoApis"
|
||
3 years ago
|
v-ge="['columns', 'save-and-scaffold']"
|
||
4 years ago
|
tooltip="Save & Scaffold Changes"
|
||
|
outlined
|
||
|
color="primary"
|
||
|
small
|
||
|
:disabled="(!edited && !newTable) || isMetaTable"
|
||
|
@click="applyChangesDirectGql"
|
||
|
>
|
||
3 years ago
|
<v-icon small> mdi-content-save </v-icon> <u>S</u>ave & Scaffold
|
||
4 years ago
|
</x-btn>
|
||
|
|
||
|
<x-btn
|
||
3 years ago
|
v-else-if="$store.state.settings.scaffoldOnSave && !isNoApis"
|
||
3 years ago
|
v-ge="['columns', 'save-and-scaffold']"
|
||
4 years ago
|
tooltip="Save & Scaffold Changes"
|
||
|
outlined
|
||
|
color="primary"
|
||
|
small
|
||
|
:disabled="(!edited && !newTable) || isMetaTable"
|
||
|
@click="applyChangesDirect"
|
||
|
>
|
||
3 years ago
|
<v-icon small> mdi-content-save </v-icon> <u>S</u>ave & Scaffold
|
||
4 years ago
|
</x-btn>
|
||
|
<x-btn
|
||
|
v-else
|
||
3 years ago
|
v-ge="['columns', 'save']"
|
||
3 years ago
|
:tooltip="$t('tooltip.saveChanges')"
|
||
4 years ago
|
outlined
|
||
|
color="primary"
|
||
|
small
|
||
|
:disabled="(!edited && !newTable) || isMetaTable"
|
||
|
@click="applyChanges"
|
||
3 years ago
|
>
|
||
3 years ago
|
<v-icon small> mdi-content-save </v-icon> <u>S</u>ave
|
||
4 years ago
|
</x-btn>
|
||
3 years ago
|
<x-btn
|
||
3 years ago
|
v-ge="['columns', 'table-delete']"
|
||
3 years ago
|
tooltip="Deletes Table"
|
||
|
outlined
|
||
|
small
|
||
|
color="error "
|
||
|
class="text-right"
|
||
|
@click="deleteTable('showDialog')"
|
||
|
>
|
||
3 years ago
|
<v-icon small> mdi-delete-outline </v-icon> <u>D</u>elete Table
|
||
4 years ago
|
</x-btn>
|
||
|
<v-menu open-on-hover offset-y primary>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
3 years ago
|
<v-btn outlined small color="primary" dark class="font-weight-bold" v-on="on">
|
||
4 years ago
|
Actions
|
||
|
<v-icon>mdi-menu-down</v-icon>
|
||
|
</v-btn>
|
||
|
</template>
|
||
|
|
||
|
<v-list dense>
|
||
|
<template v-if="!isNoApis && isMvc">
|
||
3 years ago
|
<template v-if="projectIsGraphql">
|
||
|
<v-list-item v-ge="['columns', 'save-and-scaffold']" @click="saveAndScaffoldGql()">
|
||
|
<v-list-item-title v-ge="['columns', 'json-to-columns']" class="font-weight-bold pa-1">
|
||
|
<v-icon color="primary" small> mdi-code-json </v-icon>
|
||
4 years ago
|
Save & Scaffold Module
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
3 years ago
|
<v-list-item v-ge="['columns', 'save-and-scaffold']" @click="saveAndScaffoldGqlModel()">
|
||
|
<v-list-item-title v-ge="['columns', 'json-to-columns']" class="font-weight-bold pa-1">
|
||
|
<v-icon color="primary" small> mdi-code-json </v-icon>
|
||
4 years ago
|
Save & Scaffold GQL Model
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
|
||
3 years ago
|
<v-list-item v-ge="['columns', 'scaffold']" @click="scaffoldGql({ model: true })">
|
||
|
<v-list-item-title v-ge="['columns', 'json-to-columns']" class="font-weight-bold pa-1">
|
||
|
<v-icon color="primary" small> mdi-code-json </v-icon>
|
||
4 years ago
|
Scaffold GQL Model
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
3 years ago
|
<v-list-item v-ge="['columns', 'scaffold']" @click="scaffoldGql({ resolver: true })">
|
||
|
<v-list-item-title v-ge="['columns', 'json-to-columns']" class="font-weight-bold pa-1">
|
||
|
<v-icon color="primary" small> mdi-code-json </v-icon>
|
||
4 years ago
|
Scaffold GQL Resolver
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
3 years ago
|
<v-list-item v-ge="['columns', 'scaffold']" @click="scaffoldGql({ service: true })">
|
||
|
<v-list-item-title v-ge="['columns', 'json-to-columns']" class="font-weight-bold pa-1">
|
||
|
<v-icon color="primary" small> mdi-code-json </v-icon>
|
||
4 years ago
|
Scaffold GQL Service
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
3 years ago
|
<v-list-item v-ge="['columns', 'scaffold']" @click="scaffoldGql({ relations: true })">
|
||
|
<v-list-item-title v-ge="['columns', 'json-to-columns']" class="font-weight-bold pa-1">
|
||
|
<v-icon color="primary" small> mdi-code-json </v-icon>
|
||
4 years ago
|
Scaffold GQL Relations
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
|
||
|
<!-- graphql : end-->
|
||
|
</template>
|
||
|
<template v-else>
|
||
3 years ago
|
<v-list-item v-ge="['columns', 'save-and-scaffold']" @click="saveAndScaffold()">
|
||
|
<v-list-item-title v-ge="['columns', 'json-to-columns']" class="font-weight-bold pa-1">
|
||
|
<v-icon color="primary" small> mdi-code-json </v-icon>
|
||
4 years ago
|
Save & Scaffold Module
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
|
||
3 years ago
|
<v-list-item v-ge="['columns', 'save-and-scaffold']" @click="saveAndScaffoldModel()">
|
||
|
<v-list-item-title v-ge="['columns', 'json-to-columns']" class="font-weight-bold pa-1">
|
||
|
<v-icon color="primary" small> mdi-code-json </v-icon>
|
||
4 years ago
|
Save & Scaffold Model
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
|
||
3 years ago
|
<v-list-item v-ge="['columns', 'json-to-column']" @click="scaffold({ model: true })">
|
||
|
<v-list-item-title v-ge="['columns', 'json-to-columns']" class="font-weight-bold pa-1">
|
||
|
<v-icon color="primary" small> mdi-code-json </v-icon>
|
||
4 years ago
|
Scaffold Model
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
3 years ago
|
<v-list-item v-ge="['columns', 'scaffold']" @click="scaffold({ router: true })">
|
||
|
<v-list-item-title v-ge="['columns', 'json-to-columns']" class="font-weight-bold pa-1">
|
||
|
<v-icon color="primary" small> mdi-code-json </v-icon>
|
||
4 years ago
|
Scaffold Router
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
3 years ago
|
<v-list-item v-ge="['columns', 'scaffold']" @click="scaffold({ service: true })">
|
||
|
<v-list-item-title v-ge="['columns', 'json-to-columns']" class="font-weight-bold pa-1">
|
||
|
<v-icon color="primary" small> mdi-code-json </v-icon>
|
||
4 years ago
|
Scaffold Service
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
3 years ago
|
<v-list-item v-ge="['columns', 'scaffold']" @click="scaffold({ relations: true })">
|
||
|
<v-list-item-title v-ge="['columns', 'json-to-columns']" class="font-weight-bold pa-1">
|
||
|
<v-icon color="primary" small> mdi-code-json </v-icon>
|
||
4 years ago
|
Scaffold Relations
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
</template>
|
||
|
</template>
|
||
3 years ago
|
<v-list-item @click="showJsonToColumDlg = true">
|
||
|
<v-list-item-title v-ge="['columns', 'json-to-columns']" class="font-weight-bold pa-1">
|
||
|
<v-icon color="primary" small> mdi-code-json </v-icon>
|
||
|
JSON To Columns
|
||
4 years ago
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
</v-list>
|
||
|
</v-menu>
|
||
|
</v-toolbar>
|
||
|
|
||
3 years ago
|
<v-skeleton-loader v-if="loading" type="table" />
|
||
4 years ago
|
<v-data-table
|
||
|
v-else
|
||
|
dense
|
||
|
:headers="headers"
|
||
|
:items="columns"
|
||
|
hide-default-header
|
||
3 years ago
|
:footer-props="{ 'items-per-page-options': paginationLength }"
|
||
|
class="column-table"
|
||
4 years ago
|
>
|
||
3 years ago
|
<template #header="{ props: { headers } }">
|
||
4 years ago
|
<tr>
|
||
3 years ago
|
<th
|
||
|
v-for="header in headers"
|
||
|
:key="header.title"
|
||
3 years ago
|
class="pt-2 pb-0 grey--text caption text-center"
|
||
|
style="white-space: nowrap"
|
||
|
:style="{ minWidth: header.width, width: header.width }"
|
||
4 years ago
|
>
|
||
|
<v-tooltip bottom>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
4 years ago
|
<span v-on="on">{{ header.text }}</span>
|
||
|
</template>
|
||
|
<span>{{ header.title }}</span>
|
||
|
</v-tooltip>
|
||
|
</th>
|
||
|
</tr>
|
||
|
</template>
|
||
|
|
||
3 years ago
|
<template #item="props">
|
||
3 years ago
|
<tr :disabled="nodes.table_name === '_evolutions' || nodes.table_name === 'nc_evolutions'">
|
||
|
<td ref="column" :title="props.item.column_name" style="width: 200px">
|
||
4 years ago
|
<div class="d-flex">
|
||
|
|
||
3 years ago
|
<v-icon
|
||
|
small
|
||
|
:class="{
|
||
3 years ago
|
'green--text': props.item.pk,
|
||
|
'orange--text text--darken-2': props.item.rcn,
|
||
|
'lime--text text--lighten-4': !props.item.pk && !props.item.rcn,
|
||
3 years ago
|
}"
|
||
|
>
|
||
3 years ago
|
{{ getColumnIcon(props.item) }} </v-icon
|
||
|
>
|
||
4 years ago
|
|
||
|
<v-edit-dialog
|
||
|
v-if="!props.item.rcn"
|
||
3 years ago
|
v-ge="['columns', 'cn']"
|
||
3 years ago
|
class="flex-shrink-1"
|
||
4 years ago
|
@save.native="saveColumnName(props.item)"
|
||
|
@cancel="saveColumnName(props.item)"
|
||
|
@close="saveColumnName(props.item)"
|
||
|
>
|
||
|
<div
|
||
3 years ago
|
:title="props.item.column_name"
|
||
3 years ago
|
style="width: 180px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
|
||
3 years ago
|
>
|
||
3 years ago
|
{{ props.item.column_name }}
|
||
4 years ago
|
</div>
|
||
3 years ago
|
<template #input>
|
||
4 years ago
|
<v-text-field
|
||
3 years ago
|
v-model="props.item.column_name"
|
||
3 years ago
|
:disabled="props.item.rcn || !sqlUi.columnEditable(props.item)"
|
||
4 years ago
|
:rules="form.validation.required"
|
||
3 years ago
|
:label="$t('general.edit')"
|
||
4 years ago
|
single-line
|
||
3 years ago
|
/>
|
||
4 years ago
|
</template>
|
||
|
</v-edit-dialog>
|
||
3 years ago
|
<span v-else @click="onFKShowWarning">{{ props.item.column_name }}</span>
|
||
4 years ago
|
</div>
|
||
|
</td>
|
||
|
<td class="pa-0">
|
||
|
<v-autocomplete
|
||
|
v-if="!props.item.rcn"
|
||
3 years ago
|
v-model="props.item.dt"
|
||
3 years ago
|
v-ge="['columns', 'dt']"
|
||
3 years ago
|
:disabled="!sqlUi.columnEditable(props.item)"
|
||
4 years ago
|
class="body-2 mt-n1"
|
||
|
:full-width="false"
|
||
|
:items="dataTypes"
|
||
|
dense
|
||
|
hide-details
|
||
3 years ago
|
@change="onDataTypeChange(props.item, props.index)"
|
||
3 years ago
|
/>
|
||
4 years ago
|
|
||
|
<span v-else @click="onFKShowWarning">{{ props.item.dt }}</span>
|
||
|
</td>
|
||
|
<td class="pa-0">
|
||
|
<v-autocomplete
|
||
3 years ago
|
v-model="props.item.uidt"
|
||
3 years ago
|
v-ge="['columns', 'dt']"
|
||
4 years ago
|
:disabled="!sqlUi.columnEditable(props.item)"
|
||
|
class="body-2 mt-n1"
|
||
|
:full-width="false"
|
||
|
:items="uiDataTypes"
|
||
|
dense
|
||
|
hide-details
|
||
3 years ago
|
@change="onUiDataTypeChange(props.item)"
|
||
|
/>
|
||
4 years ago
|
</td>
|
||
|
<td>
|
||
|
<v-edit-dialog
|
||
|
v-if="!props.item.rcn"
|
||
|
lazy
|
||
|
@cancel="savePrecision(props.item)"
|
||
3 years ago
|
@close="savePrecision(props.item)"
|
||
|
>
|
||
4 years ago
|
{{ props.item.dtxp }}
|
||
3 years ago
|
<template #input>
|
||
4 years ago
|
<v-text-field
|
||
|
v-model="props.item.dtxp"
|
||
3 years ago
|
v-ge="['columns', 'precision']"
|
||
3 years ago
|
:disabled="sqlUi.getDefaultLengthIsDisabled(props.item.dt) || !sqlUi.columnEditable(props.item)"
|
||
4 years ago
|
:rules="[max25chars]"
|
||
3 years ago
|
:label="$t('general.edit')"
|
||
4 years ago
|
single-line
|
||
3 years ago
|
/>
|
||
4 years ago
|
</template>
|
||
|
</v-edit-dialog>
|
||
|
<span v-else @click="onFKShowWarning">{{ props.item.dtxp }}</span>
|
||
|
</td>
|
||
3 years ago
|
<td :style="props.item.rcn ? 'padding:0' : ''">
|
||
4 years ago
|
<template v-if="!props.item.rcn">
|
||
|
<v-edit-dialog
|
||
|
v-if="showScale(props.item)"
|
||
|
lazy
|
||
|
@cancel="saveScale(props.item)"
|
||
|
@close="saveScale(props.item)"
|
||
|
>
|
||
|
{{ props.item.dtxs }}
|
||
3 years ago
|
<template #input>
|
||
4 years ago
|
<v-text-field
|
||
|
v-model="props.item.dtxs"
|
||
3 years ago
|
v-ge="['columns', 'scale']"
|
||
3 years ago
|
:disabled="!sqlUi.columnEditable(props.item)"
|
||
4 years ago
|
:rules="[max25chars]"
|
||
3 years ago
|
:label="$t('general.edit')"
|
||
4 years ago
|
single-line
|
||
3 years ago
|
/>
|
||
4 years ago
|
</template>
|
||
|
</v-edit-dialog>
|
||
|
</template>
|
||
3 years ago
|
<div v-else style="width: 100%; height: 100%" @click="onFKShowWarning">
|
||
|
{{ props.item.dtxs || '' }}
|
||
4 years ago
|
</div>
|
||
|
</td>
|
||
|
<td>
|
||
|
<v-checkbox
|
||
3 years ago
|
v-if="!props.item.rcn"
|
||
|
v-model="props.item.pk"
|
||
3 years ago
|
v-ge="['columns', 'pk']"
|
||
4 years ago
|
hide-details
|
||
|
:disabled="!sqlUi.columnEditable(props.item)"
|
||
|
solo
|
||
|
dense
|
||
|
height="44"
|
||
|
color="primary lighten-1"
|
||
3 years ago
|
@change="onCheckboxChangePk(props.item)"
|
||
|
/>
|
||
|
<v-checkbox
|
||
|
v-else
|
||
4 years ago
|
v-model="props.item.pk"
|
||
3 years ago
|
v-ge="['columns', 'pk']"
|
||
4 years ago
|
hide-details
|
||
|
:disabled="!sqlUi.columnEditable(props.item)"
|
||
|
solo
|
||
|
dense
|
||
|
height="44"
|
||
|
color="primary lighten-1"
|
||
3 years ago
|
@click.stop="onFKShowWarning"
|
||
|
/>
|
||
4 years ago
|
</td>
|
||
|
<td>
|
||
|
<v-checkbox
|
||
|
v-if="!props.item.rcn"
|
||
3 years ago
|
v-model="props.item.rqd"
|
||
3 years ago
|
v-ge="['columns', 'nn']"
|
||
3 years ago
|
hide-details
|
||
4 years ago
|
solo
|
||
|
dense
|
||
|
color="primary lighten-1"
|
||
|
:disabled="props.item.pk || !sqlUi.columnEditable(props.item)"
|
||
3 years ago
|
@change="onCheckboxChangeNN(props.item)"
|
||
|
/>
|
||
4 years ago
|
|
||
|
<v-checkbox
|
||
3 years ago
|
v-else
|
||
|
v-model="props.item.rqd"
|
||
3 years ago
|
v-ge="['columns', 'nn']"
|
||
4 years ago
|
hide-details
|
||
|
:disabled="!sqlUi.columnEditable(props.item)"
|
||
|
solo
|
||
|
dense
|
||
|
color="primary lighten-1"
|
||
3 years ago
|
@click.stop="onFKShowWarning"
|
||
|
/>
|
||
4 years ago
|
</td>
|
||
|
<td>
|
||
|
<v-checkbox
|
||
|
v-if="!props.item.rcn"
|
||
3 years ago
|
v-model="props.item.un"
|
||
3 years ago
|
v-ge="['columns', 'un']"
|
||
3 years ago
|
hide-details
|
||
4 years ago
|
:disabled="colPropUNDisabled(props.item) || !sqlUi.columnEditable(props.item)"
|
||
|
solo
|
||
|
dense
|
||
|
color="primary lighten-1"
|
||
3 years ago
|
@change="onCheckboxChangeUN(props.item)"
|
||
|
/>
|
||
|
<v-checkbox
|
||
|
v-else
|
||
4 years ago
|
v-model="props.item.un"
|
||
3 years ago
|
v-ge="['columns', 'un']"
|
||
4 years ago
|
hide-details
|
||
|
:disabled="colPropUNDisabled(props.item) || !sqlUi.columnEditable(props.item)"
|
||
|
solo
|
||
|
dense
|
||
|
color="primary lighten-1"
|
||
3 years ago
|
@click.stop="onFKShowWarning"
|
||
|
/>
|
||
4 years ago
|
</td>
|
||
|
<td>
|
||
|
<v-checkbox
|
||
|
v-if="!props.item.rcn"
|
||
3 years ago
|
v-model="props.item.ai"
|
||
3 years ago
|
v-ge="['columns', 'ai']"
|
||
3 years ago
|
hide-details
|
||
4 years ago
|
:disabled="colPropAIDisabled(props.item) || !sqlUi.columnEditable(props.item)"
|
||
|
solo
|
||
|
dense
|
||
|
color="primary lighten-1"
|
||
3 years ago
|
@change="onCheckboxChangeAI(props.item)"
|
||
|
/>
|
||
4 years ago
|
<v-checkbox
|
||
|
v-else
|
||
3 years ago
|
v-model="props.item.ai"
|
||
3 years ago
|
v-ge="['columns', 'ai']"
|
||
4 years ago
|
:disabled="colPropAIDisabled(props.item) || !sqlUi.columnEditable(props.item)"
|
||
|
solo
|
||
|
dense
|
||
|
color="primary lighten-1"
|
||
3 years ago
|
@click.stop="onFKShowWarning"
|
||
|
/>
|
||
4 years ago
|
</td>
|
||
|
<td>
|
||
|
<v-checkbox
|
||
3 years ago
|
v-model="props.item.au"
|
||
3 years ago
|
v-ge="['columns', 'au']"
|
||
4 years ago
|
hide-details
|
||
3 years ago
|
:disabled="sqlUi.colPropAuDisabled(props.item) || !sqlUi.columnEditable(props.item)"
|
||
4 years ago
|
solo
|
||
|
dense
|
||
|
color="primary lighten-1"
|
||
3 years ago
|
@change="onCheckboxChangeAU(props.item)"
|
||
|
/>
|
||
4 years ago
|
</td>
|
||
|
|
||
|
<td>
|
||
|
<p v-if="props.item.rtn" row wrap class="mb-0">
|
||
|
{{ props.item.rtn }}
|
||
3 years ago
|
<x-icon
|
||
3 years ago
|
v-ge="['columns', 'fk-edit']"
|
||
3 years ago
|
small
|
||
|
color="primary"
|
||
|
:disabled="!sqlUi.columnEditable(props.item)"
|
||
|
@click="createNewOrEditRelation(props.item)"
|
||
4 years ago
|
>
|
||
3 years ago
|
mdi-table-edit
|
||
|
</x-icon>
|
||
|
<x-icon
|
||
3 years ago
|
v-ge="['columns', 'fk-delete']"
|
||
3 years ago
|
small
|
||
|
:disabled="!sqlUi.columnEditable(props.item)"
|
||
|
color="error"
|
||
|
@click="deleteRelation('showDialog', props.item)"
|
||
4 years ago
|
>
|
||
3 years ago
|
mdi-delete-forever
|
||
|
</x-icon>
|
||
3 years ago
|
<span v-if="props.item.type === 'virtual'" class="caption">(v)</span>
|
||
4 years ago
|
</p>
|
||
|
|
||
|
<x-icon
|
||
3 years ago
|
v-else-if="!props.item.pk && props.item.altered !== 1"
|
||
|
v-ge="['columns', 'fk-add']"
|
||
4 years ago
|
color="primary grey"
|
||
|
small
|
||
|
:disabled="!sqlUi.columnEditable(props.item)"
|
||
|
@click="createNewOrEditRelation(props.item)"
|
||
3 years ago
|
>
|
||
|
add
|
||
4 years ago
|
</x-icon>
|
||
|
|
||
3 years ago
|
<v-icon v-else v-ge="['columns', 'fk-add']" disabled small color="grey"> add </v-icon>
|
||
4 years ago
|
</td>
|
||
3 years ago
|
<td :style="props.item.rcn ? 'padding:0' : ''">
|
||
4 years ago
|
<v-edit-dialog
|
||
|
v-if="!props.item.rcn"
|
||
|
:return-value.sync="props.item.cdf"
|
||
|
large
|
||
|
lazy
|
||
|
persistent
|
||
|
:value="true"
|
||
3 years ago
|
class="caption"
|
||
4 years ago
|
@save="saveDefaultValue(props.item)"
|
||
|
@cancel="cancel"
|
||
|
@open="open"
|
||
|
@close="close"
|
||
|
>
|
||
|
<!-- <div v-if="props.item.rqd">{{ props.item.cdf }}</div>-->
|
||
3 years ago
|
<div v-if="props.item.pk" />
|
||
3 years ago
|
<div v-else-if="!props.item.cdf && !props.item.rqd" class="caption">NULL</div>
|
||
3 years ago
|
<div v-else class="caption">
|
||
|
{{ props.item.cdf }}
|
||
|
</div>
|
||
|
<!-- <template #input>-->
|
||
|
<!-- <div class="mt-3 title">-->
|
||
|
<!-- Update Column Default-->
|
||
|
<!-- </div>-->
|
||
|
<!-- </template>-->
|
||
|
<template #input>
|
||
4 years ago
|
<v-textarea
|
||
|
v-model="props.item.cdf"
|
||
3 years ago
|
v-ge="['columns', 'default']"
|
||
3 years ago
|
:disabled="!sqlUi.columnEditable(props.item)"
|
||
3 years ago
|
:label="$t('general.edit')"
|
||
4 years ago
|
counter
|
||
|
class="caption"
|
||
|
:placeholder="`${sqlUi.getDefaultValueForDatatype(props.item.dt)}`"
|
||
|
autofocus
|
||
3 years ago
|
/>
|
||
4 years ago
|
</template>
|
||
|
</v-edit-dialog>
|
||
3 years ago
|
<div v-else style="width: 100%; height: 100%" @click="onFKShowWarning">
|
||
3 years ago
|
{{ props.item.cdf }}
|
||
|
</div>
|
||
4 years ago
|
</td>
|
||
|
<td>
|
||
3 years ago
|
<v-hover v-if="!props.item.rcn" v-slot="{ hover }">
|
||
4 years ago
|
<v-icon
|
||
3 years ago
|
v-ge="['columns', 'delete']"
|
||
4 years ago
|
:color="hover ? 'error' : 'grey'"
|
||
|
small
|
||
|
:disabled="!sqlUi.columnEditable(props.item)"
|
||
|
@click="deleteColumn('showDialog', props.index, props.item)"
|
||
|
>
|
||
3 years ago
|
mdi-delete-forever
|
||
|
</v-icon>
|
||
4 years ago
|
</v-hover>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</template>
|
||
|
</v-data-table>
|
||
|
</v-card>
|
||
|
|
||
|
<addRelationDlg
|
||
|
v-if="dialogShow"
|
||
|
:nodes="nodes"
|
||
|
:column="selectedColForNewRelation"
|
||
|
heading="Relation Column "
|
||
3 years ago
|
:dialog-show="dialogShow"
|
||
|
:mtd-dialog-submit="mtdNewRelationDlgSubmit"
|
||
|
:mtd-dialog-cancel="mtdNewRelationDlgCancel"
|
||
4 years ago
|
/>
|
||
|
|
||
3 years ago
|
<span v-else />
|
||
4 years ago
|
<dlgLabelSubmitCancel
|
||
|
v-if="columnDeleteDlg"
|
||
3 years ago
|
type="primary"
|
||
|
:dialog-show="columnDeleteDlg"
|
||
|
:actions-mtd="deleteColumn"
|
||
4 years ago
|
heading="Click Submit to Delete the Column"
|
||
|
/>
|
||
|
<dlgLabelSubmitCancel
|
||
|
v-if="relationDeleteDlg"
|
||
3 years ago
|
type="primary"
|
||
|
:dialog-show="relationDeleteDlg"
|
||
|
:actions-mtd="deleteRelation"
|
||
4 years ago
|
heading="Click Submit to Delete the Relation"
|
||
|
/>
|
||
3 years ago
|
<jsonToColumn :show.sync="showJsonToColumDlg" @load="loadJsonColumn" />
|
||
4 years ago
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
import { mapGetters, mapActions } from 'vuex';
|
||
|
import JSON5 from 'json5';
|
||
|
import { SqlUiFactory } from 'nocodb-sdk';
|
||
|
import addRelationDlg from '../dlgs/DlgAddRelation.vue';
|
||
|
import dlgLabelSubmitCancel from '../../utils/DlgLabelSubmitCancel.vue';
|
||
4 years ago
|
|
||
3 years ago
|
import jsonToColumn from './columnActions/JsonToColumn';
|
||
|
import uiTypes from '@/components/project/spreadsheet/helpers/uiTypes';
|
||
4 years ago
|
|
||
|
// const {path} = require("electron").remote.require(
|
||
|
// "./libs"
|
||
|
// );
|
||
|
|
||
|
export default {
|
||
3 years ago
|
components: { addRelationDlg, dlgLabelSubmitCancel, jsonToColumn },
|
||
3 years ago
|
data() {
|
||
4 years ago
|
return {
|
||
|
showJsonToColumDlg: false,
|
||
|
paginationLength: [20, 50, -1],
|
||
|
form: {
|
||
|
validation: {
|
||
3 years ago
|
required: [v => !!v || 'Required'],
|
||
|
},
|
||
4 years ago
|
},
|
||
|
progress: {
|
||
|
save: false,
|
||
|
deleteTable: false,
|
||
3 years ago
|
refresh: false,
|
||
4 years ago
|
},
|
||
|
edited: false,
|
||
|
columnDeleteDlg: false,
|
||
|
selectedColForDelete: null,
|
||
|
relationDeleteDlg: false,
|
||
|
selectedColForRelationDelete: null,
|
||
|
columns: [],
|
||
|
dataTypes: [],
|
||
|
uiDataTypes: [],
|
||
|
headers: [
|
||
|
{
|
||
3 years ago
|
text: 'Column',
|
||
|
title: 'Column name',
|
||
|
value: 'cn',
|
||
4 years ago
|
sortable: false,
|
||
3 years ago
|
width: '1%',
|
||
4 years ago
|
},
|
||
3 years ago
|
{ text: 'Data Type', title: 'Data Type', value: 'dt', sortable: false, width: '10%' },
|
||
|
{ text: 'UI Type', title: 'UI Type', value: 'uidt', sortable: false, width: '10%' },
|
||
4 years ago
|
// {text: "Type",title:', value: "dt", sortable: false, width: "10%"},
|
||
3 years ago
|
{ text: 'Length/Values', title: 'Length/Values', value: 'dt', sortable: false, width: '5%' },
|
||
|
{ text: 'Scale', title: 'Scale', value: 'dt', sortable: false, width: '5%' },
|
||
|
{ text: 'PK', title: 'Primary Key', value: 'pk', sortable: false, width: '1%' },
|
||
|
{ text: 'NN', title: 'Not NULL', value: 'rqd', sortable: false, width: '1%' },
|
||
|
{ text: 'UN', title: 'Unsigned', value: 'unsigned', sortable: false, width: '1%' },
|
||
|
{ text: 'AI', title: 'Auto Increment', value: 'ai', sortable: false, width: '1%' },
|
||
|
{ text: 'AU', title: 'Auto Update Timestamp', value: '', sortable: false, width: '1%' },
|
||
|
{ text: 'FK', title: 'Foreign Key', value: '', sortable: false, width: '20%' },
|
||
4 years ago
|
{
|
||
3 years ago
|
text: 'Default',
|
||
|
title: 'Default Value',
|
||
|
value: 'cdf',
|
||
4 years ago
|
sortable: false,
|
||
3 years ago
|
width: '10%',
|
||
4 years ago
|
},
|
||
3 years ago
|
{ text: '', title: 'Action', value: '', sortable: false, width: '1%' },
|
||
4 years ago
|
],
|
||
3 years ago
|
max25chars: v => (v + '').length <= 150 || 'Input too long!',
|
||
4 years ago
|
dialogShow: false,
|
||
|
selectedColForNewRelation: null,
|
||
3 years ago
|
loading: true,
|
||
|
};
|
||
4 years ago
|
},
|
||
|
methods: {
|
||
3 years ago
|
async saveAndScaffold() {
|
||
3 years ago
|
await this.applyChanges();
|
||
|
await this.scaffold();
|
||
4 years ago
|
},
|
||
3 years ago
|
async saveAndScaffoldModel() {
|
||
3 years ago
|
await this.applyChanges();
|
||
|
await this.scaffold({ model: true });
|
||
4 years ago
|
},
|
||
3 years ago
|
async scaffold(scaffold = null) {
|
||
4 years ago
|
try {
|
||
|
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
|
null,
|
||
3 years ago
|
'projectGenerateBackend',
|
||
4 years ago
|
{
|
||
3 years ago
|
env: '_noco',
|
||
3 years ago
|
table_name: this.nodes.table_name,
|
||
3 years ago
|
scaffold,
|
||
|
},
|
||
|
]);
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
console.log(e);
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async saveAndScaffoldGql() {
|
||
3 years ago
|
await this.applyChanges();
|
||
|
await this.scaffoldGql();
|
||
4 years ago
|
},
|
||
3 years ago
|
async saveAndScaffoldModelGql() {
|
||
3 years ago
|
await this.applyChanges();
|
||
|
await this.scaffoldGql({ model: true });
|
||
4 years ago
|
},
|
||
3 years ago
|
async scaffoldGql(scaffold = null) {
|
||
4 years ago
|
try {
|
||
|
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
|
null,
|
||
3 years ago
|
'projectGenerateBackendGql',
|
||
4 years ago
|
{
|
||
3 years ago
|
env: '_noco',
|
||
3 years ago
|
tn: this.nodes.table_name,
|
||
3 years ago
|
scaffold,
|
||
|
},
|
||
|
]);
|
||
|
} catch (e) {}
|
||
4 years ago
|
},
|
||
3 years ago
|
async handleKeyDown({ metaKey, key, altKey, shiftKey, ctrlKey }) {
|
||
4 years ago
|
// cmd + s -> save
|
||
|
// cmd + l -> reload
|
||
|
// cmd + n -> new
|
||
|
// cmd + d -> delete
|
||
|
// cmd + enter -> send api
|
||
|
|
||
|
switch ([this._isMac ? metaKey : ctrlKey, key].join('_')) {
|
||
3 years ago
|
case 'true_s':
|
||
|
await this.applyChanges();
|
||
|
break;
|
||
|
case 'true_l':
|
||
|
await this.loadColumnList();
|
||
|
break;
|
||
|
case 'true_n':
|
||
|
this.addColumn();
|
||
|
break;
|
||
|
case 'true_d':
|
||
|
await this.deleteTable('showDialog');
|
||
|
break;
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
loadJsonColumn(jsonString) {
|
||
4 years ago
|
try {
|
||
3 years ago
|
const columns = this.sqlUi.getColumnsFromJson(JSON5.parse(jsonString), this.nodes.table_name);
|
||
|
const dup = Columns.find(col => this.columns.some(exCol => exCol.column_name === col.column_name));
|
||
4 years ago
|
if (!dup) {
|
||
3 years ago
|
this.columns = [...this.columns, ...Columns];
|
||
|
this.showJsonToColumDlg = false;
|
||
|
this.edited = true;
|
||
|
this.$toast.info(`${Columns.length} column${Columns.length > 1 ? 's' : ''} added`).goAway(3000);
|
||
4 years ago
|
} else {
|
||
3 years ago
|
this.$toast.error(`Duplicate column found : ${dup.column_name}`).goAway(3000);
|
||
4 years ago
|
}
|
||
|
} catch (e) {
|
||
3 years ago
|
console.log(e);
|
||
|
this.$toast.error('Invalid JSON string').goAway(3000);
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
getColumnIcon(column) {
|
||
4 years ago
|
if (column.pk) {
|
||
3 years ago
|
return 'mdi-key';
|
||
4 years ago
|
} else if (column.rcn) {
|
||
3 years ago
|
return 'mdi-link-variant';
|
||
4 years ago
|
} else {
|
||
3 years ago
|
return 'mdi-gate-or';
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
onFKShowWarning() {
|
||
3 years ago
|
this.$toast
|
||
|
.error("COLUMN property with foreign key mapped can't be edited. Remove foreign key to edit.")
|
||
|
.goAway(3000);
|
||
4 years ago
|
},
|
||
|
|
||
|
...mapActions({
|
||
3 years ago
|
loadTablesFromChildTreeNode: 'project/loadTablesFromChildTreeNode',
|
||
4 years ago
|
}),
|
||
3 years ago
|
onCheckboxChange() {
|
||
3 years ago
|
this.edited = true;
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
onCheckboxChangePk(col) {
|
||
3 years ago
|
this.edited = true;
|
||
|
col.altered = col.altered || 2;
|
||
4 years ago
|
|
||
|
if (!col.pk && col.ai) {
|
||
3 years ago
|
col.ai = false;
|
||
4 years ago
|
} else if (col.pk) {
|
||
3 years ago
|
col.rqd = true;
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
col.cdf = null;
|
||
|
col.rqd = true;
|
||
4 years ago
|
},
|
||
3 years ago
|
colPropAIDisabled(col) {
|
||
3 years ago
|
return this.sqlUi.colPropAIDisabled(col, this.columns);
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
colPropUNDisabled(col) {
|
||
3 years ago
|
return this.sqlUi.colPropUNDisabled(col);
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
onCheckboxChangeAI(col) {
|
||
3 years ago
|
this.sqlUi.onCheckboxChangeAI(col);
|
||
4 years ago
|
|
||
3 years ago
|
this.edited = true;
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
onCheckboxChangeAU(col) {
|
||
3 years ago
|
this.sqlUi.onCheckboxChangeAU(col);
|
||
|
this.edited = true;
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
onCheckboxChangeNN(col) {
|
||
3 years ago
|
col.altered = col.altered || 2;
|
||
|
this.edited = true;
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
onCheckboxChangeUN(col) {
|
||
3 years ago
|
col.altered = col.altered || 2;
|
||
|
this.edited = true;
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
onUiDataTypeChange(column) {
|
||
3 years ago
|
this.edited = true;
|
||
|
column.altered = column.altered || 2;
|
||
4 years ago
|
},
|
||
3 years ago
|
onDataTypeChange(column, index) {
|
||
3 years ago
|
this.edited = true;
|
||
|
column.altered = column.altered || 2;
|
||
|
column.rqd = false;
|
||
|
column.pk = false;
|
||
|
column.ai = false;
|
||
|
column.cdf = null;
|
||
|
column.dtxp = this.sqlUi.getDefaultLengthForDatatype(column.dt);
|
||
|
column.dtxs = this.sqlUi.getDefaultScaleForDatatype(column.dt);
|
||
4 years ago
|
|
||
3 years ago
|
column.dtx = 'specificType';
|
||
4 years ago
|
|
||
3 years ago
|
this.$set(column, 'uidt', this.sqlUi.getUIType(column));
|
||
4 years ago
|
},
|
||
3 years ago
|
async loadColumnList() {
|
||
3 years ago
|
this.loading = true;
|
||
|
this.$store.commit('notification/MutToggleProgressBar', true);
|
||
4 years ago
|
try {
|
||
3 years ago
|
this.edited = false;
|
||
4 years ago
|
if (this.newTable) {
|
||
3 years ago
|
this.columns = this.sqlUi.getNewTableColumns();
|
||
|
return;
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
|
},
|
||
|
'columnList',
|
||
|
{
|
||
|
tn: this.nodes.table_name,
|
||
|
},
|
||
|
]);
|
||
|
const columns = result.data.list;
|
||
4 years ago
|
|
||
3 years ago
|
const relations = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
|
},
|
||
|
'xcRelationList',
|
||
|
{
|
||
|
tn: this.nodes.table_name,
|
||
|
},
|
||
|
]);
|
||
4 years ago
|
|
||
|
for (let i = 0; i < relations.length; i++) {
|
||
3 years ago
|
const relation = relations[i];
|
||
3 years ago
|
for (let i = 0; i < Columns.length; i++) {
|
||
3 years ago
|
const column = Columns[i];
|
||
4 years ago
|
|
||
3 years ago
|
if (column.column_name === relation.column_name) {
|
||
3 years ago
|
Columns[i] = { ...column, ...relation };
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
this.columns = JSON.parse(JSON.stringify(Columns));
|
||
|
this.originalColumns = [...Columns];
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
console.log(e);
|
||
|
this.$toast.error('Error loading columns :' + e).goAway(4000);
|
||
|
throw e;
|
||
4 years ago
|
} finally {
|
||
3 years ago
|
this.$store.commit('notification/MutToggleProgressBar', false);
|
||
|
this.loading = false;
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async loadUiDataTypes() {
|
||
3 years ago
|
this.uiDataTypes = uiTypes;
|
||
4 years ago
|
},
|
||
3 years ago
|
async loadDataTypes() {
|
||
4 years ago
|
try {
|
||
3 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
|
},
|
||
|
'getKnexDataTypes',
|
||
|
{},
|
||
|
]);
|
||
4 years ago
|
|
||
3 years ago
|
this.dataTypes = result.data.list;
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error('Error loading datatypes :' + e).goAway(4000);
|
||
|
throw e;
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
saveColumnName(col, v) {
|
||
3 years ago
|
this.edited = true;
|
||
|
col.altered = col.altered || 8;
|
||
|
this.snack = true;
|
||
4 years ago
|
},
|
||
3 years ago
|
save(col) {
|
||
3 years ago
|
this.edited = true;
|
||
|
col.altered = col.altered || 2;
|
||
|
this.snack = true;
|
||
4 years ago
|
},
|
||
3 years ago
|
cancel() {
|
||
3 years ago
|
this.snack = true;
|
||
4 years ago
|
},
|
||
3 years ago
|
open() {
|
||
3 years ago
|
this.snack = true;
|
||
4 years ago
|
},
|
||
3 years ago
|
close() {},
|
||
4 years ago
|
|
||
3 years ago
|
saveDefaultValue(col) {
|
||
3 years ago
|
this.edited = true;
|
||
|
col.altered = col.altered || 2;
|
||
|
this.snack = true;
|
||
4 years ago
|
},
|
||
3 years ago
|
savePrecision(col) {
|
||
3 years ago
|
console.log(col);
|
||
|
col.altered = col.altered || 2;
|
||
|
this.edited = true;
|
||
|
this.snack = true;
|
||
4 years ago
|
},
|
||
3 years ago
|
cancelPrecision() {
|
||
3 years ago
|
this.snack = true;
|
||
4 years ago
|
},
|
||
3 years ago
|
openPrecision() {
|
||
3 years ago
|
this.snack = true;
|
||
4 years ago
|
},
|
||
3 years ago
|
closePrecision() {},
|
||
3 years ago
|
showScale(columnObj) {
|
||
3 years ago
|
return this.sqlUi.showScale(columnObj);
|
||
4 years ago
|
},
|
||
3 years ago
|
saveScale(col) {
|
||
3 years ago
|
col.altered = col.altered || 2;
|
||
|
this.edited = true;
|
||
|
this.snack = true;
|
||
4 years ago
|
},
|
||
3 years ago
|
cancelScale() {
|
||
3 years ago
|
this.snack = true;
|
||
4 years ago
|
},
|
||
3 years ago
|
openScale() {
|
||
3 years ago
|
this.snack = true;
|
||
4 years ago
|
},
|
||
3 years ago
|
closeScale() {},
|
||
3 years ago
|
removeUnsigned(columns) {
|
||
3 years ago
|
this.sqlUi.removeUnsigned(Columns);
|
||
4 years ago
|
},
|
||
3 years ago
|
async reload() {
|
||
3 years ago
|
await this.loadColumnList();
|
||
4 years ago
|
},
|
||
3 years ago
|
addColumn() {
|
||
3 years ago
|
this.edited = true;
|
||
|
this.columns.push(this.sqlUi.getNewColumn(this.columns.length));
|
||
|
this.scrollAndFocusLastRow();
|
||
4 years ago
|
},
|
||
3 years ago
|
async deleteColumn(action = '', index, column) {
|
||
4 years ago
|
try {
|
||
3 years ago
|
if (action === 'showDialog') {
|
||
3 years ago
|
this.columnDeleteDlg = true;
|
||
|
this.selectedColForDelete = { index, column };
|
||
3 years ago
|
} else if (action === 'hideDialog') {
|
||
3 years ago
|
this.columnDeleteDlg = false;
|
||
4 years ago
|
} else {
|
||
|
if (this.columns[this.selectedColForDelete.index].altered === 1) {
|
||
3 years ago
|
// newly added column no need to remove from db
|
||
3 years ago
|
this.columns.splice(this.selectedColForDelete.index, 1);
|
||
4 years ago
|
} else {
|
||
3 years ago
|
const columns = JSON.parse(JSON.stringify(this.columns));
|
||
|
Columns[this.selectedColForDelete.index].altered = 4;
|
||
|
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
|
},
|
||
|
'tableUpdate',
|
||
|
{
|
||
|
tn: this.nodes.table_name,
|
||
|
originalColumns: this.originalColumns,
|
||
|
Columns,
|
||
|
},
|
||
|
]);
|
||
|
this.columns.splice(this.selectedColForDelete.index, 1);
|
||
|
this.$toast.success('Column deleted successfully').goAway(3000);
|
||
4 years ago
|
}
|
||
3 years ago
|
this.columnDeleteDlg = false;
|
||
|
this.selectedColForDelete = null;
|
||
4 years ago
|
}
|
||
|
} catch (e) {
|
||
3 years ago
|
console.log(e);
|
||
|
this.$toast.error('Error while deleting column : ' + e).goAway(3000);
|
||
|
throw e;
|
||
4 years ago
|
}
|
||
|
},
|
||
|
|
||
3 years ago
|
async applyChangesDirect() {
|
||
4 years ago
|
try {
|
||
|
if (this.newTable) {
|
||
3 years ago
|
await this.saveAndScaffold();
|
||
4 years ago
|
} else if (this.edited) {
|
||
3 years ago
|
await this.saveAndScaffoldModel();
|
||
4 years ago
|
}
|
||
|
} catch (e) {
|
||
3 years ago
|
console.log(e);
|
||
|
this.$toast.error('Error while saving table : ' + e).goAway(3000);
|
||
|
throw e;
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async applyChangesDirectGql() {
|
||
4 years ago
|
try {
|
||
|
if (this.newTable) {
|
||
3 years ago
|
await this.saveAndScaffoldGql();
|
||
4 years ago
|
} else if (this.edited) {
|
||
3 years ago
|
await this.saveAndScaffoldModelGql();
|
||
4 years ago
|
}
|
||
|
} catch (e) {
|
||
3 years ago
|
console.log(e);
|
||
|
this.$toast.error('Error while saving table : ' + e).goAway(3000);
|
||
|
throw e;
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async applyChanges() {
|
||
4 years ago
|
try {
|
||
3 years ago
|
this.progress.save = true;
|
||
4 years ago
|
if (this.newTable) {
|
||
3 years ago
|
this.removeUnsigned(this.columns);
|
||
3 years ago
|
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
4 years ago
|
{
|
||
|
env: this.nodes.env,
|
||
3 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
4 years ago
|
},
|
||
3 years ago
|
'tableCreate',
|
||
4 years ago
|
{
|
||
3 years ago
|
tn: this.nodes.table_name,
|
||
3 years ago
|
columns: this.columns,
|
||
|
},
|
||
|
]);
|
||
|
this.mtdNewTableUpdate(false);
|
||
4 years ago
|
await this.loadTablesFromChildTreeNode({
|
||
|
_nodes: {
|
||
3 years ago
|
...this.nodes,
|
||
|
},
|
||
|
});
|
||
4 years ago
|
} else if (this.edited) {
|
||
3 years ago
|
this.removeUnsigned(this.columns);
|
||
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
|
},
|
||
|
'tableUpdate',
|
||
|
{
|
||
|
tn: this.nodes.table_name,
|
||
|
originalColumns: this.originalColumns,
|
||
|
columns: this.columns,
|
||
|
},
|
||
|
]);
|
||
4 years ago
|
}
|
||
3 years ago
|
await this.loadColumnList();
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
console.log(e);
|
||
|
this.$toast.error('Error while saving table : ' + e).goAway(3000);
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
this.progress.save = false;
|
||
4 years ago
|
},
|
||
3 years ago
|
createNewOrEditRelation(column) {
|
||
3 years ago
|
console.log(column);
|
||
|
this.selectedColForNewRelation = { ...column };
|
||
|
this.dialogShow = true;
|
||
4 years ago
|
},
|
||
3 years ago
|
async mtdNewRelationDlgSubmit(relationObject) {
|
||
4 years ago
|
try {
|
||
|
if (relationObject.updateRelation) {
|
||
3 years ago
|
// update existing relation
|
||
3 years ago
|
alert('Not Implemented yet');
|
||
4 years ago
|
} else {
|
||
3 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
4 years ago
|
{
|
||
|
env: this.nodes.env,
|
||
3 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
4 years ago
|
},
|
||
3 years ago
|
relationObject.type === 'real' ? 'relationCreate' : 'xcVirtualRelationCreate',
|
||
3 years ago
|
relationObject,
|
||
|
]);
|
||
4 years ago
|
}
|
||
3 years ago
|
await this.loadColumnList();
|
||
|
this.selectedColForNewRelation = null;
|
||
|
this.dialogShow = false;
|
||
4 years ago
|
|
||
3 years ago
|
this.$toast.success('Foreign Key created successfully').goAway(3000);
|
||
4 years ago
|
} catch (error) {
|
||
3 years ago
|
console.log(error);
|
||
|
this.$toast.error('Foreign Key relation creation failed ' + error).goAway(4000);
|
||
|
console.error('relationCreate error: ', error);
|
||
|
throw error;
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
mtdNewRelationDlgCancel() {
|
||
3 years ago
|
this.dialogShow = false;
|
||
|
this.selectedColNameForNewRelation = '';
|
||
4 years ago
|
},
|
||
3 years ago
|
async deleteRelation(action = '', column) {
|
||
4 years ago
|
try {
|
||
3 years ago
|
if (action === 'showDialog') {
|
||
3 years ago
|
this.relationDeleteDlg = true;
|
||
|
this.selectedColForRelationDelete = column;
|
||
3 years ago
|
} else if (action === 'hideDialog') {
|
||
3 years ago
|
this.relationDeleteDlg = false;
|
||
|
this.selectedColForRelationDelete = null;
|
||
4 years ago
|
} else {
|
||
3 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
4 years ago
|
{
|
||
|
env: this.nodes.env,
|
||
3 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
4 years ago
|
},
|
||
3 years ago
|
this.selectedColForRelationDelete.type === 'virtual' ? 'xcVirtualRelationDelete' : 'relationDelete',
|
||
4 years ago
|
{
|
||
3 years ago
|
childColumn: this.selectedColForRelationDelete.column_name,
|
||
|
childTable: this.nodes.table_name,
|
||
3 years ago
|
parentTable: this.selectedColForRelationDelete.rtn,
|
||
|
parentColumn: this.selectedColForRelationDelete.rcn,
|
||
|
},
|
||
|
]);
|
||
|
await this.loadColumnList();
|
||
|
this.relationDeleteDlg = false;
|
||
|
this.selectedColForRelationDelete = null;
|
||
|
this.$toast.success('Foreign Key deleted successfully').goAway(3000);
|
||
4 years ago
|
}
|
||
|
} catch (e) {
|
||
3 years ago
|
console.log(e);
|
||
|
this.$toast.error('Foreign key relation delete failed' + e).goAway(3000);
|
||
|
throw e;
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
scrollAndFocusLastRow() {
|
||
4 years ago
|
this.$nextTick(() => {
|
||
3 years ago
|
document.querySelector('.project-container').scrollTop = 9999;
|
||
|
const menuActivator =
|
||
|
this.$refs.column && this.$refs.column.querySelector('.v-small-dialog__activator__content');
|
||
4 years ago
|
if (menuActivator) {
|
||
3 years ago
|
this.$refs.column.querySelector('.v-small-dialog__activator__content').click();
|
||
4 years ago
|
this.$nextTick(() => {
|
||
3 years ago
|
const inputField = document.querySelector('.menuable__content__active input');
|
||
|
inputField && inputField.select();
|
||
|
});
|
||
4 years ago
|
}
|
||
3 years ago
|
});
|
||
|
},
|
||
4 years ago
|
},
|
||
|
computed: {
|
||
|
...mapGetters({
|
||
3 years ago
|
sqlMgr: 'sqlMgr/sqlMgr',
|
||
|
currentProjectFolder: 'project/currentProjectFolder',
|
||
|
projectIsGraphql: 'project/GtrProjectIsGraphql',
|
||
|
isNoApis: 'project/GtrProjectIsNoApis',
|
||
3 years ago
|
isMvc: 'project/GtrIsMvc',
|
||
|
}),
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
beforeCreated() {},
|
||
3 years ago
|
watch: {},
|
||
3 years ago
|
async created() {
|
||
3 years ago
|
this.sqlUi = SqlUiFactory.create(this.nodes.dbConnection);
|
||
4 years ago
|
|
||
|
try {
|
||
3 years ago
|
this.loading = true;
|
||
|
this.loadDataTypes();
|
||
|
this.loadUiDataTypes();
|
||
|
await this.loadColumnList();
|
||
4 years ago
|
} finally {
|
||
3 years ago
|
this.loading = false;
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
mounted() {},
|
||
|
beforeDestroy() {},
|
||
|
destroy() {},
|
||
3 years ago
|
directives: {},
|
||
3 years ago
|
validate({ params }) {
|
||
3 years ago
|
return true;
|
||
4 years ago
|
},
|
||
3 years ago
|
head() {
|
||
3 years ago
|
return {};
|
||
4 years ago
|
},
|
||
3 years ago
|
props: ['nodes', 'newTable', 'mtdNewTableUpdate', 'deleteTable', 'isMetaTable'],
|
||
|
};
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
/* to apply 6-9 columns */
|
||
3 years ago
|
/deep/ .column-table td:nth-child(n + 5):not(:nth-child(n + 10)),
|
||
|
/deep/ .column-table th:nth-child(n + 5):not(:nth-child(n + 10)) {
|
||
4 years ago
|
width: 30px;
|
||
|
padding: 0;
|
||
|
}
|
||
|
</style>
|
||
|
<!--
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|