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.
173 lines
4.9 KiB
173 lines
4.9 KiB
4 years ago
|
<template>
|
||
|
<v-container fluid>
|
||
3 years ago
|
<v-row class="align-stretch">
|
||
2 years ago
|
<v-col 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 }">
|
||
3 years ago
|
<v-card
|
||
3 years ago
|
class="h-100"
|
||
3 years ago
|
:elevation="hover ? 4 : 1"
|
||
3 years ago
|
:ripple="!isLocked"
|
||
2 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
|
>
|
||
2 years ago
|
<v-carousel-item v-for="(cover, i) in getCovers(row)" :key="i">
|
||
|
<v-img height="200" :src="cover.url" :alt="cover.title" />
|
||
3 years ago
|
</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="">
|
||
2 years ago
|
<v-col v-for="col in fields" v-show="showFields[col.title]" :key="col.title" 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"
|
||
|
/>
|
||
2 years ago
|
<header-cell v-else :is-form="true" :value="col.title" :column="col" />
|
||
3 years ago
|
</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>
|
||
2 years ago
|
import { isVirtualCol } from 'nocodb-sdk';
|
||
|
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,
|
||
2 years ago
|
VirtualHeaderCell,
|
||
3 years ago
|
},
|
||
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',
|
||
2 years ago
|
'isLocked',
|
||
4 years ago
|
],
|
||
3 years ago
|
data() {
|
||
|
return {
|
||
2 years ago
|
galleryView: {},
|
||
|
};
|
||
3 years ago
|
},
|
||
4 years ago
|
computed: {
|
||
3 years ago
|
attachmentColumn() {
|
||
2 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) {
|
||
2 years ago
|
return this.availableColumns;
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
const hideCols = ['created_at', 'updated_at'];
|
||
3 years ago
|
|
||
|
if (this.showSystemFields) {
|
||
2 years ago
|
return this.meta.columns || [];
|
||
3 years ago
|
} else {
|
||
2 years ago
|
return (
|
||
|
this.meta.columns.filter(
|
||
|
c =>
|
||
|
!(c.pk && c.ai) &&
|
||
|
!hideCols.includes(c.title) &&
|
||
|
!(this.meta.v || []).some(v => v.bt && v.bt.title === c.title)
|
||
|
) || []
|
||
|
);
|
||
3 years ago
|
}
|
||
2 years ago
|
},
|
||
4 years ago
|
},
|
||
3 years ago
|
watch: {
|
||
|
async coverImageField(v) {
|
||
|
if (this.galleryView && v !== this.galleryView.fk_cover_image_col_id) {
|
||
2 years ago
|
await this.$api.dbView.galleryUpdate(this.viewId, {
|
||
3 years ago
|
...this.galleryView,
|
||
2 years ago
|
fk_cover_image_col_id: v,
|
||
|
});
|
||
3 years ago
|
}
|
||
2 years ago
|
},
|
||
3 years ago
|
},
|
||
|
created() {
|
||
2 years ago
|
this.loadView();
|
||
3 years ago
|
},
|
||
4 years ago
|
methods: {
|
||
3 years ago
|
isVirtualCol,
|
||
|
async loadView() {
|
||
2 years ago
|
this.galleryView = await this.$api.dbView.galleryRead(this.viewId);
|
||
|
this.$emit('update:coverImageField', this.galleryView.fk_cover_image_col_id);
|
||
3 years ago
|
},
|
||
3 years ago
|
getCovers(row) {
|
||
2 years ago
|
if (
|
||
|
this.attachmentColumn &&
|
||
|
row[this.attachmentColumn.title] &&
|
||
|
row[this.attachmentColumn.title][0] &&
|
||
|
row[this.attachmentColumn.title]
|
||
|
) {
|
||
4 years ago
|
try {
|
||
2 years ago
|
return JSON.parse(row[this.attachmentColumn.title]);
|
||
|
} catch (e) {}
|
||
4 years ago
|
}
|
||
2 years ago
|
return [{ url: 'https://via.placeholder.com/700?text=No%20image%20found' }];
|
||
|
},
|
||
|
},
|
||
|
};
|
||
4 years ago
|
</script>
|
||
|
|
||
2 years ago
|
<style scoped></style>
|