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.
1781 lines
57 KiB
1781 lines
57 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"
|
||
|
>
|
||
2 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">
|
||
2 years ago
|
<v-icon class="ml-2" small color="grey"> mdi-magnify </v-icon>
|
||
4 years ago
|
|
||
2 years ago
|
<v-icon color="grey" class="pl-0 pa-1" small> mdi-menu-down </v-icon>
|
||
4 years ago
|
</div>
|
||
|
</template>
|
||
|
<v-list dense>
|
||
2 years ago
|
<v-list-item v-for="col in availableRealColumns" :key="col.column_name" @click="searchField = col.title">
|
||
3 years ago
|
<v-icon color="grey darken-4" small class="mr-1">
|
||
|
{{ col.icon }}
|
||
|
</v-icon>
|
||
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
|
||
2 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>
|
||
|
|
||
2 years ago
|
<span v-if="relationType && false" class="caption grey--text"
|
||
|
>{{ refTable }}({{ relationPrimaryValue }}) -> {{ relationType === 'hm' ? ' Has Many ' : ' Belongs To ' }} ->
|
||
|
{{ 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"
|
||
|
/>
|
||
|
<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"
|
||
3 years ago
|
@updated="loadTableData(false)"
|
||
3 years ago
|
/>
|
||
3 years ago
|
<sort-list
|
||
|
v-if="!isForm"
|
||
|
v-model="sortList"
|
||
|
:is-locked="isLocked"
|
||
|
:meta="meta"
|
||
|
:view-id="selectedViewId"
|
||
3 years ago
|
@updated="loadTableData(false)"
|
||
3 years ago
|
/>
|
||
3 years ago
|
</div>
|
||
2 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 }">
|
||
2 years ago
|
<v-icon class="mr-3" small v-on="on" @click="exportCache"> mdi-export </v-icon>
|
||
3 years ago
|
</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 }">
|
||
2 years ago
|
<v-icon class="mr-3" small v-on="on" @click="deleteCache"> mdi-delete </v-icon>
|
||
3 years ago
|
</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 }">
|
||
2 years ago
|
<v-icon v-if="!isPkAvail && !isForm" color="warning" small class="mr-3" v-on="on">
|
||
3 years ago
|
mdi-information-outline
|
||
|
</v-icon>
|
||
|
</template>
|
||
2 years ago
|
<span class="caption"> Update & Delete not allowed since the table doesn't have any primary key </span>
|
||
3 years ago
|
</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"
|
||
|
>-->
|
||
2 years ago
|
<v-icon small class="mx-n1" color="grey lighten-1"> mdi-circle-small </v-icon>
|
||
3 years ago
|
<!-- tooltip="Reload view data" -->
|
||
2 years ago
|
<x-icon :tooltip="$t('general.reload')" icon.class="nc-table-reload-btn mx-1" small @click="reloadClick">
|
||
3 years ago
|
mdi-reload
|
||
|
</x-icon>
|
||
2 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
|
>-->
|
||
2 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>
|
||
|
|
||
2 years ago
|
<v-icon small class="ml-n2" color="grey lighten-1"> mdi-circle-small </v-icon>
|
||
3 years ago
|
<!-- </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">
|
||
2 years ago
|
{{ 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">
|
||
2 years ago
|
<div ref="table" :style="{ height: isForm ? '100%' : 'calc(100% - 36px)' }" style="overflow: auto; width: 100%">
|
||
|
<div
|
||
|
v-if="loadingData && (isGallery || isGrid)"
|
||
|
class="d-100 h-100 align-center justify-center d-flex flex-column"
|
||
|
>
|
||
3 years ago
|
<v-progress-circular size="40" color="grey" width="2" indeterminate class="mb-4" />
|
||
|
<span v-if="selectedView" class="caption grey--text">Loading view data... </span>
|
||
|
</div>
|
||
|
|
||
2 years ago
|
<template v-else-if="selectedViewId && selectedView">
|
||
3 years ago
|
<!-- <v-skeleton-loader v-if="!dataLoaded && loadingData || !meta" type="table" />-->
|
||
|
<template v-if="selectedView.type === viewTypes.GRID">
|
||
|
<xc-grid-view
|
||
|
ref="ncgridview"
|
||
|
:loading="loadingData"
|
||
|
:is-view="isView"
|
||
|
droppable
|
||
|
:relation-type="relationType"
|
||
|
:columns-width.sync="columnsWidth"
|
||
|
:is-locked="isLocked"
|
||
|
:table="table"
|
||
|
:available-columns="availableColumns"
|
||
|
:show-fields="showFields"
|
||
|
:sql-ui="sqlUi"
|
||
|
:is-editable="isEditable"
|
||
|
:nodes="nodes"
|
||
|
:primary-value-column="primaryValueColumn"
|
||
|
:belongs-to="belongsTo"
|
||
|
:has-many="hasMany"
|
||
|
:data="data"
|
||
|
:visible-col-length="visibleColLength"
|
||
|
:meta="meta"
|
||
|
:is-virtual="selectedView && selectedView.type === 'vtable'"
|
||
|
:api="api"
|
||
|
:is-pk-avail="isPkAvail"
|
||
|
:view-id="selectedViewId"
|
||
|
@drop="onFileDrop"
|
||
|
@onNewColCreation="onNewColCreation"
|
||
|
@colDelete="onColDelete"
|
||
|
@onCellValueChange="onCellValueChange"
|
||
|
@insertNewRow="insertNewRow"
|
||
|
@showRowContextMenu="showRowContextMenu"
|
||
|
@expandRow="expandRow"
|
||
|
@onRelationDelete="loadMeta"
|
||
|
@loadTableData="loadTableData"
|
||
|
@loadMeta="loadMeta"
|
||
|
/>
|
||
|
</template>
|
||
|
<template v-else-if="selectedView.type === viewTypes.GALLERY">
|
||
|
<gallery-view
|
||
|
:is-locked="isLocked"
|
||
|
:nodes="nodes"
|
||
|
:table="table"
|
||
|
:show-fields="showFields"
|
||
|
:available-columns="availableColumns"
|
||
|
:meta="meta"
|
||
|
:data="data"
|
||
|
:sql-ui="sqlUi"
|
||
|
:view-id="selectedViewId"
|
||
|
:primary-value-column="primaryValueColumn"
|
||
|
:cover-image-field.sync="coverImageField"
|
||
2 years ago
|
@expandForm="({ rowIndex, rowMeta }) => expandRow(rowIndex, rowMeta)"
|
||
3 years ago
|
/>
|
||
|
</template>
|
||
|
<template v-else-if="isKanban">
|
||
|
<v-container v-if="kanban.loadingData" fluid>
|
||
|
<v-row>
|
||
|
<v-col v-for="idx in 5" :key="idx">
|
||
|
<v-skeleton-loader type="image@3" />
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
</v-container>
|
||
|
<kanban-view
|
||
|
v-if="!kanban.loadingData && kanban.data.length"
|
||
|
:nodes="nodes"
|
||
|
:table="table"
|
||
|
:show-fields="showFields"
|
||
|
:available-columns="availableColumns"
|
||
|
:meta="meta"
|
||
|
:kanban="kanban"
|
||
|
:sql-ui="sqlUi"
|
||
|
:primary-value-column="primaryValueColumn"
|
||
|
:grouping-field.sync="groupingField"
|
||
|
:api="api"
|
||
|
@expandKanbanForm="({ rowIdx }) => expandKanbanForm(rowIdx)"
|
||
|
@insertNewRow="insertNewRow"
|
||
2 years ago
|
@loadMoreKanbanData="groupingFieldVal => loadMoreKanbanData(groupingFieldVal)"
|
||
3 years ago
|
/>
|
||
|
</template>
|
||
2 years ago
|
<template v-else-if="selectedView && selectedView.show_as === 'calendar'">
|
||
3 years ago
|
<calendar-view
|
||
|
:nodes="nodes"
|
||
|
:table="table"
|
||
|
:show-fields="showFields"
|
||
|
:available-columns="availableColumns"
|
||
|
:meta="meta"
|
||
|
:data="data"
|
||
|
:primary-value-column="primaryValueColumn"
|
||
2 years ago
|
@expandForm="({ rowIndex, rowMeta }) => expandRow(rowIndex, rowMeta)"
|
||
3 years ago
|
/>
|
||
|
</template>
|
||
|
<template v-else-if="selectedView.type === viewTypes.FORM">
|
||
|
<form-view
|
||
|
:id="selectedViewId"
|
||
|
ref="formView"
|
||
|
:key="selectedViewId + viewKey"
|
||
|
:view-id="selectedViewId"
|
||
|
:nodes="nodes"
|
||
|
:table="table"
|
||
|
:available-columns="availableColumns"
|
||
|
:meta="meta"
|
||
|
:data="data"
|
||
|
:show-fields.sync="showFields"
|
||
|
:all-columns="allColumns"
|
||
|
:field-list="fieldList"
|
||
|
:is-locked="isLocked"
|
||
|
:db-alias="nodes.dbAlias"
|
||
|
:api="api"
|
||
|
:sql-ui="sqlUi"
|
||
|
:fields-order.sync="fieldsOrder"
|
||
|
:primary-value-column="primaryValueColumn"
|
||
|
:form-params.sync="extraViewParams.formParams"
|
||
|
:view.sync="selectedView"
|
||
|
:view-title="selectedView.title"
|
||
|
@onNewColCreation="loadMeta(false)"
|
||
|
/>
|
||
|
</template>
|
||
3 years ago
|
</template>
|
||
4 years ago
|
</div>
|
||
3 years ago
|
<template v-if="data && (isGrid || isGallery)">
|
||
2 years ago
|
<pagination v-model="page" :count="count" :size="size" @input="clickPagination" />
|
||
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"
|
||
3 years ago
|
@loadTableData="loadTableData(false)"
|
||
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>-->
|
||
2 years ago
|
<v-list-item v-if="showAdvanceOptions" @click="showAdditionalFeatOverlay('validators')">
|
||
|
<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
|
|
||
2 years ago
|
<v-list-item v-if="showAdvanceOptions" @click="showAdditionalFeatOverlay('columns')">
|
||
|
<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>
|
||
2 years ago
|
<v-list-item v-if="showAdvanceOptions" @click="showAdditionalFeatOverlay('indexes')">
|
||
|
<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>
|
||
2 years ago
|
<v-list-item v-if="showAdvanceOptions" @click="showAdditionalFeatOverlay('triggers')">
|
||
|
<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">
|
||
2 years ago
|
<v-list-item v-if="relationType !== 'bt'" v-t="['a:row:insert']" @click="insertNewRow(false)">
|
||
3 years ago
|
<span class="caption">
|
||
|
<!-- Insert New Row -->
|
||
2 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 -->
|
||
2 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 -->
|
||
2 years ago
|
{{ $t('activity.deleteSelectedRow') }}
|
||
3 years ago
|
</span>
|
||
4 years ago
|
</v-list-item>
|
||
|
</template>
|
||
3 years ago
|
|
||
2 years ago
|
<template
|
||
|
v-if="
|
||
|
isEditable &&
|
||
|
!isLocked &&
|
||
|
rowContextMenu.col &&
|
||
|
!rowContextMenu.col.rqd &&
|
||
|
!rowContextMenu.col.virtual &&
|
||
|
rowContextMenu.col.uidt !== 'Formula'
|
||
|
"
|
||
|
>
|
||
3 years ago
|
<v-tooltip bottom>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
2 years ago
|
<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>
|
||
|
|
||
2 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
|
transition="dialog-bottom-transition"
|
||
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;
|
||
2 years ago
|
kanban.selectedExpandRow && kanban.selectedExpandRow.rowMeta && delete kanban.selectedExpandRow.rowMeta.new;
|
||
3 years ago
|
loadKanbanData(false);
|
||
|
"
|
||
3 years ago
|
@commented="reloadComments"
|
||
|
@next="loadNext"
|
||
|
@prev="loadPrev"
|
||
|
/>
|
||
|
<expanded-form
|
||
2 years ago
|
v-if="!isKanban && selectedExpandRowIndex != null && data[selectedExpandRowIndex]"
|
||
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"
|
||
4 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>
|
||
2 years ago
|
import { mapActions } from 'vuex';
|
||
|
import debounce from 'debounce';
|
||
|
import { SqlUiFactory, ViewTypes, UITypes } from 'nocodb-sdk';
|
||
|
import FileSaver from 'file-saver';
|
||
|
import FormView from './views/FormView';
|
||
|
import XcGridView from './views/GridView';
|
||
|
import spreadsheet from './mixins/spreadsheet';
|
||
|
import DebugMetas from '~/components/project/spreadsheet/components/DebugMetas';
|
||
|
|
||
|
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';
|
||
|
import getPlainText from '~/components/project/spreadsheet/helpers/getPlainText';
|
||
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,
|
||
2 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,
|
||
2 years ago
|
showTabs: [Boolean, Number],
|
||
4 years ago
|
},
|
||
|
data: () => ({
|
||
2 years ago
|
syncDataDebounce: debounce(async function (self) {
|
||
|
await self.syncData();
|
||
3 years ago
|
}, 500),
|
||
2 years ago
|
loadTableDataDeb: debounce(async function (self, ignoreLoader) {
|
||
|
await self.loadTableDataFn(ignoreLoader);
|
||
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: {
|
||
2 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,
|
||
2 years ago
|
col: null,
|
||
4 years ago
|
},
|
||
|
editEnabled: {
|
||
|
row: null,
|
||
2 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,
|
||
2 years ago
|
columnSorting: false,
|
||
4 years ago
|
},
|
||
|
filteredData: [],
|
||
|
|
||
3 years ago
|
cellHeights: [
|
||
|
{
|
||
3 years ago
|
size: 'small',
|
||
2 years ago
|
icon: 'mdi-view-headline',
|
||
3 years ago
|
},
|
||
|
{
|
||
3 years ago
|
size: 'medium',
|
||
2 years ago
|
icon: 'mdi-view-sequential',
|
||
3 years ago
|
},
|
||
|
{
|
||
3 years ago
|
size: 'large',
|
||
2 years ago
|
icon: 'mdi-view-stream',
|
||
3 years ago
|
},
|
||
|
{
|
||
3 years ago
|
size: 'xlarge',
|
||
2 years ago
|
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,
|
||
2 years ago
|
selectedExpandRowMeta: null,
|
||
3 years ago
|
},
|
||
2 years ago
|
clickCount: 0,
|
||
4 years ago
|
}),
|
||
3 years ago
|
watch: {
|
||
3 years ago
|
isActive(n, o) {
|
||
|
if (!o && n) {
|
||
2 years ago
|
this.reload(true);
|
||
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',
|
||
2 years ago
|
val: p,
|
||
|
});
|
||
3 years ago
|
},
|
||
|
selectedViewId(id) {
|
||
|
if (this.tabsState[this.tabId] && this.tabsState[this.tabId].page) {
|
||
2 years ago
|
this.page = this.tabsState[this.tabId].page || 1;
|
||
3 years ago
|
} else {
|
||
2 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) {
|
||
2 years ago
|
this.groupingField = newVal;
|
||
3 years ago
|
if (this.selectedView && this.selectedView.show_as === 'kanban') {
|
||
2 years ago
|
await this.loadKanbanData();
|
||
3 years ago
|
}
|
||
2 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) {
|
||
2 years ago
|
this.page = this.tabsState[this.uniqueId].page;
|
||
3 years ago
|
}
|
||
|
}
|
||
2 years ago
|
await this.createTableIfNewTable();
|
||
|
this.loadingMeta = true;
|
||
|
await this.loadMeta(false);
|
||
|
this.loadingMeta = false;
|
||
4 years ago
|
} catch (e) {
|
||
2 years ago
|
console.log(e);
|
||
4 years ago
|
}
|
||
2 years ago
|
this.searchField = this.primaryValueColumn;
|
||
4 years ago
|
},
|
||
|
methods: {
|
||
3 years ago
|
clickAddNewIcon() {
|
||
2 years ago
|
this.insertNewRow(true, true);
|
||
|
this.$e('c:row:add:grid-top');
|
||
3 years ago
|
},
|
||
|
toggleClick() {
|
||
2 years ago
|
this.$e('c:grid:toggle-navdraw');
|
||
3 years ago
|
},
|
||
4 years ago
|
...mapActions({
|
||
2 years ago
|
loadTablesFromChildTreeNode: 'project/loadTablesFromChildTreeNode',
|
||
4 years ago
|
}),
|
||
3 years ago
|
generateNewViewKey() {
|
||
2 years ago
|
this.viewKey = Math.random();
|
||
3 years ago
|
},
|
||
3 years ago
|
loadNext() {
|
||
2 years ago
|
this.selectedExpandRowIndex = ++this.selectedExpandRowIndex % this.data.length;
|
||
3 years ago
|
},
|
||
|
loadPrev() {
|
||
3 years ago
|
this.selectedExpandRowIndex =
|
||
2 years ago
|
--this.selectedExpandRowIndex === -1 ? this.data.length - 1 : 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)
|
||
|
// }
|
||
2 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)
|
||
|
// }
|
||
2 years ago
|
this.$e('c:table:delete');
|
||
3 years ago
|
},
|
||
|
async reloadClick() {
|
||
2 years ago
|
await this.reload();
|
||
|
this.$e('a:table:reload:navbar');
|
||
3 years ago
|
},
|
||
3 years ago
|
async reload(ignoreLoader = false) {
|
||
3 years ago
|
this.$store.dispatch('meta/ActLoadMeta', {
|
||
3 years ago
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
2 years ago
|
table_name: this.table,
|
||
2 years ago
|
force: true,
|
||
|
});
|
||
3 years ago
|
if (this.selectedView && this.selectedView.show_as === 'kanban') {
|
||
2 years ago
|
await this.loadKanbanData();
|
||
3 years ago
|
} else {
|
||
2 years ago
|
await this.loadTableData(ignoreLoader);
|
||
3 years ago
|
}
|
||
2 years ago
|
this.key = Math.random();
|
||
3 years ago
|
},
|
||
3 years ago
|
reloadComments() {
|
||
4 years ago
|
if (this.$refs.ncgridview) {
|
||
2 years ago
|
this.$refs.ncgridview.xcAuditModelCommentsCount();
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async syncData() {},
|
||
3 years ago
|
showAdditionalFeatOverlay(feat) {
|
||
2 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) {
|
||
2 years ago
|
const columns = this.sqlUi.getNewTableColumns().filter(col => {
|
||
|
if (col.column_name === 'id' && this.nodes.newTable.columns.includes('id_ag')) {
|
||
|
Object.assign(col, this.sqlUi.getDataTypeForUiType({ uidt: UITypes.ID }, 'AG'));
|
||
|
|
||
|
col.dtxp = this.sqlUi.getDefaultLengthForDatatype(col.dt);
|
||
|
col.dtxs = this.sqlUi.getDefaultScaleForDatatype(col.dt);
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
return this.nodes.newTable.columns.includes(col.column_name);
|
||
|
});
|
||
3 years ago
|
await this.$api.dbTable.create(this.projectId, {
|
||
|
table_name: this.nodes.table_name,
|
||
|
title: this.nodes.title,
|
||
2 years ago
|
columns,
|
||
|
});
|
||
3 years ago
|
|
||
4 years ago
|
await this.loadTablesFromChildTreeNode({
|
||
|
_nodes: {
|
||
2 years ago
|
...this.nodes,
|
||
|
},
|
||
|
});
|
||
3 years ago
|
// eslint-disable-next-line vue/no-mutating-props
|
||
2 years ago
|
this.nodes.tableCreated = true;
|
||
4 years ago
|
}
|
||
|
|
||
2 years ago
|
this.loadViews = true;
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
comingSoon() {
|
||
2 years ago
|
this.$toast.info('Coming soon!').goAway(3000);
|
||
4 years ago
|
},
|
||
3 years ago
|
changed(col, row) {
|
||
2 years ago
|
this.$set(this.data[row].rowMeta, 'changed', this.data[row].rowMeta.changed || {});
|
||
4 years ago
|
if (this.data[row].rowMeta) {
|
||
2 years ago
|
this.$set(this.data[row].rowMeta.changed, this.availableColumns[col].column_name, true);
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async save() {
|
||
4 years ago
|
for (let row = 0; row < this.rowLength; row++) {
|
||
2 years ago
|
const { row: rowObj, rowMeta } = this.data[row];
|
||
4 years ago
|
if (rowMeta.new) {
|
||
|
try {
|
||
2 years ago
|
this.$set(this.data[row], 'saving', true);
|
||
|
const pks = this.meta.columns.filter(col => {
|
||
|
return col.pk;
|
||
|
});
|
||
3 years ago
|
if (
|
||
2 years ago
|
this.meta.columns.every(col => {
|
||
|
return !col.ai;
|
||
3 years ago
|
}) &&
|
||
|
pks.length &&
|
||
2 years ago
|
pks.every(col => !rowObj[col.title] && !(col.columnDefault || col.default) && !(col.meta && col.meta.ag))
|
||
3 years ago
|
) {
|
||
2 years ago
|
return this.$toast.info('Primary column is empty please provide some value').goAway(3000);
|
||
4 years ago
|
}
|
||
3 years ago
|
if (
|
||
2 years ago
|
this.meta.columns.some(col => {
|
||
3 years ago
|
return (
|
||
|
!col.ai &&
|
||
|
col.rqd &&
|
||
3 years ago
|
!(col.meta && col.meta.ag) &&
|
||
2 years ago
|
(rowObj[col.title] === undefined || rowObj[col.title] === null) &&
|
||
3 years ago
|
!col.cdf
|
||
2 years ago
|
);
|
||
3 years ago
|
})
|
||
|
) {
|
||
2 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) {
|
||
2 years ago
|
o[col.title] = rowObj && rowObj[col.title];
|
||
4 years ago
|
}
|
||
2 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.id,
|
||
|
this.selectedView.id,
|
||
3 years ago
|
insertObj
|
||
2 years ago
|
);
|
||
3 years ago
|
|
||
4 years ago
|
this.data.splice(row, 1, {
|
||
|
row: insertedData,
|
||
|
rowMeta: {},
|
||
2 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) {
|
||
2 years ago
|
this.$toast.error(await this._extractSdkResponseErrorMsg(e)).goAway(3000);
|
||
3 years ago
|
// } else {
|
||
|
// this.$toast.error(`Failed to
|
||
|
//
|
||
|
// row : ${e.message}`).goAway(3000)
|
||
|
// }
|
||
3 years ago
|
} finally {
|
||
2 years ago
|
this.$set(this.data[row], 'saving', false);
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
2 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]) {
|
||
2 years ago
|
return;
|
||
3 years ago
|
}
|
||
2 years ago
|
const { row: rowObj, rowMeta, oldRow, saving, lastSave } = this.data[row];
|
||
3 years ago
|
if (!lastSave) {
|
||
2 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
|
||
2 years ago
|
if ((column && oldRow[column.title] === rowObj[column.title]) || saving) {
|
||
|
return;
|
||
3 years ago
|
}
|
||
2 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])
|
||
|
) {
|
||
2 years ago
|
return;
|
||
3 years ago
|
}
|
||
3 years ago
|
if (saved) {
|
||
2 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])
|
||
2 years ago
|
.join('___');
|
||
3 years ago
|
|
||
3 years ago
|
if (!id) {
|
||
2 years ago
|
return this.$toast.info("Update not allowed for table which doesn't have primary Key").goAway(3000);
|
||
3 years ago
|
}
|
||
2 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.id,
|
||
|
this.selectedView.id,
|
||
3 years ago
|
id,
|
||
|
{
|
||
2 years ago
|
[column.title]: rowObj[column.title],
|
||
3 years ago
|
},
|
||
|
{
|
||
2 years ago
|
query: { ignoreWebhook: !saved },
|
||
3 years ago
|
}
|
||
2 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,
|
||
2 years ago
|
value: getPlainText(rowObj[column.title]),
|
||
2 years ago
|
prev_value: getPlainText(oldRow[column.title]),
|
||
3 years ago
|
})
|
||
2 years ago
|
.then(() => {});
|
||
3 years ago
|
|
||
2 years ago
|
this.$set(this.data[row], 'row', { ...rowObj, ...newData });
|
||
3 years ago
|
|
||
2 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) {
|
||
2 years ago
|
this.$toast.error(await this._extractSdkResponseErrorMsg(e)).goAway(3000);
|
||
3 years ago
|
// } else {
|
||
|
// this.$toast.error(`Failed to update row : ${e.message}`).goAway(3000)
|
||
|
// }
|
||
4 years ago
|
}
|
||
3 years ago
|
|
||
2 years ago
|
this.$set(this.data[row], 'saving', false);
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async deleteRow() {
|
||
4 years ago
|
try {
|
||
2 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])
|
||
2 years ago
|
.join('___');
|
||
3 years ago
|
|
||
2 years ago
|
const successfulDeletion = await this.deleteRowById(id);
|
||
|
if (!successfulDeletion) {
|
||
2 years ago
|
return;
|
||
|
}
|
||
4 years ago
|
}
|
||
2 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) {
|
||
2 years ago
|
this.$toast.error(`Failed to delete row : ${e.message}`).goAway(3000);
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async deleteSelectedRows() {
|
||
2 years ago
|
let row = this.rowLength;
|
||
4 years ago
|
while (row--) {
|
||
|
try {
|
||
2 years ago
|
const { row: rowObj, rowMeta } = this.data[row];
|
||
4 years ago
|
if (!rowMeta.selected) {
|
||
2 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])
|
||
2 years ago
|
.join('___');
|
||
3 years ago
|
|
||
2 years ago
|
const successfulDeletion = await this.deleteRowById(id);
|
||
|
if (!successfulDeletion) {
|
||
|
continue;
|
||
3 years ago
|
}
|
||
4 years ago
|
}
|
||
2 years ago
|
this.data.splice(row, 1);
|
||
4 years ago
|
} catch (e) {
|
||
2 years ago
|
return this.$toast.error(`Failed to delete row : ${e.message}`).goAway(3000);
|
||
4 years ago
|
}
|
||
|
}
|
||
2 years ago
|
this.syncCount();
|
||
4 years ago
|
},
|
||
3 years ago
|
|
||
2 years ago
|
async deleteRowById(id) {
|
||
|
try {
|
||
|
if (!id) {
|
||
|
this.$toast.info("Delete not allowed for table which doesn't have primary Key").goAway(3000);
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
const res = await this.$api.dbViewRow.delete('noco', this.projectName, this.meta.id, this.selectedView.id, id);
|
||
|
|
||
|
if (res?.message) {
|
||
|
this.$toast
|
||
|
.info(
|
||
|
`<div style="padding:10px 4px">Unable to delete row with ID ${id} because of the following:
|
||
|
<br><br>${res.message.join('<br>')}<br><br>
|
||
|
Clear the data first & try again</div>`
|
||
|
)
|
||
|
.goAway(5000);
|
||
|
return false;
|
||
|
}
|
||
|
} catch (e) {
|
||
|
this.$toast.error(`Failed to delete row : ${e.message}`).goAway(3000);
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
},
|
||
|
|
||
3 years ago
|
async clearCellValue() {
|
||
2 years ago
|
const { col, colIndex, row, index } = this.rowContextMenu;
|
||
3 years ago
|
if (row[col.title] === null) {
|
||
2 years ago
|
return;
|
||
3 years ago
|
}
|
||
2 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 = {}) {
|
||
2 years ago
|
const isKanban = this.selectedView && this.selectedView.show_as === 'kanban';
|
||
|
const data = isKanban ? this.kanban.data : this.data;
|
||
|
const focusRow = isKanban ? data.length : atEnd ? 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,
|
||
2 years ago
|
[f]: presetValues[f] ?? null,
|
||
3 years ago
|
}),
|
||
|
{}
|
||
|
),
|
||
2 years ago
|
[this.relation.column_name]: this.relationIdValue,
|
||
3 years ago
|
}
|
||
|
: this.fieldList.reduce(
|
||
2 years ago
|
(o, f) => ({
|
||
|
...o,
|
||
|
[f]: presetValues[f] ?? null,
|
||
|
}),
|
||
|
{}
|
||
|
),
|
||
4 years ago
|
rowMeta: {
|
||
2 years ago
|
new: true,
|
||
3 years ago
|
},
|
||
2 years ago
|
oldRow: {},
|
||
|
});
|
||
3 years ago
|
if (data[focusRow].row[this.groupingField] === 'Uncategorized') {
|
||
2 years ago
|
data[focusRow].row[this.groupingField] = null;
|
||
3 years ago
|
}
|
||
3 years ago
|
this.selected = {
|
||
|
row: focusRow,
|
||
2 years ago
|
col: focusCol,
|
||
|
};
|
||
3 years ago
|
this.editEnabled = {
|
||
|
row: focusRow,
|
||
2 years ago
|
col: focusCol,
|
||
|
};
|
||
|
this.presetValues = presetValues;
|
||
4 years ago
|
|
||
|
if (expand) {
|
||
3 years ago
|
if (isKanban) {
|
||
2 years ago
|
this.expandKanbanForm(-1, data[focusRow]);
|
||
3 years ago
|
} else {
|
||
2 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':
|
||
2 years ago
|
this.edited && (await this.save());
|
||
|
break;
|
||
3 years ago
|
case 'true_l':
|
||
2 years ago
|
await this.loadTableData();
|
||
|
break;
|
||
3 years ago
|
case 'true_n':
|
||
2 years ago
|
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,
|
||
2 years ago
|
force: true,
|
||
|
});
|
||
3 years ago
|
},
|
||
|
clickPagination() {
|
||
2 years ago
|
this.loadTableData(false);
|
||
|
this.$e('a:grid:pagination');
|
||
4 years ago
|
},
|
||
3 years ago
|
loadTableData(ignoreLoader = true) {
|
||
2 years ago
|
this.loadTableDataDeb(this, ignoreLoader);
|
||
4 years ago
|
},
|
||
3 years ago
|
async loadTableDataFn(ignoreLoader = true) {
|
||
3 years ago
|
if (this.isForm || !this.selectedView || !this.selectedView.title) {
|
||
2 years ago
|
return;
|
||
3 years ago
|
}
|
||
2 years ago
|
this.loadingData = !ignoreLoader;
|
||
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,
|
||
3 years ago
|
this.meta.id,
|
||
|
this.selectedView.id,
|
||
3 years ago
|
this.listQueryParams
|
||
2 years ago
|
);
|
||
3 years ago
|
|
||
2 years ago
|
this.count = pageInfo.totalRows; // count
|
||
3 years ago
|
this.data = list.map(row => ({
|
||
3 years ago
|
row,
|
||
|
oldRow: { ...row },
|
||
2 years ago
|
rowMeta: {},
|
||
|
}));
|
||
3 years ago
|
// }
|
||
4 years ago
|
} catch (e) {
|
||
2 years ago
|
this.$toast.error(await this._extractSdkResponseErrorMsg(e)).goAway(3000);
|
||
4 years ago
|
}
|
||
2 years ago
|
this.loadingData = false;
|
||
4 years ago
|
},
|
||
3 years ago
|
showRowContextMenu(e, row, rowMeta, index, colIndex, col) {
|
||
3 years ago
|
if (!this.isEditable) {
|
||
2 years ago
|
return;
|
||
3 years ago
|
}
|
||
2 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,
|
||
2 years ago
|
col,
|
||
|
};
|
||
|
});
|
||
4 years ago
|
},
|
||
3 years ago
|
expandRow(row, rowMeta) {
|
||
2 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)
|
||
|
// }
|
||
2 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() {
|
||
2 years ago
|
this.$refs.fields && this.$refs.fields.loadFields();
|
||
3 years ago
|
},
|
||
|
onFileDrop(ev) {
|
||
2 years ago
|
let file;
|
||
3 years ago
|
if (ev.dataTransfer.items) {
|
||
|
// Use DataTransferItemList interface to access the file(s)
|
||
2 years ago
|
if (ev.dataTransfer.items.length && ev.dataTransfer.items[0].kind === 'file') {
|
||
|
file = ev.dataTransfer.items[0].getAsFile();
|
||
3 years ago
|
}
|
||
|
} else if (ev.dataTransfer.files.length) {
|
||
2 years ago
|
file = ev.dataTransfer.files[0];
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
if (file && !file.name.endsWith('.csv')) {
|
||
2 years ago
|
return;
|
||
3 years ago
|
}
|
||
|
|
||
2 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,
|
||
2 years ago
|
selectedExpandRowMeta: null,
|
||
|
};
|
||
3 years ago
|
if (initKanbanProps) {
|
||
2 years ago
|
this.kanban = kanban;
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
if (this.api) {
|
||
2 years ago
|
const groupingColumn = this.meta.columns.find(c => c.title === this.groupingField);
|
||
3 years ago
|
|
||
|
if (!groupingColumn) {
|
||
2 years ago
|
return;
|
||
3 years ago
|
}
|
||
2 years ago
|
const initialLimit = 10;
|
||
|
const uncategorized = 'Uncategorized';
|
||
3 years ago
|
|
||
|
kanban.groupingColumnItems = groupingColumn.dtxp
|
||
3 years ago
|
.split(',')
|
||
2 years ago
|
.map(c => {
|
||
|
const trimCol = c.replace(/'/g, '');
|
||
|
kanban.recordCnt[trimCol] = 0;
|
||
|
return trimCol;
|
||
3 years ago
|
})
|
||
2 years ago
|
.sort();
|
||
3 years ago
|
|
||
2 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)`
|
||
2 years ago
|
: `(${this.groupingField},eq,${groupingColumnItem})`,
|
||
3 years ago
|
}
|
||
2 years ago
|
);
|
||
|
data.forEach(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])
|
||
2 years ago
|
.join('___');
|
||
3 years ago
|
if (!d.id) {
|
||
|
// id is required for <kanban-board/>
|
||
2 years ago
|
d.id = d.c_pk;
|
||
3 years ago
|
}
|
||
|
kanban.data.push({
|
||
|
row: d,
|
||
|
oldRow: d,
|
||
2 years ago
|
rowMeta: {},
|
||
|
});
|
||
|
kanban.recordCnt[groupingColumnItem] += 1;
|
||
3 years ago
|
kanban.blocks.push({
|
||
|
status: groupingColumnItem,
|
||
2 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)`
|
||
2 years ago
|
: `(${this.groupingField},eq,${groupingColumnItem})`,
|
||
3 years ago
|
}
|
||
2 years ago
|
);
|
||
|
kanban.recordTotalCnt[groupingColumnItem] = data.count;
|
||
3 years ago
|
}
|
||
3 years ago
|
}
|
||
|
}
|
||
2 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, {
|
||
2 years ago
|
position: 'bottom-center',
|
||
3 years ago
|
})
|
||
2 years ago
|
.goAway(3000);
|
||
3 years ago
|
} else {
|
||
3 years ago
|
this.$toast
|
||
|
.error(`Error occurred : ${e.message}`, {
|
||
2 years ago
|
position: 'bottom-center',
|
||
3 years ago
|
})
|
||
2 years ago
|
.goAway(3000);
|
||
3 years ago
|
}
|
||
|
} finally {
|
||
2 years ago
|
this.kanban.loadingData = false;
|
||
3 years ago
|
}
|
||
|
},
|
||
|
async loadMoreKanbanData(groupingFieldVal) {
|
||
2 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})`,
|
||
2 years ago
|
offset: this.kanban.recordCnt[groupingFieldVal],
|
||
3 years ago
|
}
|
||
2 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])
|
||
2 years ago
|
.join('___');
|
||
3 years ago
|
if (!d.id) {
|
||
3 years ago
|
// id is required for <kanban-board/>
|
||
2 years ago
|
d.id = d.c_pk;
|
||
3 years ago
|
}
|
||
3 years ago
|
this.kanban.data.push({
|
||
|
row: d,
|
||
|
oldRow: d,
|
||
2 years ago
|
rowMeta: {},
|
||
|
});
|
||
3 years ago
|
this.kanban.blocks.push({
|
||
|
status: groupingFieldVal,
|
||
2 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
|
||
2 years ago
|
data = this.kanban.data.filter(o => o.row.c_pk == rowIdx)[0];
|
||
3 years ago
|
}
|
||
2 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 {
|
||
2 years ago
|
const data = await this.$api.utils.cacheGet();
|
||
3 years ago
|
if (!data) {
|
||
2 years ago
|
this.$toast.info('Cache is empty').goAway(3000);
|
||
|
return;
|
||
3 years ago
|
}
|
||
3 years ago
|
const blob = new Blob([JSON.stringify(data)], {
|
||
2 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) {
|
||
2 years ago
|
console.log(e);
|
||
|
this.$toast.error(e.message).goAway(3000);
|
||
3 years ago
|
}
|
||
|
},
|
||
|
async deleteCache() {
|
||
|
try {
|
||
2 years ago
|
await this.$api.utils.cacheDelete();
|
||
|
this.$toast.info('Deleted Cache Successfully').goAway(3000);
|
||
3 years ago
|
} catch (e) {
|
||
2 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.id,
|
||
|
this.selectedView.id
|
||
2 years ago
|
);
|
||
|
this.count = count;
|
||
|
},
|
||
4 years ago
|
},
|
||
|
computed: {
|
||
3 years ago
|
listQueryParams() {
|
||
|
return {
|
||
|
...this.queryParams,
|
||
2 years ago
|
...(this._isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(this.sortList) }),
|
||
|
...(this._isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(this.filters) }),
|
||
3 years ago
|
// sort: ['-FirstName'],
|
||
|
// where: '(FirstName,like,%ro)~or((FirstName,like,%a)~and(FirstName,like,%e%))'
|
||
2 years ago
|
};
|
||
3 years ago
|
},
|
||
3 years ago
|
isLocked() {
|
||
2 years ago
|
return this.lockType === 'locked';
|
||
3 years ago
|
},
|
||
|
lockType: {
|
||
|
get() {
|
||
2 years ago
|
return this.selectedView && this.selectedView.lock_type;
|
||
3 years ago
|
},
|
||
|
set(type) {
|
||
2 years ago
|
this.selectedView.lock_type = type;
|
||
3 years ago
|
this.$api.dbView.update(this.selectedViewId, {
|
||
2 years ago
|
lock_type: type,
|
||
|
});
|
||
|
},
|
||
3 years ago
|
},
|
||
|
showSystemFields: {
|
||
|
get() {
|
||
2 years ago
|
return this.selectedView && this.selectedView.show_system_fields;
|
||
3 years ago
|
},
|
||
|
set(v) {
|
||
|
if (this.selectedView) {
|
||
2 years ago
|
this.selectedView.show_system_fields = v;
|
||
3 years ago
|
this.$api.dbView
|
||
|
.update(this.selectedViewId, {
|
||
2 years ago
|
show_system_fields: v,
|
||
3 years ago
|
})
|
||
|
.then(() => {
|
||
|
if (v) {
|
||
2 years ago
|
this.loadTableData();
|
||
3 years ago
|
}
|
||
2 years ago
|
});
|
||
3 years ago
|
}
|
||
2 years ago
|
},
|
||
3 years ago
|
},
|
||
|
viewTypes() {
|
||
2 years ago
|
return ViewTypes;
|
||
3 years ago
|
},
|
||
3 years ago
|
tabsState() {
|
||
2 years ago
|
return this.$store.state.tabs.tabsState || {};
|
||
3 years ago
|
},
|
||
3 years ago
|
uniqueId() {
|
||
2 years ago
|
return `${this.tabId}_${this.selectedViewId}`;
|
||
3 years ago
|
},
|
||
|
size() {
|
||
2 years ago
|
return (this.$store.state.project.appInfo && this.$store.state.project.appInfo.defaultLimit) || 25;
|
||
3 years ago
|
},
|
||
3 years ago
|
isPkAvail() {
|
||
2 years ago
|
return this.meta && this.meta.columns.some(c => c.pk);
|
||
3 years ago
|
},
|
||
3 years ago
|
isGallery() {
|
||
2 years ago
|
return this.selectedView && this.selectedView.type === ViewTypes.GALLERY;
|
||
3 years ago
|
},
|
||
3 years ago
|
isForm() {
|
||
2 years ago
|
return this.selectedView && this.selectedView.type === ViewTypes.FORM;
|
||
3 years ago
|
},
|
||
3 years ago
|
isKanban() {
|
||
2 years ago
|
return this.selectedView && this.selectedView.type === ViewTypes.KANBAN;
|
||
3 years ago
|
},
|
||
|
isGrid() {
|
||
2 years ago
|
return this.selectedView && this.selectedView.type === ViewTypes.GRID;
|
||
3 years ago
|
},
|
||
3 years ago
|
meta() {
|
||
2 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])
|
||
2 years ago
|
.map(([key, val]) => `${encodeURIComponent(key)}=${encodeURIComponent(val)}`)
|
||
3 years ago
|
.join('&')
|
||
2 years ago
|
);
|
||
4 years ago
|
},
|
||
3 years ago
|
isEditable() {
|
||
2 years ago
|
return this._isUIAllowed('xcDatatableEditable');
|
||
4 years ago
|
},
|
||
3 years ago
|
sqlUi() {
|
||
3 years ago
|
// return SqlUI.create(this.nodes.dbConnection)
|
||
2 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,
|
||
2 years ago
|
table: this.meta.table_name,
|
||
3 years ago
|
})
|
||
2 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
|
||
2 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;
|
||
|
}
|
||
|
|
||
2 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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|