2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
2023-06-02 16:04:55 +00:00
|
|
|
<div :class="cx('root')" role="group" v-bind="ptm('root')">
|
|
|
|
<button :aria-label="listViewAriaLabel" :class="cx('listButton')" @click="changeLayout('list')" type="button" :aria-pressed="isListButtonPressed" v-bind="ptm('listButton')">
|
2023-04-07 06:47:10 +00:00
|
|
|
<slot name="listicon">
|
2023-05-09 22:39:10 +00:00
|
|
|
<BarsIcon v-bind="ptm('listIcon')" />
|
2023-04-07 06:47:10 +00:00
|
|
|
</slot>
|
2022-09-14 11:26:01 +00:00
|
|
|
</button>
|
2023-06-02 16:04:55 +00:00
|
|
|
<button :aria-label="gridViewAriaLabel" :class="cx('gridButton')" @click="changeLayout('grid')" type="button" :aria-pressed="isGridButtonPressed" v-bind="ptm('gridButton')">
|
2023-04-07 06:47:10 +00:00
|
|
|
<slot name="gridicon">
|
2023-05-09 22:39:10 +00:00
|
|
|
<ThLargeIcon v-bind="ptm('gridIcon')" />
|
2023-04-07 06:47:10 +00:00
|
|
|
</slot>
|
2022-09-14 11:26:01 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
2022-09-06 12:03:37 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-04-18 12:53:43 +00:00
|
|
|
import BarsIcon from 'primevue/icons/bars';
|
|
|
|
import ThLargeIcon from 'primevue/icons/thlarge';
|
2023-06-06 13:04:43 +00:00
|
|
|
import BaseDataViewLayoutOptions from './BaseDataViewLayoutOptions.vue';
|
2023-04-07 06:47:10 +00:00
|
|
|
|
2022-09-14 11:26:01 +00:00
|
|
|
export default {
|
|
|
|
name: 'DataViewLayoutOptions',
|
2023-06-02 16:04:55 +00:00
|
|
|
extends: BaseDataViewLayoutOptions,
|
2022-09-14 11:26:01 +00:00
|
|
|
emits: ['update:modelValue'],
|
2022-12-08 11:04:25 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isListButtonPressed: false,
|
|
|
|
isGridButtonPressed: false
|
|
|
|
};
|
|
|
|
},
|
2022-09-14 11:26:01 +00:00
|
|
|
methods: {
|
|
|
|
changeLayout(layout) {
|
|
|
|
this.$emit('update:modelValue', layout);
|
2022-12-08 11:04:25 +00:00
|
|
|
|
|
|
|
if (layout === 'list') {
|
|
|
|
this.isListButtonPressed = true;
|
|
|
|
this.isGridButtonPressed = false;
|
|
|
|
} else if (layout === 'grid') {
|
|
|
|
this.isGridButtonPressed = true;
|
|
|
|
this.isListButtonPressed = false;
|
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2022-12-08 11:04:25 +00:00
|
|
|
listViewAriaLabel() {
|
|
|
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.listView : undefined;
|
|
|
|
},
|
|
|
|
gridViewAriaLabel() {
|
|
|
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.gridView : undefined;
|
2022-09-14 11:26:01 +00:00
|
|
|
}
|
2023-04-07 06:47:10 +00:00
|
|
|
},
|
|
|
|
components: {
|
|
|
|
BarsIcon: BarsIcon,
|
|
|
|
ThLargeIcon: ThLargeIcon
|
2022-09-14 11:26:01 +00:00
|
|
|
}
|
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
</script>
|