added prettier

This commit is contained in:
Čarodej
2022-02-01 12:21:38 +01:00
parent 5ae875233b
commit b38b532cbe
284 changed files with 25410 additions and 25338 deletions

View File

@@ -1,58 +1,54 @@
<template>
<template>
<tr class="table-row">
<td
class="table-cell"
v-for="(collumn, index) in normalizedColumns"
:key="index"
>
<td class="table-cell" v-for="(collumn, index) in normalizedColumns" :key="index">
<span>{{ collumn }}</span>
</td>
</tr>
</template>
<script>
export default {
props: ['data'],
computed: {
normalizedColumns() {
// Remove ID from object
if (this.data['id']) delete this.data['id']
export default {
props: ['data'],
computed: {
normalizedColumns() {
// Remove ID from object
if (this.data['id']) delete this.data['id']
// Return object
return Object.values(this.data)
}
}
}
// Return object
return Object.values(this.data)
},
},
}
</script>
<style lang="scss" scoped>
@import '../../../../sass/vuefilemanager/variables';
@import '../../../../sass/vuefilemanager/mixins';
@import '../../../../sass/vuefilemanager/variables';
@import '../../../../sass/vuefilemanager/mixins';
.table-row {
border-radius: 8px;
.table-row {
border-radius: 8px;
&:hover {
background: $light_background;
&:hover {
background: $light_background;
}
.table-cell {
padding-top: 15px;
padding-bottom: 15px;
&:first-child {
padding-left: 15px;
}
.table-cell {
padding-top: 15px;
padding-bottom: 15px;
&:last-child {
padding-right: 15px;
text-align: right;
}
&:first-child {
padding-left: 15px;
}
&:last-child {
padding-right: 15px;
text-align: right;
}
span {
@include font-size(16);
font-weight: bold;
}
span {
@include font-size(16);
font-weight: bold;
}
}
}
</style>

View File

@@ -1,85 +1,70 @@
<template>
<div class="flex items-center shrink-0 grow-0">
<MemberAvatar
class="mr-3 shrink-0"
:is-border="false"
:size="52"
:member="member"
/>
<div class="info">
<b class="name" v-if="title">{{ title }}</b>
<span class="description" v-if="description">{{ description }}</span>
</div>
</div>
<template>
<div class="flex shrink-0 grow-0 items-center">
<MemberAvatar class="mr-3 shrink-0" :is-border="false" :size="52" :member="member" />
<div class="info">
<b class="name" v-if="title">{{ title }}</b>
<span class="description" v-if="description">{{ description }}</span>
</div>
</div>
</template>
<script>
import MemberAvatar from "../../FilesView/MemberAvatar";
import MemberAvatar from '../../FilesView/MemberAvatar'
export default {
name:'DatatableCellImage',
props: [
'member',
'title',
'description',
'image-size'
],
components: {
MemberAvatar,
}
}
export default {
name: 'DatatableCellImage',
props: ['member', 'title', 'description', 'image-size'],
components: {
MemberAvatar,
},
}
</script>
<style lang="scss" scoped>
@import '../../../../sass/vuefilemanager/variables';
@import '../../../../sass/vuefilemanager/mixins';
@import '../../../../sass/vuefilemanager/variables';
@import '../../../../sass/vuefilemanager/mixins';
.info {
.info {
.name,
.description {
max-width: 150px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: block;
}
.name, .description {
max-width: 150px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: block;
}
.name {
@include font-size(15);
line-height: 1;
color: $text;
}
.name {
@include font-size(15);
line-height: 1;
color: $text;
}
.description {
color: $text-muted;
@include font-size(12);
}
}
.description {
color: $text-muted;
@include font-size(12);
}
}
.dark {
.cell-image-thumbnail {
.image {
img {
&.blurred {
display: none;
}
}
}
.info {
.name {
color: $dark_mode_text_primary;
}
.description {
color: $dark_mode_text_secondary;
.dark {
.cell-image-thumbnail {
.image {
img {
&.blurred {
display: none;
}
}
}
.info {
.name {
color: $dark_mode_text_primary;
}
.description {
color: $dark_mode_text_secondary;
}
}
}
}
</style>

View File

@@ -2,240 +2,271 @@
<div class="w-full">
<table v-if="hasData" class="w-full">
<thead>
<tr class="whitespace-nowrap">
<th
class="text-left"
v-for="(column, index) in columns"
@click="sort(column.field, column.sortable)"
:key="index"
:class="{ 'sortable cursor-pointer': column.sortable, 'text-right': (Object.values(columns).length - 1) === index }"
v-if="! column.hidden"
>
<span class="dark:text-gray-500 text-gray-400 text-xs">
{{ column.label }}
</span>
<tr class="whitespace-nowrap">
<th
class="text-left"
v-for="(column, index) in columns"
@click="sort(column.field, column.sortable)"
:key="index"
:class="{
'sortable cursor-pointer': column.sortable,
'text-right': Object.values(columns).length - 1 === index,
}"
v-if="!column.hidden"
>
<span class="text-xs text-gray-400 dark:text-gray-500">
{{ column.label }}
</span>
<chevron-up-icon
v-if="column.sortable"
:class="{ 'arrow-down': filter.sort === 'ASC' }"
class="inline-block vue-feather dark:text-gray-500 text-gray-300"
size="12"
/>
</th>
</tr>
<chevron-up-icon
v-if="column.sortable"
:class="{ 'arrow-down': filter.sort === 'ASC' }"
class="vue-feather inline-block text-gray-300 dark:text-gray-500"
size="12"
/>
</th>
</tr>
</thead>
<tbody class="table-body">
<slot v-for="row in data.data" :row="row">
<DatatableCell :data="row" :key="row.id" />
</slot>
<slot v-for="row in data.data" :row="row">
<DatatableCell :data="row" :key="row.id" />
</slot>
</tbody>
</table>
<!--Empty data slot-->
<slot v-if="! isLoading && ! hasData" name="empty-page"></slot>
<!--Paginator-->
<div v-if="paginator && hasData" class="mt-6 flex justify-between items-center">
<!--Empty data slot-->
<slot v-if="!isLoading && !hasData" name="empty-page"></slot>
<!--Paginator-->
<div v-if="paginator && hasData" class="mt-6 flex items-center justify-between">
<!--Show if there is only 6 pages-->
<ul v-if="data.meta.total > 15 && data.meta.last_page <= 6" class="pagination flex items-center">
<!--Go previous icon-->
<li class="p-1 inline-block previous">
<a @click="goToPage(pageIndex - 1)" class="page-link" :class="{ 'opacity-20 cursor-default': pageIndex === 1 }">
<li class="previous inline-block p-1">
<a
@click="goToPage(pageIndex - 1)"
class="page-link"
:class="{
'cursor-default opacity-20': pageIndex === 1,
}"
>
<chevron-left-icon size="14" class="inline-block" />
</a>
</li>
<li v-for="(page, index) in data.meta.last_page" :key="index" class="p-1 inline-block" @click="goToPage(page)">
<a class="page-link" :class="{'dark:text-gray-300 dark:bg-4x-dark-foreground bg-light-background': pageIndex === page }">
<li v-for="(page, index) in data.meta.last_page" :key="index" class="inline-block p-1" @click="goToPage(page)">
<a
class="page-link"
:class="{
'bg-light-background dark:bg-4x-dark-foreground dark:text-gray-300': pageIndex === page,
}"
>
{{ page }}
</a>
</li>
<!--Go next icon-->
<li class="p-1 inline-block next">
<a @click="goToPage(pageIndex + 1)" class="page-link" :class="{ 'opacity-20 cursor-default': pageIndex === data.meta.last_page }">
<!--Go next icon-->
<li class="next inline-block p-1">
<a
@click="goToPage(pageIndex + 1)"
class="page-link"
:class="{
'cursor-default opacity-20': pageIndex === data.meta.last_page,
}"
>
<chevron-right-icon size="14" class="inline-block" />
</a>
</li>
</ul>
<!--Show if there is more than 6 pages-->
<!--Show if there is more than 6 pages-->
<ul v-if="data.meta.total > 15 && data.meta.last_page > 6" class="pagination flex items-center">
<!--Go previous icon-->
<li class="p-1 inline-block previous">
<a @click="goToPage(pageIndex - 1)" class="page-link" :class="{'opacity-20 cursor-default': pageIndex === 1 }">
<li class="previous inline-block p-1">
<a
@click="goToPage(pageIndex - 1)"
class="page-link"
:class="{
'cursor-default opacity-20': pageIndex === 1,
}"
>
<chevron-left-icon size="14" class="inline-block" />
</a>
</li>
<!--Show first Page-->
<li class="p-1 inline-block" v-if="pageIndex >= 5" @click="goToPage(1)">
<a class="page-link">
1
</a>
<!--Show first Page-->
<li class="inline-block p-1" v-if="pageIndex >= 5" @click="goToPage(1)">
<a class="page-link"> 1 </a>
</li>
<li v-if="pageIndex < 5" v-for="(page, index) in 5" :key="index" class="p-1 inline-block" @click="goToPage(page)">
<a class="page-link" :class="{'dark:text-gray-300 dark:bg-4x-dark-foreground bg-light-background': pageIndex === page }">
<li v-if="pageIndex < 5" v-for="(page, index) in 5" :key="index" class="inline-block p-1" @click="goToPage(page)">
<a
class="page-link"
:class="{
'bg-light-background dark:bg-4x-dark-foreground dark:text-gray-300': pageIndex === page,
}"
>
{{ page }}
</a>
</li>
<li class="p-1 inline-block" v-if="pageIndex >= 5">
<li class="inline-block p-1" v-if="pageIndex >= 5">
<a class="page-link">...</a>
</li>
<!--Floated Pages-->
<li v-if="pageIndex >= 5 && pageIndex < (data.meta.last_page - 3)" v-for="(page, index) in floatPages" :key="index" class="p-1 inline-block" @click="goToPage(page)">
<a class="page-link" :class="{'dark:text-gray-300 dark:bg-4x-dark-foreground bg-light-background': pageIndex === page }">
<!--Floated Pages-->
<li v-if="pageIndex >= 5 && pageIndex < data.meta.last_page - 3" v-for="(page, index) in floatPages" :key="index" class="inline-block p-1" @click="goToPage(page)">
<a
class="page-link"
:class="{
'bg-light-background dark:bg-4x-dark-foreground dark:text-gray-300': pageIndex === page,
}"
>
{{ page }}
</a>
</li>
<li class="p-1 inline-block" v-if="pageIndex < (data.meta.last_page - 3)">
<li class="inline-block p-1" v-if="pageIndex < data.meta.last_page - 3">
<a class="page-link">...</a>
</li>
<li v-if="pageIndex > (data.meta.last_page - 4)" v-for="(page, index) in 5" :key="index" class="p-1 inline-block" @click="goToPage(data.meta.last_page - (4 - index))">
<a class="page-link" :class="{ 'dark:text-gray-300 dark:bg-4x-dark-foreground bg-light-background': pageIndex === (data.meta.last_page - (4 - index)) }">
<li
v-if="pageIndex > data.meta.last_page - 4"
v-for="(page, index) in 5"
:key="index"
class="inline-block p-1"
@click="goToPage(data.meta.last_page - (4 - index))"
>
<a
class="page-link"
:class="{
'bg-light-background dark:bg-4x-dark-foreground dark:text-gray-300': pageIndex === data.meta.last_page - (4 - index),
}"
>
{{ data.meta.last_page - (4 - index) }}
</a>
</li>
<!--Show last page-->
<li class="p-1 inline-block" v-if="pageIndex < (data.meta.last_page - 3)" @click="goToPage(data.meta.last_page)">
<!--Show last page-->
<li class="inline-block p-1" v-if="pageIndex < data.meta.last_page - 3" @click="goToPage(data.meta.last_page)">
<a class="page-link">
{{ data.meta.last_page }}
</a>
</li>
<!--Go next icon-->
<li class="p-1 inline-block next">
<a @click="goToPage(pageIndex + 1)" class="page-link" :class="{ 'opacity-20 cursor-default': pageIndex === data.meta.last_page }">
<!--Go next icon-->
<li class="next inline-block p-1">
<a
@click="goToPage(pageIndex + 1)"
class="page-link"
:class="{
'cursor-default opacity-20': pageIndex === data.meta.last_page,
}"
>
<chevron-right-icon size="14" class="inline-block" />
</a>
</li>
</ul>
<span class="dark:text-gray-500 text-xs text-gray-600">
Showing {{ data.meta.from }} - {{ data.meta.to }} from {{ data.meta.total }} records
</span>
<span class="text-xs text-gray-600 dark:text-gray-500"> Showing {{ data.meta.from }} - {{ data.meta.to }} from {{ data.meta.total }} records </span>
</div>
</div>
</template>
<script>
import {ChevronUpIcon, ChevronLeftIcon, ChevronRightIcon} from 'vue-feather-icons'
import DatatableCell from "./DatatableCell";
import axios from "axios";
import { ChevronUpIcon, ChevronLeftIcon, ChevronRightIcon } from 'vue-feather-icons'
import DatatableCell from './DatatableCell'
import axios from 'axios'
export default {
name: 'DatatableWrapper',
props: [
'paginator',
'tableData',
'columns',
'scope',
'api',
],
components: {
ChevronRightIcon,
ChevronLeftIcon,
DatatableCell,
ChevronUpIcon,
},
computed: {
hasData() {
return this.data && this.data.data && this.data.data.length > 0
},
floatPages() {
return [(this.pageIndex - 1), this.pageIndex, (this.pageIndex + 1)];
}
},
data() {
return {
data: undefined,
isLoading: true,
pageIndex: 1,
filter: {
sort: 'DESC',
field: undefined,
}
}
},
methods: {
goToPage(index) {
if (index > this.data.meta.last_page || index === 0) return
name: 'DatatableWrapper',
props: ['paginator', 'tableData', 'columns', 'scope', 'api'],
components: {
ChevronRightIcon,
ChevronLeftIcon,
DatatableCell,
ChevronUpIcon,
},
computed: {
hasData() {
return this.data && this.data.data && this.data.data.length > 0
},
floatPages() {
return [this.pageIndex - 1, this.pageIndex, this.pageIndex + 1]
},
},
data() {
return {
data: undefined,
isLoading: true,
pageIndex: 1,
filter: {
sort: 'DESC',
field: undefined,
},
}
},
methods: {
goToPage(index) {
if (index > this.data.meta.last_page || index === 0) return
this.pageIndex = index
this.pageIndex = index
this.getPage(index)
},
sort(field, sortable) {
this.getPage(index)
},
sort(field, sortable) {
// Prevent sortable if is disabled
if (!sortable) return
// Prevent sortable if is disabled
if (!sortable) return
// Set filter
this.filter.field = field
// Set filter
this.filter.field = field
// Set sorting direction
if (this.filter.sort === 'DESC') {
this.filter.sort = 'ASC'
} else if (this.filter.sort === 'ASC') {
this.filter.sort = 'DESC'
}
// Set sorting direction
if (this.filter.sort === 'DESC') {
this.filter.sort = 'ASC'
} else if (this.filter.sort === 'ASC') {
this.filter.sort = 'DESC'
}
this.getPage(this.pageIndex)
},
getPage(page) {
// Get api URI
this.URI = this.api
this.getPage(this.pageIndex)
},
getPage(page) {
// Set page index
if (this.paginator) this.URI = this.URI + '?page=' + page
// Get api URI
this.URI = this.api;
// Add filder URI if is defined sorting
if (this.filter.field) this.URI = this.URI + (this.paginator ? '&' : '?') + 'sort=' + this.filter.field + '&direction=' + this.filter.sort
// Set page index
if (this.paginator)
this.URI = this.URI + '?page=' + page
this.isLoading = true
// Add filder URI if is defined sorting
if (this.filter.field)
// Get data
axios
.get(this.URI)
.then((response) => {
this.data = response.data
this.$emit('data', response.data)
})
.catch(() => this.$isSomethingWrong())
.finally(() => {
this.$emit('init', true)
this.isLoading = false
})
},
},
created() {
if (this.api) this.getPage(this.pageIndex)
this.URI = this.URI + (this.paginator ? '&' : '?') + 'sort=' + this.filter.field + '&direction=' + this.filter.sort
this.isLoading = true
// Get data
axios.get(this.URI)
.then(response => {
this.data = response.data
this.$emit('data', response.data)
})
.catch(() => this.$isSomethingWrong())
.finally(() => {
this.$emit('init', true)
this.isLoading = false
}
)
},
},
created() {
if (this.api)
this.getPage(this.pageIndex)
if (this.tableData)
this.data = this.tableData,
this.isLoading = false
}
if (this.tableData) (this.data = this.tableData), (this.isLoading = false)
},
}
</script>
<style lang="scss" scoped>
.page-link {
@apply w-8 h-8 flex justify-center items-center block rounded-lg font-bold text-sm cursor-pointer hover:bg-light-background transition duration-200;
}
</style>
.page-link {
@apply block flex h-8 w-8 cursor-pointer items-center justify-center rounded-lg text-sm font-bold transition duration-200 hover:bg-light-background;
}
</style>