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.
438 lines
11 KiB
438 lines
11 KiB
4 years ago
|
<template>
|
||
2 years ago
|
<v-container fluid class="h-100 d-100" style="overflow: auto">
|
||
3 years ago
|
<kanban-board
|
||
|
:stages="kanban.groupingColumnItems"
|
||
|
:blocks="kanban.blocks"
|
||
|
class="h-100 my-0 mx-n2"
|
||
|
@update-block="updateBlock"
|
||
|
>
|
||
|
<div v-for="stage in kanban.groupingColumnItems" :slot="stage" :key="stage" class="mx-auto">
|
||
3 years ago
|
<enum-cell :value="stage" :column="groupingFieldColumn" />
|
||
4 years ago
|
</div>
|
||
2 years ago
|
<div v-for="block in kanban.blocks" :slot="block.id" :key="block.c_pk" class="caption">
|
||
|
<v-hover v-slot="{ hover }">
|
||
|
<v-card class="h-100" :elevation="hover ? 4 : 1" @click="$emit('expandKanbanForm', { rowIdx: block.c_pk })">
|
||
3 years ago
|
<v-card-text>
|
||
|
<v-container>
|
||
|
<v-row class="">
|
||
|
<v-col
|
||
2 years ago
|
v-for="col in fields"
|
||
3 years ago
|
v-show="showFields[col.title]"
|
||
|
:key="col.title"
|
||
3 years ago
|
class="kanban-col col-12"
|
||
|
>
|
||
3 years ago
|
<label :for="`data-table-form-${col.title}`" class="body-2 text-capitalize caption grey--text">
|
||
3 years ago
|
<virtual-header-cell
|
||
3 years ago
|
v-if="col.virtual"
|
||
|
:column="col"
|
||
|
:nodes="nodes"
|
||
3 years ago
|
:is-form="true"
|
||
3 years ago
|
:meta="meta"
|
||
|
/>
|
||
2 years ago
|
<header-cell v-else :is-form="true" :value="col.title" :column="col" />
|
||
3 years ago
|
</label>
|
||
|
<virtual-cell
|
||
|
v-if="col.virtual"
|
||
|
ref="virtual"
|
||
|
:column="col"
|
||
|
:row="block"
|
||
|
:nodes="nodes"
|
||
|
:meta="meta"
|
||
|
/>
|
||
|
<table-cell
|
||
|
v-else
|
||
3 years ago
|
:value="block[col.title]"
|
||
3 years ago
|
:column="col"
|
||
|
:sql-ui="sqlUi"
|
||
|
class="xc-input body-2"
|
||
|
:meta="meta"
|
||
|
/>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
</v-container>
|
||
|
</v-card-text>
|
||
|
</v-card>
|
||
|
</v-hover>
|
||
3 years ago
|
</div>
|
||
|
<div v-for="stage in kanban.groupingColumnItems" :key="stage" :slot="`footer-${stage}`" class="kanban-footer">
|
||
3 years ago
|
<x-btn
|
||
3 years ago
|
v-if="stage"
|
||
|
outlined
|
||
|
tooltip="Add a new record"
|
||
|
color="primary"
|
||
|
class="primary"
|
||
3 years ago
|
x-small
|
||
|
fab
|
||
2 years ago
|
@click="insertNewRow(true, true, { [groupingField]: stage })"
|
||
3 years ago
|
>
|
||
2 years ago
|
<v-icon small> mdi-plus </v-icon>
|
||
3 years ago
|
</x-btn>
|
||
|
<!-- <x-btn
|
||
|
v-else
|
||
|
outlined
|
||
|
tooltip="New Stack"
|
||
|
color="primary"
|
||
|
class="primary"
|
||
|
small
|
||
|
@click="insertNewRow(true, true, {[groupingField]: stage})"
|
||
|
>
|
||
|
<v-icon small left>
|
||
|
mdi-plus
|
||
|
</v-icon>
|
||
|
New Stack
|
||
|
</x-btn> -->
|
||
3 years ago
|
<div class="record-cnt caption grey--text">
|
||
|
{{ kanban.recordCnt[stage] }} / {{ kanban.recordTotalCnt[stage] }}
|
||
2 years ago
|
{{ kanban.recordTotalCnt[stage] > 1 ? 'records' : 'record' }}
|
||
4 years ago
|
</div>
|
||
|
</div>
|
||
|
</kanban-board>
|
||
|
</v-container>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
2 years ago
|
import VirtualHeaderCell from '../components/VirtualHeaderCell';
|
||
|
import HeaderCell from '../components/HeaderCell';
|
||
|
import VirtualCell from '../components/VirtualCell';
|
||
|
import TableCell from '../components/Cell';
|
||
|
import EnumCell from '../components/cell/EnumCell';
|
||
4 years ago
|
export default {
|
||
3 years ago
|
name: 'KanbanView',
|
||
3 years ago
|
components: { TableCell, VirtualCell, HeaderCell, VirtualHeaderCell, EnumCell },
|
||
|
props: [
|
||
|
'nodes',
|
||
|
'table',
|
||
|
'showFields',
|
||
|
'availableColumns',
|
||
|
'meta',
|
||
|
'kanban',
|
||
|
'primaryValueColumn',
|
||
|
'showSystemFields',
|
||
|
'sqlUi',
|
||
|
'groupingField',
|
||
2 years ago
|
'api',
|
||
3 years ago
|
],
|
||
|
computed: {
|
||
|
fields() {
|
||
|
if (this.availableColumns) {
|
||
2 years ago
|
return this.availableColumns;
|
||
3 years ago
|
}
|
||
|
if (this.showSystemFields) {
|
||
2 years ago
|
return this.meta.columns || [];
|
||
3 years ago
|
}
|
||
2 years ago
|
const hideCols = ['created_at', 'updated_at'];
|
||
|
return (
|
||
|
this.meta.columns.filter(
|
||
|
c =>
|
||
|
!(c.pk && c.ai) &&
|
||
|
!hideCols.includes(c.column_name) &&
|
||
|
!(this.meta.v || []).some(v => v.bt && v.bt.column_name === c.column_name)
|
||
|
) || []
|
||
|
);
|
||
3 years ago
|
},
|
||
|
groupingFieldColumn() {
|
||
2 years ago
|
return this.fields.filter(f => f.title === this.groupingField)[0];
|
||
|
},
|
||
3 years ago
|
},
|
||
|
mounted() {
|
||
2 years ago
|
const kbListElements = document.querySelectorAll('.drag-inner-list');
|
||
|
kbListElements.forEach(kbListEle => {
|
||
|
kbListEle.addEventListener('scroll', async e => {
|
||
3 years ago
|
if (kbListEle.scrollTop + kbListEle.clientHeight >= kbListEle.scrollHeight) {
|
||
2 years ago
|
const groupingFieldVal = kbListEle.getAttribute('data-status');
|
||
|
this.$emit('loadMoreKanbanData', groupingFieldVal);
|
||
3 years ago
|
}
|
||
2 years ago
|
});
|
||
|
});
|
||
3 years ago
|
},
|
||
|
methods: {
|
||
|
async updateBlock(c_pk, status) {
|
||
|
try {
|
||
|
if (!this.api) {
|
||
2 years ago
|
this.$toast
|
||
|
.error('API not found', {
|
||
|
position: 'bottom-center',
|
||
|
})
|
||
|
.goAway(3000);
|
||
|
return;
|
||
3 years ago
|
}
|
||
|
|
||
|
// update kanban block
|
||
2 years ago
|
const targetBlock = this.kanban.blocks.find(b => b.c_pk === c_pk);
|
||
3 years ago
|
if (!targetBlock) {
|
||
2 years ago
|
this.$toast
|
||
|
.error(`Block with ID ${c_pk} not found`, {
|
||
|
position: 'bottom-center',
|
||
|
})
|
||
|
.goAway(3000);
|
||
|
return;
|
||
3 years ago
|
}
|
||
|
|
||
|
if (targetBlock.status === status) {
|
||
|
// no change
|
||
2 years ago
|
return;
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
const uncategorized = 'Uncategorized';
|
||
|
const prevStatus = targetBlock.status;
|
||
|
await this.api.update(
|
||
|
c_pk,
|
||
3 years ago
|
{ [this.groupingField]: status === uncategorized ? null : status }, // new data
|
||
2 years ago
|
{ [this.groupingField]: prevStatus }
|
||
|
); // old data
|
||
3 years ago
|
|
||
2 years ago
|
this.$set(targetBlock, 'status', status);
|
||
|
this.$set(targetBlock, this.groupingField, status === uncategorized ? null : status);
|
||
4 years ago
|
|
||
3 years ago
|
// update kanban data
|
||
2 years ago
|
const kanbanRow = this.kanban.data.find(d => d.row.c_pk === c_pk);
|
||
3 years ago
|
if (kanbanRow) {
|
||
2 years ago
|
this.$set(kanbanRow.row, this.groupingField, status === uncategorized ? null : status);
|
||
3 years ago
|
}
|
||
2 years ago
|
this.$set(this.kanban.recordCnt, prevStatus, this.kanban.recordCnt[prevStatus] - 1);
|
||
|
this.$set(this.kanban.recordCnt, status, this.kanban.recordCnt[status] + 1);
|
||
|
this.$set(this.kanban.recordTotalCnt, prevStatus, this.kanban.recordTotalCnt[prevStatus] - 1);
|
||
|
this.$set(this.kanban.recordTotalCnt, status, this.kanban.recordTotalCnt[status] + 1);
|
||
|
this.$forceUpdate();
|
||
|
this.$toast
|
||
|
.success(`Moved block from ${prevStatus} to ${status ?? uncategorized} successfully.`, {
|
||
|
position: 'bottom-center',
|
||
|
})
|
||
|
.goAway(3000);
|
||
3 years ago
|
} catch (e) {
|
||
|
if (e.response && e.response.data && e.response.data.msg) {
|
||
2 years ago
|
this.$toast
|
||
|
.error(e.response.data.msg, {
|
||
|
position: 'bottom-center',
|
||
|
})
|
||
|
.goAway(3000);
|
||
3 years ago
|
} else {
|
||
2 years ago
|
this.$toast
|
||
|
.error(`Failed to update block : ${e.message}`, {
|
||
|
position: 'bottom-center',
|
||
|
})
|
||
|
.goAway(3000);
|
||
3 years ago
|
}
|
||
|
}
|
||
|
},
|
||
|
insertNewRow(atEnd = false, expand = false, presetValues = {}) {
|
||
2 years ago
|
this.$emit('insertNewRow', atEnd, expand, presetValues);
|
||
|
},
|
||
|
},
|
||
|
};
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped lang="scss">
|
||
|
::v-deep {
|
||
3 years ago
|
.v-card {
|
||
|
border: 1px solid rgba(0, 0, 0, 0.2);
|
||
|
}
|
||
|
|
||
|
ul.drag-inner-list {
|
||
|
overflow-y: scroll;
|
||
|
}
|
||
4 years ago
|
|
||
2 years ago
|
ul.drag-list,
|
||
|
ul.drag-inner-list {
|
||
4 years ago
|
list-style-type: none;
|
||
|
margin: 0;
|
||
|
padding: 0;
|
||
|
}
|
||
|
|
||
|
.drag-container {
|
||
3 years ago
|
//max-width: 1000px;
|
||
3 years ago
|
margin: 20px 0px;
|
||
4 years ago
|
}
|
||
|
|
||
|
.drag-list {
|
||
|
display: flex;
|
||
|
align-items: flex-start;
|
||
|
}
|
||
|
|
||
|
@media (max-width: 690px) {
|
||
|
.drag-list {
|
||
|
display: block;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
.drag-column {
|
||
|
flex: 1;
|
||
|
margin: 0 10px;
|
||
|
position: relative;
|
||
|
background: var(--v-backgroundColor-base); //rgba(256, 256, 256, 0.2);
|
||
3 years ago
|
border-radius: 6px;
|
||
|
max-width: 240px;
|
||
|
}
|
||
|
|
||
|
.drag-column-footer {
|
||
|
padding: 20px 10px 10px 10px;
|
||
|
text-align: center;
|
||
|
}
|
||
|
|
||
2 years ago
|
/* .drag-column-footer .v-btn {
|
||
3 years ago
|
border-radius: 50%;
|
||
|
border: 2px solid;
|
||
|
padding: 0px 0px 0px 6px;
|
||
|
min-width: 40px;
|
||
|
min-height: 38px;
|
||
3 years ago
|
}*/
|
||
3 years ago
|
|
||
|
.drag-column-footer .record-cnt {
|
||
|
height: 38px;
|
||
|
line-height: 38px;
|
||
|
font-size: 15px;
|
||
|
}
|
||
|
|
||
|
.drag-column-footer .v-btn .mdi-plug::before {
|
||
|
font-weight: bold;
|
||
4 years ago
|
}
|
||
|
|
||
|
@media (max-width: 690px) {
|
||
|
.drag-column {
|
||
|
margin-bottom: 30px;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
.drag-column h2 {
|
||
|
font-size: 0.8rem;
|
||
|
margin: 0;
|
||
|
text-transform: uppercase;
|
||
|
font-weight: 600;
|
||
|
}
|
||
|
|
||
|
.drag-column-header {
|
||
|
display: flex;
|
||
|
align-items: center;
|
||
|
justify-content: space-between;
|
||
3 years ago
|
width: 240px;
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
.drag-column-header .set-item {
|
||
|
margin-top: 20px !important;
|
||
4 years ago
|
}
|
||
|
|
||
|
.drag-item {
|
||
|
margin: 10px;
|
||
|
background: var(--v-backgroundColor-lighten2);
|
||
|
transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
|
||
|
border-radius: 4px;
|
||
|
}
|
||
|
|
||
3 years ago
|
.drag-item .container {
|
||
|
padding: 0px;
|
||
|
}
|
||
|
|
||
4 years ago
|
.drag-item.is-moving {
|
||
|
transform: scale(1.1);
|
||
|
background: var(--v-backgroundColor-darken1);
|
||
|
}
|
||
|
|
||
|
.drag-header-more {
|
||
|
cursor: pointer;
|
||
|
}
|
||
|
|
||
|
.drag-options {
|
||
|
left: 0;
|
||
|
width: 100%;
|
||
|
height: 100%;
|
||
|
transform: translateX(100%);
|
||
|
opacity: 0;
|
||
|
transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
|
||
|
}
|
||
|
|
||
|
.drag-options.active {
|
||
|
transform: translateX(0);
|
||
|
opacity: 1;
|
||
|
}
|
||
|
|
||
|
.drag-options-label {
|
||
|
display: block;
|
||
|
margin: 0 0 5px 0;
|
||
|
}
|
||
|
|
||
|
.drag-options-label input {
|
||
|
opacity: 0.6;
|
||
|
}
|
||
|
|
||
|
.drag-options-label span {
|
||
|
display: inline-block;
|
||
|
font-size: 0.9rem;
|
||
|
font-weight: 400;
|
||
|
margin-left: 5px;
|
||
|
}
|
||
|
|
||
|
/* Dragula CSS */
|
||
|
.gu-mirror {
|
||
|
position: fixed !important;
|
||
|
margin: 0 !important;
|
||
|
z-index: 9999 !important;
|
||
|
opacity: 0.8;
|
||
|
list-style-type: none;
|
||
|
}
|
||
|
|
||
|
.gu-hide {
|
||
|
display: none !important;
|
||
|
}
|
||
|
|
||
|
.gu-unselectable {
|
||
|
-webkit-user-select: none !important;
|
||
|
-moz-user-select: none !important;
|
||
|
-ms-user-select: none !important;
|
||
|
user-select: none !important;
|
||
|
}
|
||
|
|
||
|
.gu-transit {
|
||
|
opacity: 0.2;
|
||
|
}
|
||
|
|
||
3 years ago
|
.kanban-col {
|
||
3 years ago
|
padding: 10px;
|
||
|
}
|
||
3 years ago
|
|
||
|
.drag-container {
|
||
|
display: inline-block;
|
||
|
.drag-list {
|
||
|
height: 100%;
|
||
|
display: inline-flex;
|
||
|
|
||
|
.drag-column {
|
||
|
display: flex;
|
||
|
flex-direction: column;
|
||
2 years ago
|
max-height: max(400px, 100%);
|
||
3 years ago
|
|
||
|
.drag-inner-list {
|
||
|
overflow-y: auto;
|
||
|
overflow-x: hidden;
|
||
|
min-height: 200px;
|
||
2 years ago
|
flex-grow: 1;
|
||
3 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
4 years ago
|
}
|
||
|
</style>
|
||
3 years ago
|
|
||
|
<!--
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Wing-Kam Wong <wingkwong.code@gmail.com>
|
||
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|