2024-02-08 23:09:51 +01:00
|
|
|
<template>
|
2024-07-13 18:24:43 +02:00
|
|
|
<div>
|
2024-07-12 20:18:41 +02:00
|
|
|
<ui-popup v-if="editing !== null" heading="Mitglied bearbeiten" closeable full @close="editing = null">
|
|
|
|
<event-form
|
2024-07-13 18:24:43 +02:00
|
|
|
:value="editing.preview"
|
2024-07-12 20:18:41 +02:00
|
|
|
:base-url="meta.base_url"
|
|
|
|
style="--primary: hsl(181, 75%, 26%); --secondary: hsl(181, 75%, 35%); --font: hsl(181, 84%, 78%); --circle: hsl(181, 86%, 16%)"
|
|
|
|
as-form
|
|
|
|
@save="updateParticipant($event.detail[0])"
|
|
|
|
></event-form>
|
|
|
|
</ui-popup>
|
2024-07-02 18:04:55 +02:00
|
|
|
<ui-popup v-if="assigning !== null" heading="Mitglied zuweisen" closeable @close="assigning = null">
|
|
|
|
<member-assign @assign="assign"></member-assign>
|
|
|
|
</ui-popup>
|
2024-04-25 21:49:31 +02:00
|
|
|
<ui-popup v-if="deleting !== null" heading="Teilnehmer*in löschen?" @close="deleting = null">
|
|
|
|
<div>
|
|
|
|
<p class="mt-4">Den*Die Teilnehmer*in löschen?</p>
|
|
|
|
<div class="grid grid-cols-2 gap-3 mt-6">
|
|
|
|
<a href="#" class="text-center btn btn-danger" @click.prevent="handleDelete">Mitglied loschen</a>
|
|
|
|
<a href="#" class="text-center btn btn-primary" @click.prevent="deleting = null">Abbrechen</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</ui-popup>
|
2024-02-21 23:18:31 +01:00
|
|
|
<page-filter breakpoint="lg">
|
2024-07-13 18:48:11 +02:00
|
|
|
<template #buttons>
|
2024-12-12 00:30:59 +01:00
|
|
|
<f-text id="search" v-model="innerFilter.search" name="search" label="Suchen" size="sm"></f-text>
|
2024-07-13 18:48:11 +02:00
|
|
|
<ui-icon-button icon="plus" @click="editing = {participant: null, preview: JSON.stringify(meta.form_config)}">Hinzufügen</ui-icon-button>
|
|
|
|
<f-switch v-if="meta.has_nami_field" id="group_participants" v-model="groupParticipants" label="Gruppieren" size="sm" name="group_participants"></f-switch>
|
|
|
|
<f-multipleselect id="active_columns" v-model="activeColumnsConfig" :options="meta.columns" label="Aktive Spalten" size="sm"></f-multipleselect>
|
|
|
|
</template>
|
2024-04-26 23:20:03 +02:00
|
|
|
|
2024-07-13 18:48:11 +02:00
|
|
|
<template #fields>
|
|
|
|
<template v-for="(filter, index) in meta.filters">
|
|
|
|
<f-select
|
|
|
|
v-if="filter.base_type === 'CheckboxField'"
|
|
|
|
:id="`filter-field-${index}`"
|
|
|
|
:key="`filter-field-${index}`"
|
|
|
|
v-model="innerFilter.data[filter.key]"
|
|
|
|
:null-value="meta.default_filter_value"
|
|
|
|
:name="`filter-field-${index}`"
|
|
|
|
:options="checkboxFilterOptions"
|
|
|
|
:label="filter.name"
|
|
|
|
size="sm"
|
|
|
|
></f-select>
|
|
|
|
<f-select
|
|
|
|
v-if="filter.base_type === 'DropdownField'"
|
|
|
|
:id="`filter-field-${index}`"
|
|
|
|
:key="`filter-field-${index}`"
|
|
|
|
v-model="innerFilter.data[filter.key]"
|
|
|
|
:null-value="meta.default_filter_value"
|
|
|
|
:name="`filter-field-${index}`"
|
|
|
|
:options="dropdownFilterOptions(filter)"
|
|
|
|
:label="filter.name"
|
|
|
|
size="sm"
|
|
|
|
></f-select>
|
|
|
|
<f-select
|
|
|
|
v-if="filter.base_type === 'RadioField'"
|
|
|
|
:id="`filter-field-${index}`"
|
|
|
|
:key="`filter-field-${index}`"
|
|
|
|
v-model="innerFilter.data[filter.key]"
|
|
|
|
:null-value="meta.default_filter_value"
|
|
|
|
:name="`filter-field-${index}`"
|
|
|
|
:options="dropdownFilterOptions(filter)"
|
|
|
|
:label="filter.name"
|
|
|
|
size="sm"
|
|
|
|
></f-select>
|
|
|
|
</template>
|
2024-04-26 23:20:03 +02:00
|
|
|
</template>
|
2024-02-21 23:18:31 +01:00
|
|
|
</page-filter>
|
2024-02-08 23:09:51 +01:00
|
|
|
<table cellspacing="0" cellpadding="0" border="0" class="custom-table custom-table-sm">
|
|
|
|
<thead>
|
|
|
|
<th v-for="column in activeColumns" :key="column.id" v-text="column.name"></th>
|
|
|
|
<th></th>
|
|
|
|
</thead>
|
|
|
|
|
2024-06-21 00:25:14 +02:00
|
|
|
<template v-for="(participant, index) in data" :key="index">
|
|
|
|
<tr>
|
|
|
|
<td v-for="(column, columnindex) in activeColumns" :key="column.id">
|
2024-07-02 18:04:55 +02:00
|
|
|
<div class="flex items-center space-x-2">
|
|
|
|
<button v-if="columnindex === 0 && participant.member_id === null" v-tooltip="`kein Mitglied zugewiesen. Per Klick zuweisen`" @click.prevent="assigning = participant">
|
|
|
|
<ui-sprite src="warning-triangle" class="text-yellow-400 w-5 h-5"></ui-sprite>
|
|
|
|
</button>
|
2024-07-25 00:17:31 +02:00
|
|
|
<ui-table-toggle-button v-if="columnindex === 0 && groupParticipants" :value="participant" :level="0" :active="isOpen(participant.id)" @toggle="toggle(participant)">
|
|
|
|
<prevention v-if="column.display_attribute === 'prevention_display'" :value="participant.prevention_items"></prevention>
|
|
|
|
<span v-else v-text="participant[column.display_attribute]"></span>
|
|
|
|
</ui-table-toggle-button>
|
|
|
|
<div v-else>
|
|
|
|
<prevention v-if="column.display_attribute === 'prevention_display'" :value="participant.prevention_items"></prevention>
|
|
|
|
<span v-else v-text="participant[column.display_attribute]"></span>
|
|
|
|
</div>
|
2024-07-02 18:04:55 +02:00
|
|
|
</div>
|
2024-06-21 00:25:14 +02:00
|
|
|
</td>
|
|
|
|
<td>
|
2024-07-12 20:18:41 +02:00
|
|
|
<a v-tooltip="`Bearbeiten`" href="#" class="ml-2 inline-flex btn btn-warning btn-sm" @click.prevent="editReal(participant)"><ui-sprite src="pencil"></ui-sprite></a>
|
2024-06-21 00:25:14 +02:00
|
|
|
<a v-tooltip="`Löschen`" href="#" class="ml-2 inline-flex btn btn-danger btn-sm" @click.prevent="deleting = participant"><ui-sprite src="trash"></ui-sprite></a>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<template v-for="child in childrenOf(participant.id)" :key="child.id">
|
|
|
|
<tr>
|
|
|
|
<td v-for="(column, columnindex) in activeColumns" :key="column.id">
|
2024-07-25 00:17:31 +02:00
|
|
|
<div class="flex items-center space-x-2">
|
|
|
|
<ui-table-toggle-button v-if="columnindex === 0 && groupParticipants" :value="child" :level="1" :active="isOpen(child.id)" @toggle="toggle(child)">
|
|
|
|
<prevention v-if="column.display_attribute === 'prevention_display'" :value="child.prevention_items"></prevention>
|
|
|
|
<span v-else v-text="child[column.display_attribute]"></span>
|
|
|
|
</ui-table-toggle-button>
|
|
|
|
<div v-else>
|
|
|
|
<prevention v-if="column.display_attribute === 'prevention_display'" :value="child.prevention_items"></prevention>
|
|
|
|
<span v-else v-text="child[column.display_attribute]"></span>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-06-21 00:25:14 +02:00
|
|
|
</td>
|
|
|
|
<td>
|
2024-07-12 20:18:41 +02:00
|
|
|
<a v-tooltip="`Bearbeiten`" href="#" class="ml-2 inline-flex btn btn-warning btn-sm" @click.prevent="editReal(child)"><ui-sprite src="pencil"></ui-sprite></a>
|
2024-06-21 00:25:14 +02:00
|
|
|
<a v-tooltip="`Löschen`" href="#" class="ml-2 inline-flex btn btn-danger btn-sm" @click.prevent="deleting = child"><ui-sprite src="trash"></ui-sprite></a>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</template>
|
|
|
|
</template>
|
2024-02-08 23:09:51 +01:00
|
|
|
</table>
|
|
|
|
<div class="px-6">
|
2024-12-12 00:30:59 +01:00
|
|
|
<ui-pagination class="mt-4" :value="meta" @reload="reloadPage($event, {filter: toFilterString(innerFilter)})"></ui-pagination>
|
2024-02-08 23:09:51 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2024-07-03 16:37:58 +02:00
|
|
|
<script lang="js" setup>
|
|
|
|
import { watch, ref, computed } from 'vue';
|
|
|
|
import { useApiIndex } from '../../composables/useApiIndex.js';
|
2024-06-21 00:25:14 +02:00
|
|
|
import useTableToggle from '../../composables/useTableToggle.js';
|
2024-07-02 18:04:55 +02:00
|
|
|
import MemberAssign from './MemberAssign.vue';
|
2024-07-25 00:17:31 +02:00
|
|
|
import Prevention from './Prevention.vue';
|
2024-02-08 23:09:51 +01:00
|
|
|
|
2024-04-25 21:49:31 +02:00
|
|
|
const deleting = ref(null);
|
2024-07-03 16:37:58 +02:00
|
|
|
const { isOpen, toggle, childrenOf, clearToggle } = useTableToggle({});
|
2024-04-25 21:49:31 +02:00
|
|
|
|
2024-07-02 18:04:55 +02:00
|
|
|
const assigning = ref(null);
|
|
|
|
|
2024-02-08 23:09:51 +01:00
|
|
|
const props = defineProps({
|
|
|
|
url: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
validator: (value) => value.startsWith('http'),
|
|
|
|
},
|
2024-06-20 23:31:09 +02:00
|
|
|
rootUrl: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
validator: (value) => value.startsWith('http'),
|
|
|
|
},
|
|
|
|
hasNamiField: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
2024-02-08 23:09:51 +01:00
|
|
|
});
|
2024-06-21 00:25:14 +02:00
|
|
|
const groupParticipants = computed({
|
|
|
|
get() {
|
|
|
|
return url.value === props.rootUrl;
|
|
|
|
},
|
|
|
|
async set(v) {
|
|
|
|
updateUrl(v ? props.rootUrl : props.url);
|
|
|
|
if (!v) {
|
|
|
|
clearToggle();
|
|
|
|
}
|
|
|
|
await reload();
|
|
|
|
},
|
|
|
|
});
|
2024-02-08 23:09:51 +01:00
|
|
|
|
2024-07-02 18:04:55 +02:00
|
|
|
async function assign(memberId) {
|
2024-07-03 16:37:58 +02:00
|
|
|
await axios.post(assigning.value.links.assign, { member_id: memberId });
|
2024-07-02 21:42:38 +02:00
|
|
|
reload(false);
|
2024-07-02 18:04:55 +02:00
|
|
|
assigning.value = null;
|
|
|
|
}
|
|
|
|
|
2024-07-03 16:37:58 +02:00
|
|
|
var { meta, data, reload, reloadPage, axios, remove, toFilterString, url, updateUrl } = useApiIndex(props.hasNamiField ? props.rootUrl : props.url, 'participant');
|
2024-02-08 23:09:51 +01:00
|
|
|
|
2024-02-21 22:44:52 +01:00
|
|
|
const activeColumns = computed(() => meta.value.columns.filter((c) => meta.value.form_meta.active_columns.includes(c.id)));
|
2024-02-21 23:18:31 +01:00
|
|
|
|
|
|
|
const activeColumnsConfig = computed({
|
|
|
|
get: () => meta.value.form_meta.active_columns,
|
|
|
|
set: async (v) => {
|
|
|
|
const response = await axios.patch(meta.value.links.update_form_meta, {
|
|
|
|
...meta.value.form_meta,
|
|
|
|
active_columns: v,
|
|
|
|
});
|
|
|
|
|
|
|
|
meta.value.form_meta = response.data;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2024-04-25 21:49:31 +02:00
|
|
|
async function handleDelete() {
|
|
|
|
await remove(deleting.value);
|
|
|
|
deleting.value = null;
|
|
|
|
}
|
|
|
|
|
2024-02-21 23:18:31 +01:00
|
|
|
await reload();
|
2024-04-26 23:20:03 +02:00
|
|
|
|
|
|
|
const innerFilter = ref(JSON.parse(JSON.stringify(meta.value.filter)));
|
|
|
|
|
|
|
|
watch(
|
|
|
|
innerFilter,
|
|
|
|
async function (newValue) {
|
|
|
|
await reload(true, {
|
|
|
|
filter: toFilterString(newValue),
|
|
|
|
});
|
|
|
|
},
|
2024-07-03 16:37:58 +02:00
|
|
|
{ deep: true }
|
2024-04-26 23:20:03 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
const checkboxFilterOptions = ref([
|
2024-07-03 16:37:58 +02:00
|
|
|
{ id: true, name: 'Ja' },
|
|
|
|
{ id: false, name: 'Nein' },
|
2024-04-26 23:20:03 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
function dropdownFilterOptions(filter) {
|
|
|
|
return [
|
2024-07-03 16:37:58 +02:00
|
|
|
{ id: null, name: 'keine Auswahl' },
|
2024-04-26 23:20:03 +02:00
|
|
|
...filter.options.map((f) => {
|
2024-07-03 16:37:58 +02:00
|
|
|
return { id: f, name: f };
|
2024-04-26 23:20:03 +02:00
|
|
|
}),
|
|
|
|
];
|
|
|
|
}
|
2024-07-12 20:18:41 +02:00
|
|
|
|
|
|
|
async function editReal(participant) {
|
|
|
|
const response = await axios.get(participant.links.fields);
|
|
|
|
editing.value = {
|
|
|
|
participant: participant,
|
2024-07-13 18:24:43 +02:00
|
|
|
preview: JSON.stringify(response.data.data.config),
|
2024-07-12 20:18:41 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
async function updateParticipant(payload) {
|
2024-07-13 18:24:43 +02:00
|
|
|
if (editing.value.participant === null) {
|
|
|
|
await axios.post(meta.value.links.store_participant, payload);
|
|
|
|
} else {
|
|
|
|
await axios.patch(editing.value.participant.links.update, payload);
|
|
|
|
}
|
2024-07-12 20:18:41 +02:00
|
|
|
|
|
|
|
await reload();
|
|
|
|
|
|
|
|
editing.value = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const editing = ref(null);
|
2024-02-08 23:09:51 +01:00
|
|
|
</script>
|