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.
186 lines
5.2 KiB
186 lines
5.2 KiB
4 years ago
|
<template>
|
||
|
<v-container fluid>
|
||
3 years ago
|
<v-row class="align-stretch">
|
||
4 years ago
|
<v-col
|
||
3 years ago
|
v-for="({row, rowMeta},rowIndex) in data"
|
||
|
:key="rowIndex"
|
||
|
class="col-md-4 col-lg-3 col-sm-6 col-12"
|
||
|
>
|
||
|
<v-hover v-slot="{hover}">
|
||
|
<v-card
|
||
3 years ago
|
class="h-100"
|
||
3 years ago
|
:elevation="hover ? 4 : 1"
|
||
3 years ago
|
:ripple="!isLocked"
|
||
3 years ago
|
@click="!isLocked && $emit('expandForm', {row,rowIndex,rowMeta})"
|
||
4 years ago
|
>
|
||
3 years ago
|
<v-carousel
|
||
3 years ago
|
v-if="attachmentColumn"
|
||
3 years ago
|
:continuous="false"
|
||
|
:cycle="true"
|
||
|
:show-arrows="false"
|
||
|
hide-delimiter-background
|
||
|
delimiter-icon="mdi-minus"
|
||
|
height="200"
|
||
4 years ago
|
>
|
||
3 years ago
|
<v-carousel-item
|
||
|
v-for="(cover, i) in getCovers(row)"
|
||
|
:key="i"
|
||
|
>
|
||
|
<v-img
|
||
|
height="200"
|
||
|
:src="cover.url"
|
||
|
:alt="cover.title"
|
||
|
/>
|
||
|
</v-carousel-item>
|
||
|
</v-carousel>
|
||
4 years ago
|
|
||
3 years ago
|
<!-- <v-card-title-->
|
||
|
<!-- class="text-capitalize"-->
|
||
|
<!-- v-text="row[primaryValueColumn]"-->
|
||
|
<!-- />-->
|
||
|
<v-card-text>
|
||
|
<v-container>
|
||
|
<v-row class="">
|
||
|
<v-col
|
||
|
v-for="(col) in fields"
|
||
3 years ago
|
v-show="showFields[ col.title]"
|
||
|
:key="col.title"
|
||
3 years ago
|
class="col-12 mt-1 mb-2 "
|
||
|
>
|
||
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="isVirtualCol(col)"
|
||
3 years ago
|
:column="col"
|
||
|
:nodes="nodes"
|
||
|
:is-form="true"
|
||
|
:meta="meta"
|
||
|
/>
|
||
|
<header-cell
|
||
|
v-else
|
||
|
:is-form="true"
|
||
3 years ago
|
:value="col.title"
|
||
3 years ago
|
:column="col"
|
||
|
/>
|
||
|
|
||
|
</label>
|
||
|
|
||
|
<virtual-cell
|
||
3 years ago
|
v-if="isVirtualCol(col)"
|
||
3 years ago
|
ref="virtual"
|
||
|
:column="col"
|
||
|
:row="row"
|
||
|
:nodes="nodes"
|
||
|
:meta="meta"
|
||
|
/>
|
||
|
<table-cell
|
||
|
v-else
|
||
3 years ago
|
:value="row[col.title]"
|
||
3 years ago
|
:column="col"
|
||
|
:sql-ui="sqlUi"
|
||
3 years ago
|
:is-locked="isLocked"
|
||
3 years ago
|
class="xc-input body-2"
|
||
|
:meta="meta"
|
||
|
/>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
</v-container>
|
||
|
</v-card-text>
|
||
3 years ago
|
</v-card>
|
||
4 years ago
|
</v-hover>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
</v-container>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
import { isVirtualCol } from 'nocodb-sdk'
|
||
3 years ago
|
import VirtualHeaderCell from '../components/VirtualHeaderCell'
|
||
|
import HeaderCell from '../components/HeaderCell'
|
||
|
import VirtualCell from '../components/VirtualCell'
|
||
|
import TableCell from '../components/Cell'
|
||
4 years ago
|
export default {
|
||
3 years ago
|
name: 'GalleryView',
|
||
3 years ago
|
components: {
|
||
|
TableCell,
|
||
|
VirtualCell,
|
||
|
HeaderCell,
|
||
|
VirtualHeaderCell
|
||
|
},
|
||
4 years ago
|
props: [
|
||
3 years ago
|
'nodes',
|
||
|
'table',
|
||
|
'showFields',
|
||
|
'availableColumns',
|
||
|
'meta',
|
||
|
'data',
|
||
3 years ago
|
'primaryValueColumn',
|
||
|
'showSystemFields',
|
||
|
'sqlUi',
|
||
3 years ago
|
'coverImageField',
|
||
3 years ago
|
'viewId',
|
||
3 years ago
|
'isLocked'
|
||
4 years ago
|
],
|
||
3 years ago
|
data() {
|
||
|
return {
|
||
|
galleryView: {}
|
||
|
}
|
||
|
},
|
||
4 years ago
|
computed: {
|
||
3 years ago
|
attachmentColumn() {
|
||
3 years ago
|
return this.coverImageField && this.meta && this.meta.columns && this.meta.columns.find(c => c.id === this.coverImageField)
|
||
3 years ago
|
},
|
||
|
fields() {
|
||
|
if (this.availableColumns) {
|
||
|
return this.availableColumns
|
||
|
}
|
||
|
|
||
|
const hideCols = ['created_at', 'updated_at']
|
||
|
|
||
|
if (this.showSystemFields) {
|
||
|
return this.meta.columns || []
|
||
|
} else {
|
||
3 years ago
|
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
|
) || []
|
||
|
}
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
watch: {
|
||
|
async coverImageField(v) {
|
||
|
if (this.galleryView && v !== this.galleryView.fk_cover_image_col_id) {
|
||
|
(await this.$api.dbView.galleryUpdate(this.viewId, {
|
||
|
...this.galleryView,
|
||
|
fk_cover_image_col_id: v
|
||
|
}))
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
created() {
|
||
|
this.loadView()
|
||
|
},
|
||
4 years ago
|
methods: {
|
||
3 years ago
|
isVirtualCol,
|
||
|
async loadView() {
|
||
|
this.galleryView = (await this.$api.dbView.galleryRead(this.viewId))
|
||
|
this.$emit('update:coverImageField', this.galleryView.fk_cover_image_col_id)
|
||
|
},
|
||
3 years ago
|
getCovers(row) {
|
||
3 years ago
|
if (this.attachmentColumn &&
|
||
3 years ago
|
row[this.attachmentColumn.column_name] && row[this.attachmentColumn.column_name][0] &&
|
||
|
row[this.attachmentColumn.column_name]) {
|
||
4 years ago
|
try {
|
||
3 years ago
|
return JSON.parse(row[this.attachmentColumn.column_name])
|
||
4 years ago
|
} catch (e) {
|
||
|
|
||
|
}
|
||
|
}
|
||
3 years ago
|
return [{ url: 'https://via.placeholder.com/700?text=No%20image%20found' }]
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
|
||
|
</style>
|