Compare commits

..

4 commits

Author SHA1 Message Date
fc3484fe22 stash 2024-06-28 00:49:09 +02:00
d6823a147b stash 2024-06-26 21:22:34 +02:00
5e6030e715 stash 2024-06-26 21:03:29 +02:00
f9409bb823 fix related item section in ticket view 2024-06-26 20:53:19 +02:00
6 changed files with 38 additions and 28 deletions

View file

@ -5,7 +5,7 @@ from rest_framework.decorators import api_view, permission_classes
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from notifications.models import MessageTemplate
from notifications.models import MessageTemplate, UserNotificationChannel
from rest_framework import serializers
from notifications.templates import TEMPLATE_VARS
@ -17,11 +17,22 @@ class MessageTemplateSerializer(serializers.ModelSerializer):
fields = '__all__'
class UserNotificationChannelSerializer(serializers.ModelSerializer):
class Meta:
model = UserNotificationChannel
fields = '__all__'
class MessageTemplateViewSet(viewsets.ModelViewSet):
serializer_class = MessageTemplateSerializer
queryset = MessageTemplate.objects.all()
class UserNotificationChannelViewSet(viewsets.ModelViewSet):
serializer_class = UserNotificationChannelSerializer
queryset = UserNotificationChannel.objects.all()
@api_view(['GET'])
@permission_classes([IsAuthenticated])
@permission_required('tickets.add_issuethread_manual', raise_exception=True) # TDOO: change this permission
@ -31,7 +42,7 @@ def get_template_vars(self):
router = routers.SimpleRouter()
router.register(r'message_templates', MessageTemplateViewSet)
router.register(r'user_notification_channels', UserNotificationChannelViewSet)
urlpatterns = ([
re_path('message_template_variables', get_template_vars),
] + router.urls)

View file

@ -111,7 +111,7 @@ export default {
this.$emit('addComment', this.newComment);
this.newComment = "";
}
},
}
};
</script>

View file

@ -11,10 +11,10 @@
</div>
<div class="card bg-dark">
<div class="row">
<div class="col" style="min-width: 4em;">
<div class="col" style="flex-grow: 0;">
<AuthenticatedImage v-if="item.item.file" cached
:src="`/media/2/256/${item.item.file}/`"
class="d-block w-100 card-img-left"
class="d-block card-img-left"
@click="openLightboxModalWith(item.item)"
/>
</div>

View file

@ -22,6 +22,7 @@ const store = createStore({
messageTemplates: [],
messageTemplateVariables: [],
shippingVouchers: [],
userNotificationChannels: [],
lastEvent: '37C3',
lastUsed: {},
@ -506,7 +507,14 @@ const store = createStore({
state.fetchedData.tickets = 0;
await Promise.all([dispatch('loadTickets'), dispatch('fetchShippingVouchers')]);
}
}
},
async fetchUserNotificationChannels({commit, state}) {
if (!state.user.token) return;
const {data, success} = await http.get('/2/user_notification_channels/', state.user.token);
if (data && success) {
state.userNotificationChannels = data;
}
},
},
plugins: [
persistentStatePlugin({ // TODO change remember to some kind of enable field

View file

@ -83,7 +83,7 @@ export default {
methods: {
...mapActions(['deleteItem', 'markItemReturned', 'sendMail', 'updateTicketPartial', 'postComment']),
...mapActions(['loadTickets', 'fetchTicketStates', 'loadUsers', 'scheduleAfterInit']),
...mapActions(['claimShippingVoucher']),
...mapActions(['claimShippingVoucher', 'fetchShippingVouchers']),
handleMail(mail) {
this.sendMail({
id: this.ticket.id,
@ -110,7 +110,8 @@ export default {
},
},
mounted() {
this.scheduleAfterInit(() => [this.fetchTicketStates(), this.loadTickets(), this.loadUsers()]);
this.scheduleAfterInit(() => [this.fetchTicketStates(), this.loadTickets(), this.loadUsers(),
this.fetchShippingVouchers()]);
}
};
</script>

View file

@ -1,22 +1,9 @@
<template>
<Table
:columns="['slug', 'name']"
:items="events"
:keyName="'slug'"
>
<template #actions="{ item }">
<div class="btn-group">
<button class="btn btn-secondary" @click.stop="changeEvent(item)">
<font-awesome-icon icon="archive"/>
use
</button>
<button class="btn btn-danger" @click.stop="">
<font-awesome-icon icon="trash"/>
delete
</button>
</div>
</template>
</Table>
<ul>
<li v-for="channel in userNotificationChannels" :key="channel.id">
{{ channel.name }}
</li>
</ul>
</template>
<script>
@ -26,8 +13,11 @@ import Table from '@/components/Table';
export default {
name: 'Notifications',
components: {Table},
computed: mapState(['events']),
methods: mapActions(['changeEvent']),
computed: mapState(['userNotificationChannels']),
methods: mapActions(['fetchUserNotificationChannels']),
mounted() {
this.fetchUserNotificationChannels();
}
};
</script>