Files
Faris Ansari 42bc0efe2a refactor: Grouped site list in bench
- Use native ListView grouping feature
- replace custom API with standard list API
- simplify code
2024-03-24 16:37:37 +05:30

51 lines
1.1 KiB
Vue

<template>
<Button v-if="buttonProps" v-bind="buttonProps">
<template
v-for="(slot, slotName) in buttonProps.slots"
v-slot:[slotName]="slotProps"
>
<component :is="slot" v-bind="slotProps" />
</template>
</Button>
<Dropdown v-else-if="dropdownProps" v-bind="dropdownProps">
<ActionButton v-bind="dropdownProps.button" />
</Dropdown>
</template>
<script>
import { Button, Dropdown } from 'frappe-ui';
import { icon } from '../utils/components';
export default {
name: 'ActionButton',
components: {
Button,
Dropdown
},
computed: {
buttonProps() {
if (!this.$attrs.label || this.$attrs.options) return null;
return this.$attrs;
},
dropdownProps() {
if (!this.$attrs.options) return null;
if (this.$attrs.condition) {
if (!this.$attrs.condition(this.$attrs.context)) return null;
}
return {
button: {
label: 'Options',
variant: 'ghost',
slots: {
icon: icon('more-horizontal')
}
},
...this.$attrs,
label: this.$attrs.label,
options: this.$attrs.options
};
}
}
};
</script>