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.
1908 lines
56 KiB
1908 lines
56 KiB
4 years ago
|
<template>
|
||
3 years ago
|
<v-container class="h-100 j-excel-container backgroundColor pa-0 ma-0" fluid>
|
||
3 years ago
|
<v-toolbar
|
||
|
height="32"
|
||
|
dense
|
||
|
class="nc-table-toolbar elevation-0 xc-toolbar xc-border-bottom mx-1"
|
||
|
style="z-index: 7"
|
||
|
>
|
||
3 years ago
|
<div
|
||
|
v-if="!isForm"
|
||
|
class="d-flex xc-border align-center search-box"
|
||
|
style="min-width: 156px"
|
||
|
>
|
||
4 years ago
|
<v-menu bottom offset-y>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
3 years ago
|
<div style="min-width: 56px" v-on="on">
|
||
3 years ago
|
<v-icon class="ml-2" small color="grey">
|
||
|
mdi-magnify
|
||
|
</v-icon>
|
||
4 years ago
|
|
||
3 years ago
|
<v-icon color="grey" class="pl-0 pa-1" small>
|
||
3 years ago
|
mdi-menu-down
|
||
4 years ago
|
</v-icon>
|
||
|
</div>
|
||
|
</template>
|
||
|
<v-list dense>
|
||
3 years ago
|
<v-list-item
|
||
|
v-for="col in availableRealColumns"
|
||
3 years ago
|
:key="col.column_name"
|
||
|
@click="searchField = col.title"
|
||
3 years ago
|
>
|
||
3 years ago
|
<span class="caption">{{ col.title }}</span>
|
||
4 years ago
|
</v-list-item>
|
||
|
</v-list>
|
||
|
</v-menu>
|
||
|
|
||
3 years ago
|
<v-divider vertical />
|
||
4 years ago
|
|
||
|
<v-text-field
|
||
|
v-model="searchQueryVal"
|
||
3 years ago
|
autocomplete="new-password"
|
||
3 years ago
|
style="min-width: 100px; width: 120px"
|
||
4 years ago
|
flat
|
||
|
dense
|
||
|
solo
|
||
|
hide-details
|
||
3 years ago
|
:placeholder="
|
||
|
searchField
|
||
|
? $t('placeholder.searchColumn', { searchField })
|
||
|
: 'Search all columns'
|
||
|
"
|
||
3 years ago
|
class="elevation-0 pa-0 flex-grow-1 caption search-field"
|
||
4 years ago
|
@keyup.enter="searchQuery = searchQueryVal"
|
||
|
@blur="searchQuery = searchQueryVal"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</div>
|
||
|
|
||
3 years ago
|
<span
|
||
|
v-if="relationType && false"
|
||
|
class="caption grey--text"
|
||
|
>{{ refTable }}({{ relationPrimaryValue }}) ->
|
||
3 years ago
|
{{ relationType === "hm" ? " Has Many " : " Belongs To " }} ->
|
||
3 years ago
|
{{ table }}</span>
|
||
3 years ago
|
<div class="d-inline-flex">
|
||
3 years ago
|
<div>
|
||
|
<fields
|
||
|
v-if="!isForm"
|
||
|
ref="fields"
|
||
|
v-model="showFields"
|
||
|
:field-list="fieldList"
|
||
|
:meta="meta"
|
||
|
:is-locked="isLocked"
|
||
|
:fields-order.sync="fieldsOrder"
|
||
|
:sql-ui="sqlUi"
|
||
|
:show-system-fields.sync="showSystemFields"
|
||
|
:cover-image-field.sync="coverImageField"
|
||
|
:grouping-field.sync="groupingField"
|
||
|
:is-gallery="isGallery"
|
||
|
:is-kanban="isKanban"
|
||
|
:view-id="selectedViewId"
|
||
|
@updated="loadTableData"
|
||
|
/>
|
||
4 years ago
|
|
||
3 years ago
|
<sort-list
|
||
3 years ago
|
v-if="!isForm"
|
||
3 years ago
|
v-model="sortList"
|
||
|
:is-locked="isLocked"
|
||
|
:meta="meta"
|
||
|
:view-id="selectedViewId"
|
||
|
@updated="loadTableData"
|
||
|
/>
|
||
|
<!-- v-model="sortList"-->
|
||
|
<!-- :field-list="[...realFieldList, ...formulaFieldList]"-->
|
||
|
<column-filter
|
||
3 years ago
|
v-if="!isForm"
|
||
3 years ago
|
v-model="filters"
|
||
|
:meta="meta"
|
||
|
:is-locked="isLocked"
|
||
|
:field-list="[...realFieldList, ...formulaFieldList]"
|
||
|
dense
|
||
|
:view-id="selectedViewId"
|
||
|
@updated="loadTableData"
|
||
|
/>
|
||
|
</div>
|
||
3 years ago
|
<share-view-menu
|
||
|
v-if="!isGallery"
|
||
|
@share="$refs.drawer && $refs.drawer.genShareLink()"
|
||
|
/>
|
||
3 years ago
|
|
||
|
<MoreActions
|
||
|
v-if="!isForm"
|
||
|
ref="csvExportImport"
|
||
|
:meta="meta"
|
||
|
:nodes="nodes"
|
||
|
:query-params="{
|
||
|
fieldsOrder,
|
||
|
fieldFilter,
|
||
|
sortList,
|
||
3 years ago
|
showFields,
|
||
3 years ago
|
}"
|
||
|
:selected-view="selectedView"
|
||
3 years ago
|
:is-view="isView"
|
||
3 years ago
|
@showAdditionalFeatOverlay="showAdditionalFeatOverlay($event)"
|
||
|
@webhook="showAdditionalFeatOverlay('webhooks')"
|
||
3 years ago
|
@reload="reload"
|
||
3 years ago
|
/>
|
||
|
</div>
|
||
3 years ago
|
<v-spacer
|
||
|
class="h-100"
|
||
|
@click="
|
||
|
clickCount = clickCount + 1;
|
||
|
debug = clickCount >= 4;
|
||
|
"
|
||
|
/>
|
||
3 years ago
|
|
||
3 years ago
|
<template v-if="!isForm">
|
||
3 years ago
|
<!-- Export Cache -->
|
||
|
<v-tooltip v-if="debug" bottom>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
3 years ago
|
<v-icon class="mr-3" small v-on="on" @click="exportCache">
|
||
|
mdi-export
|
||
|
</v-icon>
|
||
|
</template>
|
||
3 years ago
|
<span class="caption"> Export Cache </span>
|
||
3 years ago
|
</v-tooltip>
|
||
|
<!-- Delete Cache -->
|
||
|
<v-tooltip v-if="debug" bottom>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
3 years ago
|
<v-icon class="mr-3" small v-on="on" @click="deleteCache">
|
||
|
mdi-delete
|
||
|
</v-icon>
|
||
|
</template>
|
||
3 years ago
|
<span class="caption"> Delete Cache </span>
|
||
3 years ago
|
</v-tooltip>
|
||
3 years ago
|
<debug-metas v-if="debug" class="mr-3" />
|
||
|
<v-tooltip bottom>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
|
<v-icon
|
||
|
v-if="!isPkAvail && !isForm"
|
||
|
color="warning"
|
||
|
small
|
||
|
class="mr-3"
|
||
|
v-on="on"
|
||
|
>
|
||
3 years ago
|
mdi-information-outline
|
||
|
</v-icon>
|
||
|
</template>
|
||
3 years ago
|
<span class="caption">
|
||
|
Update & Delete not allowed since the table doesn't have any primary
|
||
|
key
|
||
3 years ago
|
</span>
|
||
|
</v-tooltip>
|
||
3 years ago
|
<lock-menu v-if="_isUIAllowed('view-type')" v-model="lockType" />
|
||
3 years ago
|
|
||
3 years ago
|
<!-- <x-btn
|
||
3 years ago
|
tooltip="Reload view data"
|
||
|
outlined
|
||
|
small
|
||
|
text
|
||
3 years ago
|
btn.class="nc-table-reload-btn px-0"
|
||
|
@click="reload"
|
||
|
>-->
|
||
|
<v-icon small class="mx-n1" color="grey lighten-1">
|
||
|
mdi-circle-small
|
||
|
</v-icon>
|
||
3 years ago
|
<!-- tooltip="Reload view data" -->
|
||
3 years ago
|
<x-icon
|
||
3 years ago
|
:tooltip="$t('general.reload')"
|
||
3 years ago
|
icon.class="nc-table-reload-btn mx-1"
|
||
|
small
|
||
3 years ago
|
@click="reloadClick"
|
||
3 years ago
|
>
|
||
3 years ago
|
mdi-reload
|
||
|
</x-icon>
|
||
3 years ago
|
<v-icon
|
||
|
v-if="isEditable && relationType !== 'bt'"
|
||
|
small
|
||
|
class="mx-n1"
|
||
|
color="grey lighten-1"
|
||
|
>
|
||
3 years ago
|
mdi-circle-small
|
||
|
</v-icon>
|
||
|
<!-- </x-btn>-->
|
||
|
<!-- <x-btn-->
|
||
|
<!-- v-if="isEditable && relationType !== 'bt'"-->
|
||
|
<!-- tooltip="Add new row"-->
|
||
|
<!-- :disabled="isLocked"-->
|
||
|
<!-- outlined-->
|
||
|
<!-- small-->
|
||
|
<!-- text-->
|
||
|
<!-- btn.class="nc-add-new-row-btn"-->
|
||
|
<!-- @click="insertNewRow(true,true)"-->
|
||
|
<!-- >-->
|
||
3 years ago
|
|
||
|
<!-- tooltip="Add new row"-->
|
||
3 years ago
|
<x-icon
|
||
3 years ago
|
v-if="!isView && isEditable && relationType !== 'bt'"
|
||
3 years ago
|
icon.class="nc-add-new-row-btn mx-1"
|
||
3 years ago
|
:tooltip="$t('activity.addRow')"
|
||
3 years ago
|
:disabled="isLocked"
|
||
3 years ago
|
small
|
||
3 years ago
|
:color="['success', '']"
|
||
3 years ago
|
@click="clickAddNewIcon"
|
||
3 years ago
|
>
|
||
3 years ago
|
mdi-plus-outline
|
||
|
</x-icon>
|
||
|
<!-- </x-btn>-->
|
||
|
<!-- <x-btn
|
||
3 years ago
|
small
|
||
|
text
|
||
3 years ago
|
btn.class="nc-save-new-row-btn"
|
||
3 years ago
|
outlined
|
||
|
tooltip="Save new rows"
|
||
|
:disabled="!edited || isLocked"
|
||
|
@click="save"
|
||
|
>
|
||
|
<v-icon small class="mr-1" color="grey darken-3">
|
||
|
save
|
||
|
</v-icon>
|
||
|
Save
|
||
3 years ago
|
</x-btn>-->
|
||
|
<!-- <v-tooltip-->
|
||
|
<!-- bottom-->
|
||
|
<!-- >-->
|
||
|
<!-- <template #activator="{on}">-->
|
||
|
<!-- <v-btn
|
||
3 years ago
|
v-show="_isUIAllowed('table-delete')"
|
||
|
class="nc-table-delete-btn"
|
||
|
:disabled="isLocked"
|
||
|
small
|
||
|
outlined
|
||
|
text
|
||
|
v-on="on"
|
||
|
@click="checkAndDeleteTable"
|
||
3 years ago
|
>-->
|
||
3 years ago
|
<v-icon
|
||
|
v-if="_isUIAllowed('table-delete')"
|
||
|
small
|
||
|
class="mx-n1"
|
||
|
color="grey lighten-1"
|
||
|
>
|
||
3 years ago
|
mdi-circle-small
|
||
|
</v-icon>
|
||
|
<x-icon
|
||
|
v-if="_isUIAllowed('table-delete')"
|
||
|
icon.class="nc-table-delete-btn mx-1 mr-1"
|
||
|
:disabled="isLocked"
|
||
|
small
|
||
3 years ago
|
:color="['red', '']"
|
||
3 years ago
|
:tooltip="$t('activity.deleteTable')"
|
||
3 years ago
|
@click="checkAndDeleteTable"
|
||
|
>
|
||
|
mdi-delete-outline
|
||
|
</x-icon>
|
||
|
|
||
|
<v-icon small class="ml-n2" color="grey lighten-1">
|
||
|
mdi-circle-small
|
||
|
</v-icon>
|
||
|
<!-- </v-btn>-->
|
||
|
<!-- </template>-->
|
||
|
<!-- <span class="">Delete table</span>-->
|
||
|
<!-- </v-tooltip>-->
|
||
3 years ago
|
</template>
|
||
3 years ago
|
|
||
4 years ago
|
<!-- Cell height -->
|
||
|
<!-- <v-menu>
|
||
|
<template v-slot:activator="{ on, attrs }">
|
||
|
<v-icon
|
||
|
v-bind="attrs"
|
||
|
v-on="on" small
|
||
|
class="mx-2"
|
||
|
color="grey darken-3"
|
||
|
>
|
||
|
mdi-arrow-collapse-vertical
|
||
|
</v-icon>
|
||
|
</template>
|
||
|
|
||
|
<v-list dense class="caption">
|
||
|
|
||
|
<v-list-item v-for="h in cellHeights" dense @click.stop="cellHeight = h.size" :key="h.size">
|
||
|
<v-list-item-icon class="mr-1">
|
||
|
<v-icon small :color="cellHeight === h.size && 'primary'">{{ h.icon }}</v-icon>
|
||
|
</v-list-item-icon>
|
||
|
<v-list-item-title :class="{'primary--text' : cellHeight === h.size}" style="text-transform: capitalize">
|
||
|
{{ h.size }}
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
</v-list>
|
||
|
</v-menu>-->
|
||
|
|
||
3 years ago
|
<!--tooltip="Toggle navigation drawer"-->
|
||
4 years ago
|
<x-btn
|
||
3 years ago
|
:tooltip="$t('tooltip.toggleNavDraw')"
|
||
3 years ago
|
outlined
|
||
|
small
|
||
|
text
|
||
3 years ago
|
:btn-class="{ 'primary lighten-5 nc-toggle-nav-drawer': !toggleDrawer }"
|
||
|
@click="
|
||
|
toggleDrawer = !toggleDrawer;
|
||
|
toggleClick();
|
||
|
"
|
||
4 years ago
|
>
|
||
3 years ago
|
<v-icon small class="mx-0" color="grey darken-3">
|
||
|
{{ toggleDrawer ? "mdi-door-closed" : "mdi-door-open" }}
|
||
4 years ago
|
</v-icon>
|
||
|
</x-btn>
|
||
|
</v-toolbar>
|
||
3 years ago
|
<div
|
||
|
:class="`cell-height-${cellHeight}`"
|
||
3 years ago
|
style="height: calc(100% - 32px); overflow: auto; transition: width 100ms"
|
||
3 years ago
|
class="d-flex"
|
||
4 years ago
|
>
|
||
|
<div class="flex-grow-1 h-100" style="overflow-y: auto">
|
||
3 years ago
|
<div
|
||
3 years ago
|
v-if="selectedViewId && selectedView"
|
||
3 years ago
|
ref="table"
|
||
3 years ago
|
:style="{ height: isForm ? '100%' : 'calc(100% - 36px)' }"
|
||
|
style="overflow: auto; width: 100%"
|
||
3 years ago
|
>
|
||
3 years ago
|
<!-- <v-skeleton-loader v-if="!dataLoaded && loadingData || !meta" type="table" />-->
|
||
3 years ago
|
<template v-if="selectedView.type === viewTypes.GRID">
|
||
4 years ago
|
<xc-grid-view
|
||
|
ref="ncgridview"
|
||
3 years ago
|
:loading="loadingData"
|
||
|
:is-view="isView"
|
||
3 years ago
|
droppable
|
||
3 years ago
|
:relation-type="relationType"
|
||
4 years ago
|
:columns-width.sync="columnsWidth"
|
||
|
:is-locked="isLocked"
|
||
|
:table="table"
|
||
3 years ago
|
:available-columns="availableColumns"
|
||
|
:show-fields="showFields"
|
||
|
:sql-ui="sqlUi"
|
||
|
:is-editable="isEditable"
|
||
4 years ago
|
:nodes="nodes"
|
||
3 years ago
|
:primary-value-column="primaryValueColumn"
|
||
|
:belongs-to="belongsTo"
|
||
|
:has-many="hasMany"
|
||
4 years ago
|
:data="data"
|
||
3 years ago
|
:visible-col-length="visibleColLength"
|
||
4 years ago
|
:meta="meta"
|
||
3 years ago
|
:is-virtual="selectedView && selectedView.type === 'vtable'"
|
||
3 years ago
|
:api="api"
|
||
3 years ago
|
:is-pk-avail="isPkAvail"
|
||
3 years ago
|
:view-id="selectedViewId"
|
||
3 years ago
|
@drop="onFileDrop"
|
||
4 years ago
|
@onNewColCreation="onNewColCreation"
|
||
3 years ago
|
@colDelete="onColDelete"
|
||
4 years ago
|
@onCellValueChange="onCellValueChange"
|
||
|
@insertNewRow="insertNewRow"
|
||
|
@showRowContextMenu="showRowContextMenu"
|
||
|
@expandRow="expandRow"
|
||
|
@onRelationDelete="loadMeta"
|
||
3 years ago
|
@loadTableData="loadTableData"
|
||
3 years ago
|
@loadMeta="loadMeta"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</template>
|
||
3 years ago
|
<template v-else-if="selectedView.type === viewTypes.GALLERY">
|
||
4 years ago
|
<gallery-view
|
||
3 years ago
|
:is-locked="isLocked"
|
||
4 years ago
|
:nodes="nodes"
|
||
|
:table="table"
|
||
|
:show-fields="showFields"
|
||
|
:available-columns="availableColumns"
|
||
|
:meta="meta"
|
||
|
:data="data"
|
||
3 years ago
|
:sql-ui="sqlUi"
|
||
3 years ago
|
:view-id="selectedViewId"
|
||
3 years ago
|
:primary-value-column="primaryValueColumn"
|
||
3 years ago
|
:cover-image-field.sync="coverImageField"
|
||
3 years ago
|
@expandForm="
|
||
|
({ rowIndex, rowMeta }) => expandRow(rowIndex, rowMeta)
|
||
|
"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</template>
|
||
3 years ago
|
<template v-else-if="isKanban">
|
||
3 years ago
|
<v-container v-if="kanban.loadingData" fluid>
|
||
3 years ago
|
<v-row>
|
||
|
<v-col v-for="idx in 5" :key="idx">
|
||
3 years ago
|
<v-skeleton-loader type="image@3" />
|
||
3 years ago
|
</v-col>
|
||
|
</v-row>
|
||
|
</v-container>
|
||
4 years ago
|
<kanban-view
|
||
3 years ago
|
v-if="!kanban.loadingData && kanban.data.length"
|
||
4 years ago
|
:nodes="nodes"
|
||
|
:table="table"
|
||
|
:show-fields="showFields"
|
||
|
:available-columns="availableColumns"
|
||
|
:meta="meta"
|
||
3 years ago
|
:kanban="kanban"
|
||
3 years ago
|
:sql-ui="sqlUi"
|
||
3 years ago
|
:primary-value-column="primaryValueColumn"
|
||
3 years ago
|
:grouping-field.sync="groupingField"
|
||
|
:api="api"
|
||
3 years ago
|
@expandKanbanForm="({ rowIdx }) => expandKanbanForm(rowIdx)"
|
||
3 years ago
|
@insertNewRow="insertNewRow"
|
||
3 years ago
|
@loadMoreKanbanData="
|
||
|
(groupingFieldVal) => loadMoreKanbanData(groupingFieldVal)
|
||
|
"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</template>
|
||
3 years ago
|
<template
|
||
|
v-else-if="selectedView && selectedView.show_as === 'calendar'"
|
||
|
>
|
||
4 years ago
|
<calendar-view
|
||
|
:nodes="nodes"
|
||
|
:table="table"
|
||
|
:show-fields="showFields"
|
||
|
:available-columns="availableColumns"
|
||
|
:meta="meta"
|
||
|
:data="data"
|
||
3 years ago
|
:primary-value-column="primaryValueColumn"
|
||
3 years ago
|
@expandForm="
|
||
|
({ rowIndex, rowMeta }) => expandRow(rowIndex, rowMeta)
|
||
|
"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</template>
|
||
3 years ago
|
<template v-else-if="selectedView.type === viewTypes.FORM">
|
||
3 years ago
|
<form-view
|
||
3 years ago
|
:id="selectedViewId"
|
||
3 years ago
|
ref="formView"
|
||
3 years ago
|
:key="selectedViewId + viewKey"
|
||
3 years ago
|
:view-id="selectedViewId"
|
||
3 years ago
|
:nodes="nodes"
|
||
|
:table="table"
|
||
|
:available-columns="availableColumns"
|
||
|
:meta="meta"
|
||
|
:data="data"
|
||
3 years ago
|
:show-fields.sync="showFields"
|
||
|
:all-columns="allColumns"
|
||
|
:field-list="fieldList"
|
||
|
:is-locked="isLocked"
|
||
3 years ago
|
:db-alias="nodes.dbAlias"
|
||
3 years ago
|
:api="api"
|
||
|
:sql-ui="sqlUi"
|
||
3 years ago
|
:fields-order.sync="fieldsOrder"
|
||
3 years ago
|
:primary-value-column="primaryValueColumn"
|
||
|
:form-params.sync="extraViewParams.formParams"
|
||
3 years ago
|
:view.sync="selectedView"
|
||
3 years ago
|
:view-title="selectedView.title"
|
||
3 years ago
|
@onNewColCreation="loadMeta(false)"
|
||
3 years ago
|
/>
|
||
|
</template>
|
||
4 years ago
|
</div>
|
||
3 years ago
|
<template v-if="data && (isGrid || isGallery)">
|
||
3 years ago
|
<pagination
|
||
3 years ago
|
v-model="page"
|
||
3 years ago
|
:count="count"
|
||
|
:size="size"
|
||
3 years ago
|
@input="clickPagination"
|
||
3 years ago
|
/>
|
||
3 years ago
|
</template>
|
||
4 years ago
|
</div>
|
||
|
<spreadsheet-nav-drawer
|
||
3 years ago
|
v-if="meta"
|
||
3 years ago
|
ref="drawer"
|
||
3 years ago
|
:query-params="listQueryParams"
|
||
3 years ago
|
:is-view="isView"
|
||
3 years ago
|
:current-api-url="currentApiUrl"
|
||
|
:toggle-drawer="toggleDrawer"
|
||
4 years ago
|
:nodes="nodes"
|
||
|
:table="table"
|
||
|
:meta="meta"
|
||
3 years ago
|
:selected-view-id.sync="selectedViewId"
|
||
3 years ago
|
:cover-image-field.sync="coverImageField"
|
||
3 years ago
|
:grouping-field.sync="groupingField"
|
||
3 years ago
|
:selected-view.sync="selectedView"
|
||
|
:primary-value-column="primaryValueColumn"
|
||
|
:concatenated-x-where="concatenatedXWhere"
|
||
4 years ago
|
:sort="sort"
|
||
|
:filters.sync="filters"
|
||
3 years ago
|
:sort-list.sync="sortList"
|
||
|
:show-fields.sync="showFields"
|
||
4 years ago
|
:load="loadViews"
|
||
|
:hide-views="!relation"
|
||
3 years ago
|
:show-advance-options.sync="showAdvanceOptions"
|
||
|
:fields-order.sync="fieldsOrder"
|
||
|
:view-status.sync="viewStatus"
|
||
|
:columns-width.sync="columnsWidth"
|
||
3 years ago
|
:show-system-fields.sync="showSystemFields"
|
||
3 years ago
|
:extra-view-params.sync="extraViewParams"
|
||
3 years ago
|
:views.sync="meta.views"
|
||
|
@rerender="viewKey++"
|
||
3 years ago
|
@generateNewViewKey="generateNewViewKey"
|
||
3 years ago
|
@mapFieldsAndShowFields="mapFieldsAndShowFields"
|
||
|
@loadTableData="loadTableData"
|
||
4 years ago
|
@showAdditionalFeatOverlay="showAdditionalFeatOverlay($event)"
|
||
|
>
|
||
3 years ago
|
<!-- <v-tooltip bottom>
|
||
3 years ago
|
<template #activator="{on}">
|
||
4 years ago
|
<v-list-item
|
||
|
v-on="on"
|
||
3 years ago
|
@click="showAdditionalFeatOverlay('webhooks')"
|
||
|
>
|
||
3 years ago
|
<v-icon x-small class="mr-2 nc-automations">
|
||
3 years ago
|
mdi-hook
|
||
|
</v-icon>
|
||
4 years ago
|
<span class="caption"> Automations</span>
|
||
|
</v-list-item>
|
||
|
</template>
|
||
|
Create Automations or API Webhooks
|
||
3 years ago
|
</v-tooltip>-->
|
||
3 years ago
|
<!-- <v-tooltip bottom>
|
||
3 years ago
|
<template #activator="{on}">
|
||
4 years ago
|
<v-list-item
|
||
|
v-on="on"
|
||
3 years ago
|
@click="showAdditionalFeatOverlay('acl')"
|
||
|
>
|
||
|
<v-icon x-small class="mr-2">
|
||
|
mdi-shield-edit-outline
|
||
|
</v-icon>
|
||
4 years ago
|
<span class="caption"> API ACL</span>
|
||
|
</v-list-item>
|
||
|
</template>
|
||
|
Create / Edit API Webhooks
|
||
3 years ago
|
</v-tooltip>-->
|
||
4 years ago
|
<v-list-item
|
||
|
v-if="showAdvanceOptions"
|
||
3 years ago
|
@click="showAdditionalFeatOverlay('validators')"
|
||
|
>
|
||
3 years ago
|
<v-icon x-small class="mr-2">
|
||
|
mdi-sticker-check-outline
|
||
|
</v-icon>
|
||
4 years ago
|
<span class="caption"> API Validators</span>
|
||
|
</v-list-item>
|
||
3 years ago
|
<v-divider v-if="showAdvanceOptions" class="advance-menu-divider" />
|
||
4 years ago
|
|
||
|
<v-list-item
|
||
|
v-if="showAdvanceOptions"
|
||
3 years ago
|
@click="showAdditionalFeatOverlay('columns')"
|
||
|
>
|
||
3 years ago
|
<v-icon x-small class="mr-2">
|
||
|
mdi-view-column
|
||
|
</v-icon>
|
||
4 years ago
|
<span class="caption font-weight-light">SQL Columns</span>
|
||
|
</v-list-item>
|
||
|
<v-list-item
|
||
|
v-if="showAdvanceOptions"
|
||
3 years ago
|
@click="showAdditionalFeatOverlay('indexes')"
|
||
|
>
|
||
3 years ago
|
<v-icon x-small class="mr-2">
|
||
|
mdi-blur
|
||
|
</v-icon>
|
||
4 years ago
|
<span class="caption font-weight-light">SQL Indexes</span>
|
||
|
</v-list-item>
|
||
|
<v-list-item
|
||
|
v-if="showAdvanceOptions"
|
||
3 years ago
|
@click="showAdditionalFeatOverlay('triggers')"
|
||
|
>
|
||
3 years ago
|
<v-icon x-small class="mr-2">
|
||
|
mdi-shield-edit-outline
|
||
|
</v-icon>
|
||
4 years ago
|
<span class="caption font-weight-light">SQL Triggers</span>
|
||
|
</v-list-item>
|
||
|
</spreadsheet-nav-drawer>
|
||
|
</div>
|
||
|
|
||
|
<v-menu
|
||
|
v-if="rowContextMenu"
|
||
|
value="rowContextMenu"
|
||
|
:position-x="rowContextMenu.x"
|
||
|
:position-y="rowContextMenu.y"
|
||
|
absolute
|
||
|
offset-y
|
||
|
>
|
||
|
<v-list dense>
|
||
|
<template v-if="isEditable && !isLocked">
|
||
|
<v-list-item
|
||
|
v-if="relationType !== 'bt'"
|
||
3 years ago
|
v-t="['a:row:insert']"
|
||
4 years ago
|
@click="insertNewRow(false)"
|
||
|
>
|
||
3 years ago
|
<span class="caption">
|
||
|
<!-- Insert New Row -->
|
||
3 years ago
|
{{ $t("activity.insertRow") }}
|
||
3 years ago
|
</span>
|
||
4 years ago
|
</v-list-item>
|
||
3 years ago
|
<v-list-item v-t="['a:row:delete']" @click="deleteRow">
|
||
3 years ago
|
<span class="caption">
|
||
|
<!-- Delete Row -->
|
||
3 years ago
|
{{ $t("activity.deleteRow") }}
|
||
3 years ago
|
</span>
|
||
4 years ago
|
</v-list-item>
|
||
3 years ago
|
<v-list-item v-t="['a:row:delete-bulk']" @click="deleteSelectedRows">
|
||
3 years ago
|
<span class="caption">
|
||
|
<!-- Delete Selected Rows -->
|
||
3 years ago
|
{{ $t("activity.deleteSelectedRow") }}
|
||
3 years ago
|
</span>
|
||
4 years ago
|
</v-list-item>
|
||
|
</template>
|
||
3 years ago
|
|
||
3 years ago
|
<template v-if="isEditable && !isLocked && rowContextMenu.col && !rowContextMenu.col.rqd && !rowContextMenu.col.virtual">
|
||
3 years ago
|
<v-tooltip bottom>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
|
<v-list-item
|
||
|
v-t="['a:row:clear']"
|
||
|
v-on="on"
|
||
|
@click="clearCellValue"
|
||
|
>
|
||
3 years ago
|
<span class="caption">Clear</span>
|
||
|
</v-list-item>
|
||
|
</template>
|
||
|
|
||
3 years ago
|
<span
|
||
|
class="caption"
|
||
|
>Set column value to <strong>null</strong></span>
|
||
3 years ago
|
</v-tooltip>
|
||
|
</template>
|
||
4 years ago
|
</v-list>
|
||
|
</v-menu>
|
||
|
<v-dialog
|
||
|
v-if="data"
|
||
3 years ago
|
v-model="showExpandModal"
|
||
|
:overlay-opacity="0.8"
|
||
4 years ago
|
width="1000px"
|
||
|
max-width="100%"
|
||
3 years ago
|
class="mx-auto"
|
||
3 years ago
|
>
|
||
4 years ago
|
<expanded-form
|
||
3 years ago
|
v-if="isKanban && kanban.selectedExpandRow"
|
||
|
:key="kanban.selectedExpandRow.id"
|
||
|
v-model="kanban.selectedExpandRow"
|
||
|
:db-alias="nodes.dbAlias"
|
||
|
:has-many="hasMany"
|
||
|
:belongs-to="belongsTo"
|
||
|
:table="table"
|
||
|
:old-row.sync="kanban.selectedExpandOldRow"
|
||
|
:is-new="kanban.selectedExpandRowMeta.new"
|
||
|
:selected-row-meta="kanban.selectedExpandRowMeta"
|
||
|
:meta="meta"
|
||
|
:sql-ui="sqlUi"
|
||
|
:primary-value-column="primaryValueColumn"
|
||
|
:api="api"
|
||
|
:available-columns="availableColumns"
|
||
3 years ago
|
:show-fields="showFields"
|
||
3 years ago
|
:nodes="nodes"
|
||
|
:query-params="queryParams"
|
||
|
:show-next-prev="false"
|
||
|
:preset-values="presetValues"
|
||
3 years ago
|
:is-locked="isLocked"
|
||
3 years ago
|
@cancel="showExpandModal = false"
|
||
|
@input="
|
||
|
showExpandModal = false;
|
||
|
kanban.selectedExpandRow &&
|
||
|
kanban.selectedExpandRow.rowMeta &&
|
||
|
delete kanban.selectedExpandRow.rowMeta.new;
|
||
|
loadKanbanData(false);
|
||
|
"
|
||
3 years ago
|
@commented="reloadComments"
|
||
|
@next="loadNext"
|
||
|
@prev="loadPrev"
|
||
|
/>
|
||
|
<expanded-form
|
||
3 years ago
|
v-if="
|
||
|
!isKanban &&
|
||
3 years ago
|
selectedExpandRowIndex != null &&
|
||
|
data[selectedExpandRowIndex]
|
||
3 years ago
|
"
|
||
3 years ago
|
:key="selectedExpandRowIndex"
|
||
3 years ago
|
v-model="data[selectedExpandRowIndex].row"
|
||
4 years ago
|
:db-alias="nodes.dbAlias"
|
||
|
:has-many="hasMany"
|
||
|
:belongs-to="belongsTo"
|
||
3 years ago
|
:show-fields="showFields"
|
||
4 years ago
|
:table="table"
|
||
3 years ago
|
:old-row.sync="data[selectedExpandRowIndex].oldRow"
|
||
4 years ago
|
:is-new="data[selectedExpandRowIndex].rowMeta.new"
|
||
|
:selected-row-meta="selectedExpandRowMeta"
|
||
|
:meta="meta"
|
||
|
:sql-ui="sqlUi"
|
||
|
:primary-value-column="primaryValueColumn"
|
||
|
:api="api"
|
||
3 years ago
|
:available-columns="availableColumns"
|
||
3 years ago
|
:nodes="nodes"
|
||
3 years ago
|
:query-params="queryParams"
|
||
3 years ago
|
:show-next-prev="true"
|
||
3 years ago
|
:preset-values="presetValues"
|
||
3 years ago
|
:is-locked="isLocked"
|
||
3 years ago
|
@cancel="showExpandModal = false"
|
||
|
@input="
|
||
|
showExpandModal = false;
|
||
|
data[selectedExpandRowIndex] &&
|
||
|
data[selectedExpandRowIndex].rowMeta &&
|
||
|
delete data[selectedExpandRowIndex].rowMeta.new;
|
||
|
loadTableData();
|
||
|
"
|
||
3 years ago
|
@commented="reloadComments"
|
||
|
@loadTableData="loadTableData"
|
||
3 years ago
|
@next="loadNext"
|
||
|
@prev="loadPrev"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</v-dialog>
|
||
|
<additional-features
|
||
|
v-model="showAddFeatOverlay"
|
||
3 years ago
|
:selected-view="selectedView"
|
||
3 years ago
|
:delete-table="deleteTable"
|
||
|
:nodes="nodes"
|
||
4 years ago
|
:type="featureType"
|
||
|
:table="table"
|
||
3 years ago
|
:meta="meta"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</v-container>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
import { mapActions } from 'vuex'
|
||
|
import debounce from 'debounce'
|
||
|
import { SqlUiFactory, ViewTypes } from 'nocodb-sdk'
|
||
|
import FileSaver from 'file-saver'
|
||
3 years ago
|
import FormView from './views/FormView'
|
||
|
import XcGridView from './views/GridView'
|
||
3 years ago
|
import spreadsheet from './mixins/spreadsheet'
|
||
3 years ago
|
import DebugMetas from '~/components/project/spreadsheet/components/DebugMetas'
|
||
3 years ago
|
|
||
3 years ago
|
import AdditionalFeatures from '~/components/project/spreadsheet/overlay/AdditinalFeatures'
|
||
|
import GalleryView from '~/components/project/spreadsheet/views/GalleryView'
|
||
|
import CalendarView from '~/components/project/spreadsheet/views/CalendarView'
|
||
|
import KanbanView from '~/components/project/spreadsheet/views/KanbanView'
|
||
|
import SortList from '~/components/project/spreadsheet/components/SortListMenu'
|
||
|
import Fields from '~/components/project/spreadsheet/components/FieldsMenu'
|
||
|
import SpreadsheetNavDrawer from '~/components/project/spreadsheet/components/SpreadsheetNavDrawer'
|
||
|
import LockMenu from '~/components/project/spreadsheet/components/LockMenu'
|
||
|
import ExpandedForm from '~/components/project/spreadsheet/components/ExpandedForm'
|
||
|
import Pagination from '~/components/project/spreadsheet/components/Pagination'
|
||
|
import ColumnFilter from '~/components/project/spreadsheet/components/ColumnFilterMenu'
|
||
|
import MoreActions from '~/components/project/spreadsheet/components/MoreActions'
|
||
|
import ShareViewMenu from '~/components/project/spreadsheet/components/ShareViewMenu'
|
||
4 years ago
|
|
||
|
export default {
|
||
3 years ago
|
name: 'RowsXcDataTable',
|
||
4 years ago
|
components: {
|
||
3 years ago
|
ShareViewMenu,
|
||
|
MoreActions,
|
||
3 years ago
|
FormView,
|
||
3 years ago
|
DebugMetas,
|
||
3 years ago
|
Pagination,
|
||
4 years ago
|
ExpandedForm,
|
||
|
LockMenu,
|
||
|
SpreadsheetNavDrawer,
|
||
|
Fields,
|
||
|
SortList,
|
||
|
XcGridView,
|
||
|
KanbanView,
|
||
|
CalendarView,
|
||
|
GalleryView,
|
||
|
ColumnFilter,
|
||
3 years ago
|
AdditionalFeatures
|
||
4 years ago
|
},
|
||
3 years ago
|
mixins: [spreadsheet],
|
||
4 years ago
|
props: {
|
||
3 years ago
|
isView: Boolean,
|
||
3 years ago
|
isActive: Boolean,
|
||
3 years ago
|
tabId: String,
|
||
4 years ago
|
env: String,
|
||
|
nodes: Object,
|
||
|
relationType: String,
|
||
|
relation: Object,
|
||
|
relationIdValue: [String, Number],
|
||
|
refTable: String,
|
||
|
relationPrimaryValue: [String, Number],
|
||
|
deleteTable: Function,
|
||
3 years ago
|
showTabs: [Boolean, Number]
|
||
4 years ago
|
},
|
||
|
data: () => ({
|
||
3 years ago
|
syncDataDebounce: debounce(async function(self) {
|
||
|
await self.syncData()
|
||
3 years ago
|
}, 500),
|
||
3 years ago
|
loadTableDataDeb: debounce(async function(self) {
|
||
|
await self.loadTableDataFn()
|
||
3 years ago
|
}, 200),
|
||
3 years ago
|
viewKey: 0,
|
||
3 years ago
|
extraViewParams: {},
|
||
3 years ago
|
debug: false,
|
||
3 years ago
|
key: 1,
|
||
4 years ago
|
dataLoaded: false,
|
||
3 years ago
|
searchQueryVal: '',
|
||
4 years ago
|
columnsWidth: null,
|
||
|
viewStatus: {
|
||
3 years ago
|
type: null
|
||
4 years ago
|
},
|
||
|
fieldsOrder: [],
|
||
3 years ago
|
coverImageField: null,
|
||
3 years ago
|
groupingField: null,
|
||
3 years ago
|
// showSystemFields: false,
|
||
4 years ago
|
showAdvanceOptions: false,
|
||
|
loadViews: false,
|
||
|
selectedView: {},
|
||
|
overShieldIcon: false,
|
||
|
progress: false,
|
||
3 years ago
|
createViewType: '',
|
||
4 years ago
|
addNewColModal: false,
|
||
|
showAddFeatOverlay: false,
|
||
|
featureType: null,
|
||
|
addNewColMenu: false,
|
||
|
newColumn: {},
|
||
|
shareLink: null,
|
||
|
loadingMeta: true,
|
||
|
loadingData: true,
|
||
|
toggleDrawer: false,
|
||
3 years ago
|
selectedViewId: '',
|
||
4 years ago
|
searchField: null,
|
||
3 years ago
|
searchQuery: '',
|
||
4 years ago
|
showExpandModal: false,
|
||
|
selectedExpandRowIndex: null,
|
||
|
selectedExpandRowMeta: null,
|
||
|
navDrawer: true,
|
||
|
selected: {
|
||
|
row: null,
|
||
3 years ago
|
col: null
|
||
4 years ago
|
},
|
||
|
editEnabled: {
|
||
|
row: null,
|
||
3 years ago
|
col: null
|
||
4 years ago
|
},
|
||
|
page: 1,
|
||
|
count: 0,
|
||
3 years ago
|
// size: 25,
|
||
3 years ago
|
xWhere: '',
|
||
|
sort: '',
|
||
4 years ago
|
|
||
3 years ago
|
cellHeight: 'small',
|
||
4 years ago
|
|
||
|
spreadsheet: null,
|
||
|
options: {
|
||
|
allowToolbar: true,
|
||
3 years ago
|
columnSorting: false
|
||
4 years ago
|
},
|
||
|
filteredData: [],
|
||
|
|
||
3 years ago
|
cellHeights: [
|
||
|
{
|
||
3 years ago
|
size: 'small',
|
||
|
icon: 'mdi-view-headline'
|
||
3 years ago
|
},
|
||
|
{
|
||
3 years ago
|
size: 'medium',
|
||
|
icon: 'mdi-view-sequential'
|
||
3 years ago
|
},
|
||
|
{
|
||
3 years ago
|
size: 'large',
|
||
|
icon: 'mdi-view-stream'
|
||
3 years ago
|
},
|
||
|
{
|
||
3 years ago
|
size: 'xlarge',
|
||
|
icon: 'mdi-ca rd'
|
||
|
}
|
||
3 years ago
|
],
|
||
3 years ago
|
rowContextMenu: null,
|
||
|
presetValues: {},
|
||
|
kanban: {
|
||
|
data: [],
|
||
|
stages: [],
|
||
|
blocks: [],
|
||
|
recordCnt: {},
|
||
|
recordTotalCnt: {},
|
||
|
groupingColumnItems: [],
|
||
3 years ago
|
loadingData: true,
|
||
3 years ago
|
selectedExpandRow: null,
|
||
|
selectedExpandOldRow: null,
|
||
3 years ago
|
selectedExpandRowMeta: null
|
||
3 years ago
|
},
|
||
3 years ago
|
clickCount: 0
|
||
4 years ago
|
}),
|
||
3 years ago
|
watch: {
|
||
3 years ago
|
isActive(n, o) {
|
||
|
if (!o && n) {
|
||
3 years ago
|
this.reload()
|
||
3 years ago
|
}
|
||
|
},
|
||
3 years ago
|
page(p) {
|
||
3 years ago
|
this.$store.commit('tabs/MutSetTabState', {
|
||
3 years ago
|
id: this.uniqueId,
|
||
3 years ago
|
key: 'page',
|
||
|
val: p
|
||
|
})
|
||
3 years ago
|
},
|
||
|
selectedViewId(id) {
|
||
|
if (this.tabsState[this.tabId] && this.tabsState[this.tabId].page) {
|
||
3 years ago
|
this.page = this.tabsState[this.tabId].page || 1
|
||
3 years ago
|
} else {
|
||
3 years ago
|
this.page = 1
|
||
3 years ago
|
}
|
||
|
// this.$store.commit('tabs/MutSetTabState', {
|
||
|
// id: this.tabId,
|
||
|
// key: 'selectedViewId',
|
||
|
// val: id
|
||
|
// })
|
||
3 years ago
|
},
|
||
|
async groupingField(newVal) {
|
||
3 years ago
|
this.groupingField = newVal
|
||
|
if (this.selectedView && this.selectedView.show_as === 'kanban') {
|
||
|
await this.loadKanbanData()
|
||
3 years ago
|
}
|
||
3 years ago
|
}
|
||
3 years ago
|
},
|
||
3 years ago
|
async mounted() {
|
||
4 years ago
|
try {
|
||
3 years ago
|
if (this.tabsState && this.tabsState[this.uniqueId]) {
|
||
|
if (this.tabsState[this.uniqueId].page) {
|
||
3 years ago
|
this.page = this.tabsState[this.uniqueId].page
|
||
3 years ago
|
}
|
||
|
}
|
||
3 years ago
|
await this.createTableIfNewTable()
|
||
|
this.loadingMeta = true
|
||
|
await this.loadMeta(false)
|
||
|
this.loadingMeta = false
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
console.log(e)
|
||
4 years ago
|
}
|
||
3 years ago
|
this.searchField = this.primaryValueColumn
|
||
4 years ago
|
},
|
||
|
methods: {
|
||
3 years ago
|
clickAddNewIcon() {
|
||
3 years ago
|
this.insertNewRow(true, true)
|
||
|
this.$e('c:row:add:grid-top')
|
||
3 years ago
|
},
|
||
|
toggleClick() {
|
||
3 years ago
|
this.$e('c:grid:toggle-navdraw')
|
||
3 years ago
|
},
|
||
4 years ago
|
...mapActions({
|
||
3 years ago
|
loadTablesFromChildTreeNode: 'project/loadTablesFromChildTreeNode'
|
||
4 years ago
|
}),
|
||
3 years ago
|
generateNewViewKey() {
|
||
3 years ago
|
this.viewKey = Math.random()
|
||
3 years ago
|
},
|
||
3 years ago
|
loadNext() {
|
||
3 years ago
|
this.selectedExpandRowIndex =
|
||
3 years ago
|
++this.selectedExpandRowIndex % this.data.length
|
||
3 years ago
|
},
|
||
|
loadPrev() {
|
||
3 years ago
|
this.selectedExpandRowIndex =
|
||
|
--this.selectedExpandRowIndex === -1
|
||
|
? this.data.length - 1
|
||
3 years ago
|
: this.selectedExpandRowIndex
|
||
3 years ago
|
},
|
||
3 years ago
|
async checkAndDeleteTable() {
|
||
|
// if (
|
||
|
// !this.meta || (
|
||
|
// (this.meta.hasMany && this.meta.hasMany.length) ||
|
||
|
// (this.meta.manyToMany && this.meta.manyToMany.length) ||
|
||
|
// (this.meta.belongsTo && this.meta.belongsTo.length))
|
||
|
// ) {
|
||
|
// return this.$toast.info('Please delete relations before deleting table.').goAway(3000)
|
||
|
// }
|
||
3 years ago
|
this.deleteTable('showDialog', this.meta.id)
|
||
3 years ago
|
|
||
|
// if (confirm('Do you want to delete the table?')) {
|
||
|
// await this.$api.meta.tableDelete(this.meta.id)
|
||
|
// }
|
||
3 years ago
|
this.$e('c:table:delete')
|
||
3 years ago
|
},
|
||
|
async reloadClick() {
|
||
3 years ago
|
await this.reload()
|
||
|
this.$e('a:table:reload:navbar')
|
||
3 years ago
|
},
|
||
3 years ago
|
async reload() {
|
||
3 years ago
|
this.$store.dispatch('meta/ActLoadMeta', {
|
||
3 years ago
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
|
tn: this.table,
|
||
3 years ago
|
force: true
|
||
|
})
|
||
|
if (this.selectedView && this.selectedView.show_as === 'kanban') {
|
||
|
await this.loadKanbanData()
|
||
3 years ago
|
} else {
|
||
3 years ago
|
await this.loadTableData()
|
||
3 years ago
|
}
|
||
3 years ago
|
this.key = Math.random()
|
||
3 years ago
|
},
|
||
3 years ago
|
reloadComments() {
|
||
4 years ago
|
if (this.$refs.ncgridview) {
|
||
3 years ago
|
this.$refs.ncgridview.xcAuditModelCommentsCount()
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async syncData() {},
|
||
3 years ago
|
showAdditionalFeatOverlay(feat) {
|
||
3 years ago
|
this.showAddFeatOverlay = true
|
||
|
this.featureType = feat
|
||
4 years ago
|
},
|
||
3 years ago
|
async createTableIfNewTable() {
|
||
3 years ago
|
if (this.nodes.newTable && !this.nodes.tableCreated) {
|
||
3 years ago
|
const columns = this.sqlUi
|
||
|
.getNewTableColumns()
|
||
3 years ago
|
.filter(col =>
|
||
3 years ago
|
this.nodes.newTable.columns.includes(col.column_name)
|
||
3 years ago
|
)
|
||
3 years ago
|
await this.$api.dbTable.create(this.projectId, {
|
||
|
table_name: this.nodes.table_name,
|
||
|
title: this.nodes.title,
|
||
3 years ago
|
columns
|
||
|
})
|
||
3 years ago
|
|
||
4 years ago
|
await this.loadTablesFromChildTreeNode({
|
||
|
_nodes: {
|
||
3 years ago
|
...this.nodes
|
||
|
}
|
||
|
})
|
||
3 years ago
|
// eslint-disable-next-line vue/no-mutating-props
|
||
3 years ago
|
this.nodes.tableCreated = true
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
this.loadViews = true
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
comingSoon() {
|
||
3 years ago
|
this.$toast.info('Coming soon!').goAway(3000)
|
||
4 years ago
|
},
|
||
3 years ago
|
changed(col, row) {
|
||
3 years ago
|
this.$set(
|
||
|
this.data[row].rowMeta,
|
||
3 years ago
|
'changed',
|
||
3 years ago
|
this.data[row].rowMeta.changed || {}
|
||
3 years ago
|
)
|
||
4 years ago
|
if (this.data[row].rowMeta) {
|
||
3 years ago
|
this.$set(
|
||
|
this.data[row].rowMeta.changed,
|
||
|
this.availableColumns[col].column_name,
|
||
|
true
|
||
3 years ago
|
)
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async save() {
|
||
4 years ago
|
for (let row = 0; row < this.rowLength; row++) {
|
||
3 years ago
|
const { row: rowObj, rowMeta } = this.data[row]
|
||
4 years ago
|
if (rowMeta.new) {
|
||
|
try {
|
||
3 years ago
|
this.$set(this.data[row], 'saving', true)
|
||
3 years ago
|
const pks = this.meta.columns.filter((col) => {
|
||
3 years ago
|
return col.pk
|
||
|
})
|
||
3 years ago
|
if (
|
||
|
this.meta.columns.every((col) => {
|
||
3 years ago
|
return !col.ai
|
||
3 years ago
|
}) &&
|
||
|
pks.length &&
|
||
|
pks.every(
|
||
3 years ago
|
col =>
|
||
3 years ago
|
!rowObj[col.title] && !(col.columnDefault || col.default)
|
||
|
)
|
||
|
) {
|
||
|
return this.$toast
|
||
3 years ago
|
.info('Primary column is empty please provide some value')
|
||
|
.goAway(3000)
|
||
4 years ago
|
}
|
||
3 years ago
|
if (
|
||
|
this.meta.columns.some((col) => {
|
||
|
return (
|
||
|
!col.ai &&
|
||
|
col.rqd &&
|
||
|
(rowObj[col.title] === undefined ||
|
||
|
rowObj[col.title] === null) &&
|
||
|
!col.cdf
|
||
3 years ago
|
)
|
||
3 years ago
|
})
|
||
|
) {
|
||
3 years ago
|
return
|
||
3 years ago
|
}
|
||
4 years ago
|
|
||
3 years ago
|
const insertObj = this.meta.columns.reduce((o, col) => {
|
||
3 years ago
|
if (!col.ai && (rowObj && rowObj[col.title]) !== null) {
|
||
3 years ago
|
o[col.title] = rowObj && rowObj[col.title]
|
||
4 years ago
|
}
|
||
3 years ago
|
return o
|
||
|
}, {})
|
||
4 years ago
|
|
||
3 years ago
|
// const insertedData = await this.api.insert(insertObj)
|
||
3 years ago
|
const insertedData = await this.$api.dbViewRow.create(
|
||
3 years ago
|
'noco',
|
||
3 years ago
|
this.projectName,
|
||
3 years ago
|
this.meta.title,
|
||
3 years ago
|
this.selectedView.title,
|
||
|
insertObj
|
||
3 years ago
|
)
|
||
3 years ago
|
|
||
4 years ago
|
this.data.splice(row, 1, {
|
||
|
row: insertedData,
|
||
|
rowMeta: {},
|
||
3 years ago
|
oldRow: { ...insertedData }
|
||
|
})
|
||
4 years ago
|
|
||
3 years ago
|
/* this.$toast.success(`${insertedData[this.primaryValueColumn] ? `${insertedData[this.primaryValueColumn]}'s r` : 'R'}ow saved successfully.`, {
|
||
4 years ago
|
position: 'bottom-center'
|
||
3 years ago
|
}).goAway(3000) */
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
// if (e.response && e.response.data && e.response.data.msg) {
|
||
3 years ago
|
this.$toast
|
||
|
.error(await this._extractSdkResponseErrorMsg(e))
|
||
3 years ago
|
.goAway(3000)
|
||
3 years ago
|
// } else {
|
||
|
// this.$toast.error(`Failed to
|
||
|
//
|
||
|
// row : ${e.message}`).goAway(3000)
|
||
|
// }
|
||
3 years ago
|
} finally {
|
||
3 years ago
|
this.$set(this.data[row], 'saving', false)
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
3 years ago
|
this.syncCount()
|
||
4 years ago
|
},
|
||
3 years ago
|
// // todo: move debounce to cell since this will skip few update api call
|
||
|
// onCellValueChangeDebounce: debounce(async function(col, row, column, self) {
|
||
|
// await self.onCellValueChangeFn(col, row, column)
|
||
|
// }, 100),
|
||
|
// onCellValueChange(col, row, column) {
|
||
|
// this.onCellValueChangeFn(col, row, column)
|
||
|
// },
|
||
3 years ago
|
async onCellValueChange(col, row, column, saved = true) {
|
||
3 years ago
|
if (!this.data[row]) {
|
||
3 years ago
|
return
|
||
3 years ago
|
}
|
||
3 years ago
|
const { row: rowObj, rowMeta, oldRow, saving, lastSave } = this.data[row]
|
||
3 years ago
|
if (!lastSave) {
|
||
3 years ago
|
this.$set(this.data[row], 'lastSave', rowObj[column.title])
|
||
3 years ago
|
}
|
||
4 years ago
|
if (rowMeta.new) {
|
||
3 years ago
|
// return if there is no change
|
||
3 years ago
|
if (
|
||
|
(column && oldRow[column.title] === rowObj[column.title]) ||
|
||
|
saving
|
||
|
) {
|
||
3 years ago
|
return
|
||
3 years ago
|
}
|
||
3 years ago
|
await this.save()
|
||
4 years ago
|
} else {
|
||
|
try {
|
||
3 years ago
|
// if (!this.api) {
|
||
|
// return
|
||
|
// }
|
||
3 years ago
|
// return if there is no change
|
||
3 years ago
|
if (
|
||
|
!column ||
|
||
3 years ago
|
saving ||
|
||
3 years ago
|
(oldRow[column.title] === rowObj[column.title] &&
|
||
|
(lastSave || rowObj[column.title]) === rowObj[column.title])
|
||
|
) {
|
||
3 years ago
|
return
|
||
3 years ago
|
}
|
||
3 years ago
|
if (saved) {
|
||
3 years ago
|
this.$set(this.data[row], 'lastSave', oldRow[column.title])
|
||
3 years ago
|
}
|
||
3 years ago
|
const id = this.meta.columns
|
||
3 years ago
|
.filter(c => c.pk)
|
||
|
.map(c => rowObj[c.title])
|
||
|
.join('___')
|
||
3 years ago
|
|
||
3 years ago
|
if (!id) {
|
||
3 years ago
|
return this.$toast
|
||
|
.info(
|
||
|
"Update not allowed for table which doesn't have primary Key"
|
||
|
)
|
||
3 years ago
|
.goAway(3000)
|
||
3 years ago
|
}
|
||
3 years ago
|
this.$set(this.data[row], 'saving', true)
|
||
3 years ago
|
|
||
3 years ago
|
// eslint-disable-next-line promise/param-names
|
||
3 years ago
|
const newData = await this.$api.dbViewRow.update(
|
||
3 years ago
|
'noco',
|
||
3 years ago
|
this.projectName,
|
||
3 years ago
|
this.meta.title,
|
||
|
this.selectedView.title,
|
||
3 years ago
|
id,
|
||
|
{
|
||
3 years ago
|
[column.title]: rowObj[column.title]
|
||
3 years ago
|
},
|
||
|
{
|
||
3 years ago
|
query: { ignoreWebhook: !saved }
|
||
3 years ago
|
}
|
||
3 years ago
|
)
|
||
3 years ago
|
|
||
|
// audit
|
||
3 years ago
|
this.$api.utils
|
||
|
.auditRowUpdate(id, {
|
||
|
fk_model_id: this.meta.id,
|
||
|
column_name: column.title,
|
||
|
row_id: id,
|
||
|
value: rowObj[column.title],
|
||
3 years ago
|
prev_value: oldRow[column.title]
|
||
3 years ago
|
})
|
||
3 years ago
|
.then(() => {})
|
||
3 years ago
|
|
||
3 years ago
|
this.$set(this.data[row], 'row', { ...rowObj, ...newData })
|
||
3 years ago
|
|
||
3 years ago
|
this.$set(oldRow, column.title, rowObj[column.title])
|
||
3 years ago
|
/* this.$toast.success(`${rowObj[this.primaryValueColumn] ? `${rowObj[this.primaryValueColumn]}'s c` : 'C'}olumn '${column.column_name}' updated successfully.`, {
|
||
4 years ago
|
position: 'bottom-center'
|
||
3 years ago
|
}).goAway(3000) */
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
// if (e.response && e.response.data && e.response.data.msg) {
|
||
3 years ago
|
this.$toast
|
||
|
.error(await this._extractSdkResponseErrorMsg(e))
|
||
3 years ago
|
.goAway(3000)
|
||
3 years ago
|
// } else {
|
||
|
// this.$toast.error(`Failed to update row : ${e.message}`).goAway(3000)
|
||
|
// }
|
||
4 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
this.$set(this.data[row], 'saving', false)
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async deleteRow() {
|
||
4 years ago
|
try {
|
||
3 years ago
|
const rowObj = this.rowContextMenu.row
|
||
4 years ago
|
if (!this.rowContextMenu.rowMeta.new) {
|
||
3 years ago
|
const id =
|
||
|
this.meta &&
|
||
|
this.meta.columns &&
|
||
|
this.meta.columns
|
||
3 years ago
|
.filter(c => c.pk)
|
||
|
.map(c => rowObj[c.title])
|
||
|
.join('___')
|
||
3 years ago
|
|
||
|
if (!id) {
|
||
3 years ago
|
return this.$toast
|
||
|
.info(
|
||
|
"Delete not allowed for table which doesn't have primary Key"
|
||
|
)
|
||
3 years ago
|
.goAway(3000)
|
||
3 years ago
|
}
|
||
3 years ago
|
await this.$api.dbViewRow.delete(
|
||
3 years ago
|
'noco',
|
||
3 years ago
|
this.projectName,
|
||
|
this.meta.title,
|
||
|
this.selectedView.title,
|
||
|
id
|
||
3 years ago
|
)
|
||
4 years ago
|
}
|
||
3 years ago
|
this.data.splice(this.rowContextMenu.index, 1)
|
||
|
this.syncCount()
|
||
3 years ago
|
// this.$toast.success('Deleted row successfully').goAway(3000)
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error(`Failed to delete row : ${e.message}`).goAway(3000)
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async deleteSelectedRows() {
|
||
3 years ago
|
let row = this.rowLength
|
||
3 years ago
|
// let success = 0
|
||
4 years ago
|
while (row--) {
|
||
|
try {
|
||
3 years ago
|
const { row: rowObj, rowMeta } = this.data[row]
|
||
4 years ago
|
if (!rowMeta.selected) {
|
||
3 years ago
|
continue
|
||
4 years ago
|
}
|
||
|
if (!rowMeta.new) {
|
||
3 years ago
|
const id = this.meta.columns
|
||
3 years ago
|
.filter(c => c.pk)
|
||
|
.map(c => rowObj[c.title])
|
||
|
.join('___')
|
||
3 years ago
|
|
||
|
if (!id) {
|
||
3 years ago
|
return this.$toast
|
||
|
.info(
|
||
|
"Delete not allowed for table which doesn't have primary Key"
|
||
|
)
|
||
3 years ago
|
.goAway(3000)
|
||
3 years ago
|
}
|
||
3 years ago
|
await this.$api.dbViewRow.delete(
|
||
3 years ago
|
'noco',
|
||
3 years ago
|
this.projectName,
|
||
|
this.meta.title,
|
||
|
this.selectedView.title,
|
||
|
id
|
||
3 years ago
|
)
|
||
4 years ago
|
}
|
||
3 years ago
|
this.data.splice(row, 1)
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
return this.$toast
|
||
|
.error(`Failed to delete row : ${e.message}`)
|
||
3 years ago
|
.goAway(3000)
|
||
4 years ago
|
}
|
||
|
}
|
||
3 years ago
|
this.syncCount()
|
||
4 years ago
|
},
|
||
3 years ago
|
|
||
|
async clearCellValue() {
|
||
3 years ago
|
const { col, colIndex, row, index } = this.rowContextMenu
|
||
3 years ago
|
if (row[col.title] === null) {
|
||
3 years ago
|
return
|
||
3 years ago
|
}
|
||
3 years ago
|
this.$set(this.data[index].row, col.title, null)
|
||
|
await this.onCellValueChange(colIndex, index, col, true)
|
||
3 years ago
|
},
|
||
3 years ago
|
async insertNewRow(atEnd = false, expand = false, presetValues = {}) {
|
||
3 years ago
|
const isKanban =
|
||
3 years ago
|
this.selectedView && this.selectedView.show_as === 'kanban'
|
||
|
const data = isKanban ? this.kanban.data : this.data
|
||
3 years ago
|
const focusRow = isKanban
|
||
|
? data.length
|
||
|
: atEnd
|
||
3 years ago
|
? this.rowLength
|
||
|
: this.rowContextMenu.index + 1
|
||
|
const focusCol = this.availableColumns.findIndex(c => !c.ai)
|
||
3 years ago
|
data.splice(focusRow, 0, {
|
||
3 years ago
|
row:
|
||
3 years ago
|
this.relationType === 'hm'
|
||
3 years ago
|
? {
|
||
|
...this.fieldList.reduce(
|
||
|
(o, f) => ({
|
||
|
...o,
|
||
3 years ago
|
[f]: presetValues[f] ?? null
|
||
3 years ago
|
}),
|
||
|
{}
|
||
|
),
|
||
3 years ago
|
[this.relation.column_name]: this.relationIdValue
|
||
3 years ago
|
}
|
||
|
: this.fieldList.reduce(
|
||
3 years ago
|
(o, f) => ({
|
||
|
...o,
|
||
|
[f]: presetValues[f] ?? null
|
||
|
}),
|
||
|
{}
|
||
|
),
|
||
4 years ago
|
rowMeta: {
|
||
3 years ago
|
new: true
|
||
3 years ago
|
},
|
||
3 years ago
|
oldRow: {}
|
||
|
})
|
||
|
if (data[focusRow].row[this.groupingField] === 'Uncategorized') {
|
||
|
data[focusRow].row[this.groupingField] = null
|
||
3 years ago
|
}
|
||
3 years ago
|
this.selected = {
|
||
|
row: focusRow,
|
||
3 years ago
|
col: focusCol
|
||
|
}
|
||
3 years ago
|
this.editEnabled = {
|
||
|
row: focusRow,
|
||
3 years ago
|
col: focusCol
|
||
|
}
|
||
|
this.presetValues = presetValues
|
||
4 years ago
|
|
||
|
if (expand) {
|
||
3 years ago
|
if (isKanban) {
|
||
3 years ago
|
this.expandKanbanForm(-1, data[focusRow])
|
||
3 years ago
|
} else {
|
||
3 years ago
|
const { rowMeta } = data[data.length - 1]
|
||
|
this.expandRow(data.length - 1, rowMeta)
|
||
3 years ago
|
}
|
||
4 years ago
|
}
|
||
|
},
|
||
|
|
||
3 years ago
|
async handleKeyDown({ metaKey, key, altKey, shiftKey, ctrlKey }) {
|
||
3 years ago
|
switch ([this._isMac ? metaKey : ctrlKey, key].join('_')) {
|
||
|
case 'true_s':
|
||
|
this.edited && (await this.save())
|
||
|
break
|
||
|
case 'true_l':
|
||
|
await this.loadTableData()
|
||
|
break
|
||
|
case 'true_n':
|
||
|
this.insertNewRow(true)
|
||
|
break
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async loadMeta() {
|
||
3 years ago
|
// load latest table meta
|
||
3 years ago
|
await this.$store.dispatch('meta/ActLoadMeta', {
|
||
4 years ago
|
env: this.nodes.env,
|
||
3 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
3 years ago
|
table_name: this.table,
|
||
3 years ago
|
force: true
|
||
|
})
|
||
3 years ago
|
},
|
||
|
clickPagination() {
|
||
3 years ago
|
this.loadTableData()
|
||
|
this.$e('a:grid:pagination')
|
||
4 years ago
|
},
|
||
3 years ago
|
loadTableData() {
|
||
3 years ago
|
this.loadTableDataDeb(this)
|
||
4 years ago
|
},
|
||
3 years ago
|
async loadTableDataFn() {
|
||
3 years ago
|
if (this.isForm || !this.selectedView || !this.selectedView.title) {
|
||
3 years ago
|
return
|
||
3 years ago
|
}
|
||
3 years ago
|
this.loadingData = true
|
||
4 years ago
|
try {
|
||
3 years ago
|
// if (this.api) {
|
||
|
// const { list, count } = await this.api.paginatedList(this.queryParams)
|
||
|
// const {
|
||
|
// list,
|
||
|
// pageInfo
|
||
|
// } = (await this.$api.data.list(
|
||
|
// this.selectedViewId || this.meta.views[0].id,
|
||
|
// {
|
||
|
// query: {
|
||
|
// ...this.queryParams,
|
||
|
// ...(this._isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(this.sortList) }),
|
||
|
// ...(this._isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(this.filters) })
|
||
|
// }
|
||
|
// })).data.data
|
||
|
|
||
3 years ago
|
const { list, pageInfo } = await this.$api.dbViewRow.list(
|
||
3 years ago
|
'noco',
|
||
3 years ago
|
this.projectName,
|
||
|
this.meta.title,
|
||
|
this.selectedView.title,
|
||
3 years ago
|
this.listQueryParams
|
||
|
)
|
||
3 years ago
|
|
||
3 years ago
|
this.count = pageInfo.totalRows // count
|
||
|
this.data = list.map(row => ({
|
||
3 years ago
|
row,
|
||
|
oldRow: { ...row },
|
||
3 years ago
|
rowMeta: {}
|
||
|
}))
|
||
3 years ago
|
// }
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
console.log(e)
|
||
4 years ago
|
}
|
||
3 years ago
|
this.loadingData = false
|
||
4 years ago
|
},
|
||
3 years ago
|
showRowContextMenu(e, row, rowMeta, index, colIndex, col) {
|
||
3 years ago
|
if (!this.isEditable) {
|
||
3 years ago
|
return
|
||
3 years ago
|
}
|
||
3 years ago
|
e.preventDefault()
|
||
|
this.rowContextMenu = false
|
||
4 years ago
|
this.$nextTick(() => {
|
||
|
this.rowContextMenu = {
|
||
|
x: e.clientX,
|
||
|
y: e.clientY,
|
||
3 years ago
|
row,
|
||
|
index,
|
||
3 years ago
|
rowMeta,
|
||
|
colIndex,
|
||
3 years ago
|
col
|
||
|
}
|
||
|
})
|
||
4 years ago
|
},
|
||
3 years ago
|
expandRow(row, rowMeta) {
|
||
3 years ago
|
this.showExpandModal = true
|
||
|
this.selectedExpandRowIndex = row
|
||
|
this.selectedExpandRowMeta = rowMeta
|
||
4 years ago
|
},
|
||
3 years ago
|
async onNewColCreation(col, oldCol) {
|
||
3 years ago
|
// if (this.$refs.drawer) {
|
||
|
// await this.$refs.drawer.loadViews()
|
||
|
// this.$refs.drawer.onViewIdChange(this.selectedViewId)
|
||
|
// }
|
||
3 years ago
|
await this.loadMeta(true, col, oldCol)
|
||
|
this.$nextTick(async() => {
|
||
|
await this.loadTableData()
|
||
|
})
|
||
|
this.$refs.fields && this.$refs.fields.loadFields()
|
||
3 years ago
|
},
|
||
|
onColDelete() {
|
||
3 years ago
|
this.$refs.fields && this.$refs.fields.loadFields()
|
||
3 years ago
|
},
|
||
|
onFileDrop(ev) {
|
||
3 years ago
|
let file
|
||
3 years ago
|
if (ev.dataTransfer.items) {
|
||
|
// Use DataTransferItemList interface to access the file(s)
|
||
3 years ago
|
if (
|
||
|
ev.dataTransfer.items.length &&
|
||
3 years ago
|
ev.dataTransfer.items[0].kind === 'file'
|
||
3 years ago
|
) {
|
||
3 years ago
|
file = ev.dataTransfer.items[0].getAsFile()
|
||
3 years ago
|
}
|
||
|
} else if (ev.dataTransfer.files.length) {
|
||
3 years ago
|
file = ev.dataTransfer.files[0]
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
if (file && !file.name.endsWith('.csv')) {
|
||
|
return
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
this.$refs.csvExportImport.onCsvFileSelection(file)
|
||
3 years ago
|
},
|
||
|
// Kanban
|
||
|
async loadKanbanData(initKanbanProps = true) {
|
||
|
try {
|
||
|
const kanban = {
|
||
|
data: [],
|
||
|
stages: [],
|
||
|
blocks: [],
|
||
|
recordCnt: {},
|
||
|
recordTotalCnt: {},
|
||
|
groupingColumnItems: [],
|
||
|
loadingData: true,
|
||
|
selectedExpandRow: null,
|
||
|
selectedExpandOldRow: null,
|
||
3 years ago
|
selectedExpandRowMeta: null
|
||
|
}
|
||
3 years ago
|
if (initKanbanProps) {
|
||
3 years ago
|
this.kanban = kanban
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
if (this.api) {
|
||
3 years ago
|
const groupingColumn = this.meta.columns.find(
|
||
3 years ago
|
c => c.title === this.groupingField
|
||
|
)
|
||
3 years ago
|
|
||
|
if (!groupingColumn) {
|
||
3 years ago
|
return
|
||
3 years ago
|
}
|
||
3 years ago
|
const initialLimit = 10
|
||
|
const uncategorized = 'Uncategorized'
|
||
3 years ago
|
|
||
|
kanban.groupingColumnItems = groupingColumn.dtxp
|
||
3 years ago
|
.split(',')
|
||
3 years ago
|
.map((c) => {
|
||
3 years ago
|
const trimCol = c.replace(/'/g, '')
|
||
|
kanban.recordCnt[trimCol] = 0
|
||
|
return trimCol
|
||
3 years ago
|
})
|
||
3 years ago
|
.sort()
|
||
3 years ago
|
|
||
3 years ago
|
kanban.groupingColumnItems.unshift(uncategorized)
|
||
|
kanban.recordCnt[uncategorized] = 0
|
||
3 years ago
|
for (const groupingColumnItem of kanban.groupingColumnItems) {
|
||
3 years ago
|
{
|
||
|
// enrich Kanban data
|
||
3 years ago
|
const { data } = await this.api.get(
|
||
|
`/nc/${this.$store.state.project.projectId}/api/v1/${this.$route.query.name}`,
|
||
|
{
|
||
|
limit: initialLimit,
|
||
|
where:
|
||
|
groupingColumnItem === uncategorized
|
||
|
? `(${this.groupingField},is,null)`
|
||
3 years ago
|
: `(${this.groupingField},eq,${groupingColumnItem})`
|
||
3 years ago
|
}
|
||
3 years ago
|
)
|
||
3 years ago
|
data.forEach((d) => {
|
||
|
// handle composite primary key
|
||
3 years ago
|
d.c_pk = this.meta.columns
|
||
3 years ago
|
.filter(c => c.pk)
|
||
|
.map(c => d[c.title])
|
||
|
.join('___')
|
||
3 years ago
|
if (!d.id) {
|
||
|
// id is required for <kanban-board/>
|
||
3 years ago
|
d.id = d.c_pk
|
||
3 years ago
|
}
|
||
|
kanban.data.push({
|
||
|
row: d,
|
||
|
oldRow: d,
|
||
3 years ago
|
rowMeta: {}
|
||
|
})
|
||
|
kanban.recordCnt[groupingColumnItem] += 1
|
||
3 years ago
|
kanban.blocks.push({
|
||
|
status: groupingColumnItem,
|
||
3 years ago
|
...d
|
||
|
})
|
||
|
})
|
||
3 years ago
|
}
|
||
|
{
|
||
|
// enrich recordTotalCnt
|
||
3 years ago
|
const { data } = await this.api.get(
|
||
|
`/nc/${this.$store.state.project.projectId}/api/v1/${this.$route.query.name}/count`,
|
||
|
{
|
||
|
where:
|
||
|
groupingColumnItem === uncategorized
|
||
|
? `(${this.groupingField},is,null)`
|
||
3 years ago
|
: `(${this.groupingField},eq,${groupingColumnItem})`
|
||
3 years ago
|
}
|
||
3 years ago
|
)
|
||
|
kanban.recordTotalCnt[groupingColumnItem] = data.count
|
||
3 years ago
|
}
|
||
3 years ago
|
}
|
||
|
}
|
||
3 years ago
|
this.kanban = kanban
|
||
3 years ago
|
} catch (e) {
|
||
|
if (e.response && e.response.data && e.response.data.msg) {
|
||
3 years ago
|
this.$toast
|
||
|
.error(e.response.data.msg, {
|
||
3 years ago
|
position: 'bottom-center'
|
||
3 years ago
|
})
|
||
3 years ago
|
.goAway(3000)
|
||
3 years ago
|
} else {
|
||
3 years ago
|
this.$toast
|
||
|
.error(`Error occurred : ${e.message}`, {
|
||
3 years ago
|
position: 'bottom-center'
|
||
3 years ago
|
})
|
||
3 years ago
|
.goAway(3000)
|
||
3 years ago
|
}
|
||
|
} finally {
|
||
3 years ago
|
this.kanban.loadingData = false
|
||
3 years ago
|
}
|
||
|
},
|
||
|
async loadMoreKanbanData(groupingFieldVal) {
|
||
3 years ago
|
const uncategorized = 'uncategorized'
|
||
3 years ago
|
const { data } = await this.api.get(
|
||
|
`/nc/${this.$store.state.project.projectId}/api/v1/${this.$route.query.name}`,
|
||
|
{
|
||
|
limit: 5,
|
||
|
where:
|
||
|
groupingFieldVal === uncategorized
|
||
|
? `(${this.groupingField},is,null)`
|
||
|
: `(${this.groupingField},eq,${groupingFieldVal})`,
|
||
3 years ago
|
offset: this.kanban.recordCnt[groupingFieldVal]
|
||
3 years ago
|
}
|
||
3 years ago
|
)
|
||
3 years ago
|
data.map((d) => {
|
||
3 years ago
|
// handle composite primary key
|
||
3 years ago
|
d.c_pk = this.meta.columns
|
||
3 years ago
|
.filter(c => c.pk)
|
||
|
.map(c => d[c.title])
|
||
|
.join('___')
|
||
3 years ago
|
if (!d.id) {
|
||
3 years ago
|
// id is required for <kanban-board/>
|
||
3 years ago
|
d.id = d.c_pk
|
||
3 years ago
|
}
|
||
3 years ago
|
this.kanban.data.push({
|
||
|
row: d,
|
||
|
oldRow: d,
|
||
3 years ago
|
rowMeta: {}
|
||
|
})
|
||
3 years ago
|
this.kanban.blocks.push({
|
||
|
status: groupingFieldVal,
|
||
3 years ago
|
...d
|
||
|
})
|
||
|
})
|
||
|
this.kanban.recordCnt[groupingFieldVal] += data.length
|
||
3 years ago
|
},
|
||
|
expandKanbanForm(rowIdx, data) {
|
||
|
if (rowIdx != -1) {
|
||
|
// not a new record -> find the target record
|
||
3 years ago
|
data = this.kanban.data.filter(o => o.row.c_pk == rowIdx)[0]
|
||
3 years ago
|
}
|
||
3 years ago
|
this.showExpandModal = true
|
||
|
this.kanban.selectedExpandRow = data.row
|
||
|
this.kanban.selectedExpandOldRow = data.oldRow
|
||
|
this.kanban.selectedExpandRowMeta = data.rowMeta
|
||
3 years ago
|
},
|
||
|
async exportCache() {
|
||
|
try {
|
||
3 years ago
|
const data = await this.$api.utils.cacheGet()
|
||
3 years ago
|
if (!data) {
|
||
3 years ago
|
this.$toast.info('Cache is empty').goAway(3000)
|
||
|
return
|
||
3 years ago
|
}
|
||
3 years ago
|
const blob = new Blob([JSON.stringify(data)], {
|
||
3 years ago
|
type: 'text/plain;charset=utf-8'
|
||
|
})
|
||
|
FileSaver.saveAs(blob, 'cache_exported.json')
|
||
|
this.$toast.info('Exported Cache Successfully').goAway(3000)
|
||
3 years ago
|
} catch (e) {
|
||
3 years ago
|
console.log(e)
|
||
|
this.$toast.error(e.message).goAway(3000)
|
||
3 years ago
|
}
|
||
|
},
|
||
|
async deleteCache() {
|
||
|
try {
|
||
3 years ago
|
await this.$api.utils.cacheDelete()
|
||
|
this.$toast.info('Deleted Cache Successfully').goAway(3000)
|
||
3 years ago
|
} catch (e) {
|
||
3 years ago
|
console.log(e)
|
||
|
this.$toast.error(e.message).goAway(3000)
|
||
3 years ago
|
}
|
||
3 years ago
|
},
|
||
|
async syncCount() {
|
||
3 years ago
|
const { count } = await this.$api.dbViewRow.count(
|
||
3 years ago
|
'noco',
|
||
|
this.$store.getters['project/GtrProjectName'],
|
||
3 years ago
|
this.meta.title,
|
||
|
this.selectedView.title
|
||
3 years ago
|
)
|
||
|
this.count = count
|
||
|
}
|
||
4 years ago
|
},
|
||
|
computed: {
|
||
3 years ago
|
listQueryParams() {
|
||
|
return {
|
||
|
...this.queryParams,
|
||
|
...(this._isUIAllowed('sortSync')
|
||
|
? {}
|
||
|
: { sortArrJson: JSON.stringify(this.sortList) }),
|
||
|
...(this._isUIAllowed('filterSync')
|
||
|
? {}
|
||
|
: { filterArrJson: JSON.stringify(this.filters) })
|
||
|
// sort: ['-FirstName'],
|
||
|
// where: '(FirstName,like,%ro)~or((FirstName,like,%a)~and(FirstName,like,%e%))'
|
||
|
}
|
||
|
},
|
||
3 years ago
|
isLocked() {
|
||
3 years ago
|
return this.lockType === 'locked'
|
||
3 years ago
|
},
|
||
|
lockType: {
|
||
|
get() {
|
||
3 years ago
|
return this.selectedView && this.selectedView.lock_type
|
||
3 years ago
|
},
|
||
|
set(type) {
|
||
3 years ago
|
this.selectedView.lock_type = type
|
||
3 years ago
|
this.$api.dbView.update(this.selectedViewId, {
|
||
3 years ago
|
lock_type: type
|
||
|
})
|
||
|
}
|
||
3 years ago
|
},
|
||
|
showSystemFields: {
|
||
|
get() {
|
||
3 years ago
|
return this.selectedView && this.selectedView.show_system_fields
|
||
3 years ago
|
},
|
||
|
set(v) {
|
||
|
if (this.selectedView) {
|
||
3 years ago
|
this.selectedView.show_system_fields = v
|
||
3 years ago
|
this.$api.dbView
|
||
|
.update(this.selectedViewId, {
|
||
3 years ago
|
show_system_fields: v
|
||
3 years ago
|
})
|
||
|
.then(() => {
|
||
|
if (v) {
|
||
3 years ago
|
this.loadTableData()
|
||
3 years ago
|
}
|
||
3 years ago
|
})
|
||
3 years ago
|
}
|
||
3 years ago
|
}
|
||
3 years ago
|
},
|
||
|
viewTypes() {
|
||
3 years ago
|
return ViewTypes
|
||
3 years ago
|
},
|
||
3 years ago
|
tabsState() {
|
||
3 years ago
|
return this.$store.state.tabs.tabsState || {}
|
||
3 years ago
|
},
|
||
3 years ago
|
uniqueId() {
|
||
3 years ago
|
return `${this.tabId}_${this.selectedViewId}`
|
||
3 years ago
|
},
|
||
|
size() {
|
||
3 years ago
|
return (
|
||
3 years ago
|
(this.$store.state.project.appInfo &&
|
||
|
this.$store.state.project.appInfo.defaultLimit) ||
|
||
3 years ago
|
25
|
||
3 years ago
|
)
|
||
3 years ago
|
},
|
||
3 years ago
|
isPkAvail() {
|
||
3 years ago
|
return this.meta && this.meta.columns.some(c => c.pk)
|
||
3 years ago
|
},
|
||
3 years ago
|
isGallery() {
|
||
3 years ago
|
return this.selectedView && this.selectedView.type === ViewTypes.GALLERY
|
||
3 years ago
|
},
|
||
3 years ago
|
isForm() {
|
||
3 years ago
|
return this.selectedView && this.selectedView.type === ViewTypes.FORM
|
||
3 years ago
|
},
|
||
3 years ago
|
isKanban() {
|
||
3 years ago
|
return this.selectedView && this.selectedView.type === ViewTypes.KANBAN
|
||
3 years ago
|
},
|
||
|
isGrid() {
|
||
3 years ago
|
return this.selectedView && this.selectedView.type === ViewTypes.GRID
|
||
3 years ago
|
},
|
||
3 years ago
|
meta() {
|
||
3 years ago
|
return this.$store.state.meta.metas[this.table]
|
||
3 years ago
|
},
|
||
3 years ago
|
currentApiUrl() {
|
||
3 years ago
|
return (
|
||
|
this.api &&
|
||
|
`${this.api.apiUrl}?` +
|
||
|
Object.entries(this.queryParams)
|
||
3 years ago
|
.filter(p => p[1])
|
||
3 years ago
|
.map(
|
||
|
([key, val]) =>
|
||
|
`${encodeURIComponent(key)}=${encodeURIComponent(val)}`
|
||
|
)
|
||
3 years ago
|
.join('&')
|
||
|
)
|
||
4 years ago
|
},
|
||
3 years ago
|
isEditable() {
|
||
3 years ago
|
return this._isUIAllowed('xcDatatableEditable')
|
||
4 years ago
|
},
|
||
3 years ago
|
sqlUi() {
|
||
3 years ago
|
// return SqlUI.create(this.nodes.dbConnection)
|
||
3 years ago
|
return SqlUiFactory.create(this.nodes.dbConnection)
|
||
4 years ago
|
},
|
||
3 years ago
|
api() {
|
||
3 years ago
|
return (
|
||
|
this.meta &&
|
||
|
this.$ncApis.get({
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
3 years ago
|
table: this.meta.table_name
|
||
3 years ago
|
})
|
||
3 years ago
|
)
|
||
3 years ago
|
// return this.meta && this.meta.title ? ApiFactory.create(this.$store.getters['project/GtrProjectType'], this.meta && this.meta.title, this.meta && this.meta.columns, this, this.meta) : null
|
||
3 years ago
|
}
|
||
|
}
|
||
|
}
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
/deep/ .v-input__control .v-input__slot .v-input--selection-controls__input {
|
||
3 years ago
|
transform: scale(0.85);
|
||
4 years ago
|
margin-right: 0;
|
||
|
}
|
||
|
|
||
3 years ago
|
/deep/ .xc-toolbar .v-input__slot,
|
||
|
.navigation .v-input__slot {
|
||
4 years ago
|
box-shadow: none !important;
|
||
|
}
|
||
|
|
||
|
/deep/ .navigation .v-input__slot input::placeholder {
|
||
3 years ago
|
font-size: 0.8rem;
|
||
4 years ago
|
}
|
||
|
|
||
|
/deep/ .v-btn {
|
||
|
text-transform: capitalize;
|
||
|
}
|
||
|
|
||
3 years ago
|
.row-expand-icon,
|
||
|
.row-checkbox {
|
||
4 years ago
|
opacity: 0;
|
||
|
}
|
||
|
|
||
|
/deep/ .row-checkbox .v-input__control {
|
||
|
height: 24px !important;
|
||
|
}
|
||
|
|
||
3 years ago
|
.cell-height-medium td,
|
||
|
.cell-height-medium tr {
|
||
4 years ago
|
min-height: 35px !important;
|
||
|
/*height: 35px !important;*/
|
||
|
/*max-height: 35px !important;*/
|
||
|
}
|
||
|
|
||
3 years ago
|
.cell-height-large td,
|
||
|
.cell-height-large tr {
|
||
4 years ago
|
min-height: 40px !important;
|
||
|
/*height: 40px !important;*/
|
||
|
/*max-height: 40px !important;*/
|
||
|
}
|
||
|
|
||
3 years ago
|
.cell-height-xlarge td,
|
||
|
.cell-height-xlarge tr {
|
||
4 years ago
|
min-height: 50px !important;
|
||
|
/*height: 50px !important;*/
|
||
|
/*max-height: 50px !important;*/
|
||
|
}
|
||
|
|
||
|
/deep/ .xc-border.search-box {
|
||
|
overflow: visible;
|
||
|
border-radius: 4px;
|
||
|
}
|
||
|
|
||
|
/deep/ .xc-border.search-box .v-input {
|
||
3 years ago
|
transition: 0.4s border-color;
|
||
4 years ago
|
}
|
||
|
|
||
|
/deep/ .xc-border.search-box .v-input--is-focused {
|
||
|
border: 1px solid var(--v-primary-base) !important;
|
||
|
margin: -1px;
|
||
|
}
|
||
|
|
||
3 years ago
|
/deep/
|
||
|
.search-field.v-text-field.v-text-field--solo.v-input--dense
|
||
|
> .v-input__control {
|
||
4 years ago
|
min-height: auto;
|
||
|
}
|
||
|
|
||
|
.views-navigation-drawer {
|
||
3 years ago
|
transition: 0.4s max-width, 0.4s min-width;
|
||
4 years ago
|
}
|
||
|
|
||
|
.new-column-header {
|
||
|
text-align: center;
|
||
|
min-width: 70px;
|
||
|
}
|
||
|
|
||
|
/deep/ .v-input__control label {
|
||
|
font-size: inherit;
|
||
|
}
|
||
3 years ago
|
|
||
|
/deep/ .nc-table-toolbar > .v-toolbar__content {
|
||
3 years ago
|
padding: 0;
|
||
|
}
|
||
4 years ago
|
</style>
|
||
|
|
||
|
<!--
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
3 years ago
|
* @author Wing-Kam Wong <wingkwong.code@gmail.com>
|
||
4 years ago
|
*
|
||
|
* @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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|