adrema/resources/js/views/activity/Masslist.vue

98 lines
3.2 KiB
Vue
Raw Normal View History

2023-12-30 22:21:08 +01:00
<template>
<page-layout>
<template #right>
<f-save-button form="actionform"></f-save-button>
</template>
<form id="actionform" class="grow p-3" @submit.prevent="submit">
<div class="flex space-x-3">
<f-select
2024-04-12 02:11:30 +02:00
:model-value="meta.activity_id"
:options="props.activities"
label="Tätigkeit"
2023-12-30 22:21:08 +01:00
size="sm"
2024-04-12 02:11:30 +02:00
name="activity_id"
@update:model-value="meta = {...meta, activity_id: $event, subactivity_id: null}"
2023-12-30 22:21:08 +01:00
></f-select>
2024-04-12 02:11:30 +02:00
<f-select v-model="meta.subactivity_id" :options="props.subactivities[meta.activity_id]" name="subactivity_id" label="Untertätigkeit" size="sm"></f-select>
<f-select v-model="meta.group_id" :options="props.groups" label="Gruppierung" size="sm" name="group_id"></f-select>
2024-06-28 12:43:05 +02:00
<f-text id="search_text" v-model="searchText" label="Suchen …" size="sm"></f-text>
2023-12-30 22:21:08 +01:00
</div>
<div class="grid gap-2 grid-cols-6 mt-4">
2024-04-12 02:11:30 +02:00
<f-switch v-for="member in members.hits" :id="`member-${member.id}`" :key="member.id" v-model="selected" :value="member.id" :label="member.fullname" size="sm"></f-switch>
2023-12-30 22:21:08 +01:00
</div>
2024-04-12 02:11:30 +02:00
<div class="px-6">
<ui-search-pagination class="mt-4" :value="members" @reload="reloadReal($event)"></ui-search-pagination>
2023-12-30 22:21:08 +01:00
</div>
</form>
</page-layout>
</template>
<script lang="js" setup>
2024-04-12 02:11:30 +02:00
import { onBeforeUnmount, ref, defineProps, watch, inject } from 'vue';
2023-12-30 22:21:08 +01:00
import useQueueEvents from '../../composables/useQueueEvents.js';
2024-04-12 02:11:30 +02:00
import useSearch from '../../composables/useSearch.js';
2023-12-30 22:21:08 +01:00
const { startListener, stopListener } = useQueueEvents('group', () => null);
2024-04-12 02:11:30 +02:00
const { search } = useSearch();
2023-12-30 22:21:08 +01:00
const axios = inject('axios');
startListener();
onBeforeUnmount(() => stopListener());
const props = defineProps({
activities: {
type: Object,
default: () => { },
},
subactivities: {
type: Object,
default: () => { },
},
groups: {
type: Object,
default: () => { },
},
});
2024-04-12 02:20:43 +02:00
const searchText = ref('');
watch(searchText, (newValue) => {
reloadReal(1);
});
2024-04-12 02:11:30 +02:00
const meta = ref({
activity_id: null,
subactivity_id: null,
group_id: null,
});
2023-12-30 22:21:08 +01:00
2024-04-12 02:11:30 +02:00
const members = ref({
hits: [],
hitsPerPage: 1,
page: 1,
totalHits: 0,
totalPages: 1,
});
2023-12-30 22:21:08 +01:00
2024-04-12 02:11:30 +02:00
const selected = ref([]);
2023-12-30 22:21:08 +01:00
2024-04-12 02:11:30 +02:00
watch(meta, async (newValue) => {
if (!newValue.group_id || !newValue.subactivity_id || !newValue.activity_id) {
return;
2023-12-30 22:21:08 +01:00
}
2024-04-12 02:11:30 +02:00
const results = await search('', [`memberships.with_group = "${newValue.group_id}|${newValue.activity_id}|${newValue.subactivity_id}"`], { page: 1, hitsPerPage: 1000000 });
selected.value = results.hits.map(member => member.id);
}, { deep: true });
2023-12-30 22:21:08 +01:00
2024-04-12 02:11:30 +02:00
async function reloadReal(page) {
2024-04-12 02:20:43 +02:00
const results = await search(searchText.value, [], { page: page, hitsPerPage: 80 });
2024-04-12 02:11:30 +02:00
members.value = results;
2023-12-30 22:21:08 +01:00
}
2024-04-12 02:11:30 +02:00
reloadReal(1);
2023-12-30 22:21:08 +01:00
async function submit() {
await axios.post('/api/membership/masslist', {
2024-04-12 02:11:30 +02:00
...meta.value,
2023-12-30 22:21:08 +01:00
members: selected.value,
});
}
</script>