[events] Can send invitations and transfers
This commit is contained in:
parent
43dcd0579e
commit
48aa6c724a
|
@ -15,7 +15,7 @@
|
||||||
Uhr
|
Uhr
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-card-actions align="around">
|
<q-card-actions align="around">
|
||||||
<q-btn style="width: 47.5%" color="primary" label="Eintragen" @click="enroll" />
|
<q-btn style="width: 47.5%" color="primary" label="Eintragen" @click="enroll()" />
|
||||||
<q-toggle
|
<q-toggle
|
||||||
v-model="service.is_backup"
|
v-model="service.is_backup"
|
||||||
style="width: 47.5%"
|
style="width: 47.5%"
|
||||||
|
@ -29,14 +29,14 @@
|
||||||
style="width: 47.5%"
|
style="width: 47.5%"
|
||||||
color="negative"
|
color="negative"
|
||||||
label="Übertragen"
|
label="Übertragen"
|
||||||
@click="transfer"
|
@click="enroll(true)"
|
||||||
/>
|
/>
|
||||||
<q-btn
|
<q-btn
|
||||||
v-if="!iam(service.userid)"
|
v-if="!iam(service.userid)"
|
||||||
style="width: 47.5%"
|
style="width: 47.5%"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
label="Einladen"
|
label="Einladen"
|
||||||
@click="invite"
|
@click="enroll(false, true)"
|
||||||
/>
|
/>
|
||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
@ -74,7 +74,7 @@
|
||||||
color="white"
|
color="white"
|
||||||
:text-color="scope.opt.is_backup ? 'primary' : 'secondary'"
|
:text-color="scope.opt.is_backup ? 'primary' : 'secondary'"
|
||||||
class="q-ma-none"
|
class="q-ma-none"
|
||||||
@remove="remove(scope.opt.userid, scope.removeAtIndex, scope.index)"
|
@remove="remove(scope.opt, scope.removeAtIndex, scope.index)"
|
||||||
>
|
>
|
||||||
<q-avatar :color="scope.opt.is_backup ? 'primary' : 'secondary'" text-color="white">
|
<q-avatar :color="scope.opt.is_backup ? 'primary' : 'secondary'" text-color="white">
|
||||||
<img
|
<img
|
||||||
|
@ -142,8 +142,15 @@ export default defineComponent({
|
||||||
return uid === mainStore.currentUser.userid;
|
return uid === mainStore.currentUser.userid;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function enroll() {
|
async function enroll(transfer = false, invite = false) {
|
||||||
try {
|
try {
|
||||||
|
dialog.value = false;
|
||||||
|
if (transfer)
|
||||||
|
service.value = Object.assign({}, service.value, {
|
||||||
|
replace: mainStore.currentUser.userid,
|
||||||
|
});
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||||
|
else if (invite) delete (<any>service.value).value;
|
||||||
const job = await store.updateJob(props.eventId, props.modelValue.id, {
|
const job = await store.updateJob(props.eventId, props.modelValue.id, {
|
||||||
user: <FG.Service>service.value,
|
user: <FG.Service>service.value,
|
||||||
});
|
});
|
||||||
|
@ -161,11 +168,28 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function remove(userid: string, rem: (i: number) => void, index: number) {
|
async function remove(service: FG.Service, rem: (i: number) => void, index: number) {
|
||||||
if (userid === mainStore.currentUser.userid || hasPermission(PERMISSIONS.ASSIGN_OTHER)) {
|
if (
|
||||||
console.log('YES REM');
|
service.userid === mainStore.currentUser.userid ||
|
||||||
|
hasPermission(PERMISSIONS.ASSIGN_OTHER)
|
||||||
|
) {
|
||||||
rem(index);
|
rem(index);
|
||||||
await signOutFromJob();
|
try {
|
||||||
|
const job = await store.updateJob(props.eventId, props.modelValue.id, {
|
||||||
|
user: Object.assign({}, service, { value: -service.value }),
|
||||||
|
});
|
||||||
|
emit('update:modelValue', job);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(error);
|
||||||
|
Notify.create({
|
||||||
|
group: false,
|
||||||
|
type: 'negative',
|
||||||
|
message: 'Fehler beim Austragen als Dienst',
|
||||||
|
timeout: 10000,
|
||||||
|
progress: true,
|
||||||
|
actions: [{ icon: 'mdi-close', color: 'white' }],
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,37 +217,12 @@ export default defineComponent({
|
||||||
return sum < props.modelValue.required_services && !is;
|
return sum < props.modelValue.required_services && !is;
|
||||||
});
|
});
|
||||||
|
|
||||||
async function signOutFromJob() {
|
|
||||||
const newService: FG.Service = {
|
|
||||||
userid: mainStore.currentUser.userid,
|
|
||||||
is_backup: false,
|
|
||||||
value: -1,
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
const job = await store.updateJob(props.eventId, props.modelValue.id, {
|
|
||||||
user: newService,
|
|
||||||
});
|
|
||||||
emit('update:modelValue', job);
|
|
||||||
} catch (error) {
|
|
||||||
console.warn(error);
|
|
||||||
Notify.create({
|
|
||||||
group: false,
|
|
||||||
type: 'negative',
|
|
||||||
message: 'Fehler beim Austragen als Dienst',
|
|
||||||
timeout: 10000,
|
|
||||||
progress: true,
|
|
||||||
actions: [{ icon: 'mdi-close', color: 'white' }],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
enroll,
|
enroll,
|
||||||
availableUsers,
|
availableUsers,
|
||||||
canEdit,
|
canEdit,
|
||||||
isEnrolled,
|
isEnrolled,
|
||||||
enrolled,
|
enrolled,
|
||||||
signOutFromJob,
|
|
||||||
enrollDialog,
|
enrollDialog,
|
||||||
canEnroll,
|
canEnroll,
|
||||||
remove,
|
remove,
|
||||||
|
|
|
@ -2,13 +2,35 @@ import { defineAsyncComponent } from 'vue';
|
||||||
import { innerRoutes, privateRoutes } from './routes';
|
import { innerRoutes, privateRoutes } from './routes';
|
||||||
import { FG_Plugin } from 'src/plugins';
|
import { FG_Plugin } from 'src/plugins';
|
||||||
|
|
||||||
|
interface EventNotification extends FG_Plugin.Notification {
|
||||||
|
data: { type: NotificationType };
|
||||||
|
}
|
||||||
|
|
||||||
|
enum NotificationType {
|
||||||
|
REQUEST = 0x10,
|
||||||
|
ACCEPTED = 0x11,
|
||||||
|
REJECTED = 0x12,
|
||||||
|
}
|
||||||
|
|
||||||
|
function transpile(n: FG.Notification) {
|
||||||
|
const notification = <EventNotification>Object.assign({}, n);
|
||||||
|
if (notification.data.type === NotificationType.REQUEST)
|
||||||
|
notification.accept = () =>
|
||||||
|
new Promise((r) => {
|
||||||
|
console.log('REQUEST ACCEPTED');
|
||||||
|
r();
|
||||||
|
});
|
||||||
|
return notification;
|
||||||
|
}
|
||||||
|
|
||||||
const plugin: FG_Plugin.Plugin = {
|
const plugin: FG_Plugin.Plugin = {
|
||||||
name: 'Events',
|
name: 'events',
|
||||||
innerRoutes,
|
innerRoutes,
|
||||||
internalRoutes: privateRoutes,
|
internalRoutes: privateRoutes,
|
||||||
requiredModules: ['User'],
|
requiredModules: ['User'],
|
||||||
requiredBackendModules: ['events'],
|
requiredBackendModules: ['events'],
|
||||||
version: '0.0.2',
|
version: '0.0.2',
|
||||||
|
notification: transpile,
|
||||||
widgets: [
|
widgets: [
|
||||||
{
|
{
|
||||||
priority: 0,
|
priority: 0,
|
||||||
|
|
|
@ -148,7 +148,7 @@ export const useScheduleStore = defineStore({
|
||||||
|
|
||||||
async updateJob(eventId: number, jobId: number, service: FG.Service | UserService) {
|
async updateJob(eventId: number, jobId: number, service: FG.Service | UserService) {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.put<FG.Job>(`/events/${eventId}/jobs/${jobId}`, service);
|
const { data } = await api.put<FG.Job>(`/events/${eventId}/${jobId}`, service);
|
||||||
fixJob(data);
|
fixJob(data);
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
Loading…
Reference in New Issue