feat: allow multiple prop in inbox filters
This commit is contained in:
+23
-21
@@ -1,26 +1,27 @@
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
<script setup>
|
||||
import { ref, onMounted, defineEmits } from 'vue';
|
||||
import { useMapGetter, useStore } from 'dashboard/composables/store';
|
||||
|
||||
export default {
|
||||
name: 'ReportsFiltersInboxes',
|
||||
data() {
|
||||
return {
|
||||
selectedOption: null,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
options: 'inboxes/getInboxes',
|
||||
}),
|
||||
},
|
||||
mounted() {
|
||||
this.$store.dispatch('inboxes/get');
|
||||
},
|
||||
methods: {
|
||||
handleInput() {
|
||||
this.$emit('inboxFilterSelection', this.selectedOption);
|
||||
},
|
||||
// add prop for multiple selector
|
||||
defineProps({
|
||||
multiple: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['inboxFilterSelection']);
|
||||
const store = useStore();
|
||||
const options = useMapGetter('inboxes/getInboxes');
|
||||
|
||||
const selectedOption = ref(null);
|
||||
|
||||
onMounted(() => {
|
||||
store.dispatch('inboxes/get');
|
||||
});
|
||||
|
||||
const handleInput = () => {
|
||||
emit('inboxFilterSelection', selectedOption.value);
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -32,6 +33,7 @@ export default {
|
||||
:placeholder="$t('INBOX_REPORTS.FILTER_DROPDOWN_LABEL')"
|
||||
label="name"
|
||||
track-by="id"
|
||||
:multiple="multiple"
|
||||
:options="options"
|
||||
:option-height="24"
|
||||
:show-labels="false"
|
||||
|
||||
+3
-1
@@ -56,7 +56,9 @@ describe('ReportsFiltersInboxes.vue', () => {
|
||||
const selectedInbox = { id: 1, name: 'Inbox 1' };
|
||||
wrapper.setData({ selectedOption: selectedInbox });
|
||||
|
||||
wrapper.vm.handleInput();
|
||||
wrapper
|
||||
.findComponent({ name: 'multiselect' })
|
||||
.vm.$emit('input', selectedInbox);
|
||||
|
||||
expect(wrapper.emitted('inboxFilterSelection')).toBeTruthy();
|
||||
expect(wrapper.emitted('inboxFilterSelection')[0]).toEqual([selectedInbox]);
|
||||
|
||||
Reference in New Issue
Block a user