mirror of
https://github.com/baserow/baserow.git
synced 2026-12-05 08:48:35 +00:00
63 lines
1.3 KiB
Vue
63 lines
1.3 KiB
Vue
<template>
|
|
<div>
|
|
<a
|
|
ref="contextLink"
|
|
class="header__filter-link"
|
|
:class="{
|
|
'active--warning': view.sortings.length > 0,
|
|
}"
|
|
@click="$refs.context.toggle($refs.contextLink, 'bottom', 'left', 4)"
|
|
>
|
|
<i class="header__filter-icon fas fa-sort"></i>
|
|
<span class="header__filter-name">{{ sortTitle }}</span>
|
|
</a>
|
|
<ViewSortContext
|
|
ref="context"
|
|
:view="view"
|
|
:fields="fields"
|
|
:primary="primary"
|
|
:read-only="readOnly"
|
|
@changed="$emit('changed')"
|
|
></ViewSortContext>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import ViewSortContext from './ViewSortContext'
|
|
|
|
export default {
|
|
name: 'ViewSort',
|
|
components: { ViewSortContext },
|
|
props: {
|
|
primary: {
|
|
type: Object,
|
|
required: true,
|
|
},
|
|
fields: {
|
|
type: Array,
|
|
required: true,
|
|
},
|
|
view: {
|
|
type: Object,
|
|
required: true,
|
|
},
|
|
readOnly: {
|
|
type: Boolean,
|
|
required: true,
|
|
},
|
|
},
|
|
computed: {
|
|
sortTitle() {
|
|
const numberOfSortings = this.view.sortings.length
|
|
if (numberOfSortings === 0) {
|
|
return 'Sort'
|
|
} else if (numberOfSortings === 1) {
|
|
return `${numberOfSortings} Sort`
|
|
} else {
|
|
return `${numberOfSortings} Sorts`
|
|
}
|
|
},
|
|
},
|
|
}
|
|
</script>
|