Skip to content

Commit

Permalink
feat: cleanup and update deps
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Trost <[email protected]>
  • Loading branch information
galexrt committed Sep 20, 2024
1 parent e9cdbb5 commit 6b1a5ec
Show file tree
Hide file tree
Showing 38 changed files with 222 additions and 254 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ const onSubmitThrottle = useThrottleFn(async (event: FormSubmitEvent<Schema>) =>
type="text"
name="message"
:placeholder="$t('common.message')"


/>
</UFormGroup>
</dd>
Expand All @@ -133,8 +131,6 @@ const onSubmitThrottle = useThrottleFn(async (event: FormSubmitEvent<Schema>) =>
type="text"
name="description"
:placeholder="$t('common.description')"


/>
</UFormGroup>
</dd>
Expand Down
13 changes: 1 addition & 12 deletions app/components/centrum/dispatches/DispatchStatusUpdateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,7 @@ function updateReasonField(value: string): void {
</dt>
<dd class="mt-1 text-sm leading-6 sm:col-span-2 sm:mt-0">
<UFormGroup name="code" class="flex-1">
<UInput
v-model="state.code"
type="text"
name="code"
:placeholder="$t('common.code')"


/>
<UInput v-model="state.code" type="text" name="code" :placeholder="$t('common.code')" />
</UFormGroup>
</dd>
</div>
Expand All @@ -170,8 +163,6 @@ function updateReasonField(value: string): void {
type="text"
name="reason"
:placeholder="$t('common.reason')"


/>
</UFormGroup>
</dd>
Expand All @@ -192,8 +183,6 @@ function updateReasonField(value: string): void {
name="dispatchStatus"
:options="['&nbsp;', ...settings?.predefinedStatus.dispatchStatus]"
:searchable-placeholder="$t('common.search_field')"
@change="updateReasonField($event)"
>
<template #option="{ option }">
Expand Down
2 changes: 0 additions & 2 deletions app/components/centrum/livemap/DispatchesLayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ const dispatchesFiltered = computedAsync(async () =>
:placeholder="`${$t('common.dispatch', 2)} ${$t('common.filter')}`"
autocomplete="off"
:ui="{ icon: { trailing: { pointer: '' } } }"


>
<template #trailing>
<UButton
Expand Down
9 changes: 1 addition & 8 deletions app/components/centrum/livemap/JoinUnitSlideover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,7 @@ const filteredUnits = computed(() =>
<div>
<div class="flex flex-col gap-1">
<UFormGroup name="search" :label="$t('common.search')">
<UInput
v-model="queryUnit"
type="text"
name="search"
:placeholder="$t('common.search')"


/>
<UInput v-model="queryUnit" type="text" name="search" :placeholder="$t('common.search')" />
</UFormGroup>

<div class="grid grid-cols-2 gap-2">
Expand Down
2 changes: 0 additions & 2 deletions app/components/centrum/livemap/TakeDispatchSlideover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ const onSubmitThrottle = useThrottleFn(async (resp: TakeDispatchResp) => {
type="text"
name="search"
:placeholder="$t('common.search')"


/>
</UFormGroup>
</dd>
Expand Down
5 changes: 3 additions & 2 deletions app/components/centrum/partials/DispatchStatusBreakdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ defineOptions({

<template #panel>
<div class="p-4">
<ul role="list" class="text-nowrap text-sm font-normal">
<UIcon v-if="!counts" name="i-mdi-refresh" class="size-4 animate-spin" />
<ul v-else role="list" class="text-nowrap text-sm font-normal">
<li>
<span class="text-black" :class="dispatchStatusToBGColor(StatusDispatch.NEW)"
>{{ $t('enums.centrum.StatusDispatch.UNASSIGNED') }}:</span
>
{{ counts.unassigned }}
{{ counts?.unassigned }}
</li>
<li>
<span class="text-black" :class="dispatchStatusToBGColor(StatusDispatch.EN_ROUTE)">{{
Expand Down
10 changes: 0 additions & 10 deletions app/components/centrum/settings/CentrumSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ const onSubmitThrottle = useThrottleFn(async (event: FormSubmitEvent<Schema>) =>
:options="modes"
value-attribute="mode"
:searchable-placeholder="$t('common.search_field')"


>
<template #label>
<span class="truncate">{{
Expand All @@ -225,8 +223,6 @@ const onSubmitThrottle = useThrottleFn(async (event: FormSubmitEvent<Schema>) =>
:options="modes"
value-attribute="mode"
:searchable-placeholder="$t('common.search_field')"
>
<template #label>
<span class="truncate">{{
Expand Down Expand Up @@ -269,8 +265,6 @@ const onSubmitThrottle = useThrottleFn(async (event: FormSubmitEvent<Schema>) =>
type="text"
class="w-full flex-1"
:placeholder="$t('common.reason')"
/>
</UFormGroup>
Expand Down Expand Up @@ -310,8 +304,6 @@ const onSubmitThrottle = useThrottleFn(async (event: FormSubmitEvent<Schema>) =>
type="text"
class="w-full flex-1"
:placeholder="$t('common.reason')"
/>
</UFormGroup>
Expand Down Expand Up @@ -354,8 +346,6 @@ const onSubmitThrottle = useThrottleFn(async (event: FormSubmitEvent<Schema>) =>
type="number"
:placeholder="$t('common.time_ago.second', 2)"
trailing-icon="i-mdi-access-time"
/>
</UFormGroup>
</UDashboardSection>
Expand Down
28 changes: 4 additions & 24 deletions app/components/centrum/settings/UnitCreateOrUpdateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ async function createOrUpdateUnit(values: Schema): Promise<void> {
job: '',
name: values.name,
initials: values.initials,
color: values.color,
description: values.description,
color: values.color,
attributes: {
list: values.attributes,
},
Expand Down Expand Up @@ -85,8 +85,8 @@ async function updateUnitInForm(): Promise<void> {
state.initials = props.unit.initials;
state.description = props.unit.description;
state.color = props.unit.color;
state.homePostal = props.unit.homePostal;
state.attributes = props.unit.attributes?.list ?? [];
state.homePostal = props.unit.homePostal;
}
watch(props, async () => updateUnitInForm());
Expand Down Expand Up @@ -115,25 +115,11 @@ onMounted(async () => updateUnitInForm());
<div>
<UFormGroup name="name" :label="$t('common.name')" class="flex-1">
<UInput
v-model="state.name"
name="name"
type="text"
:placeholder="$t('common.name')"
/>
<UInput v-model="state.name" name="name" type="text" :placeholder="$t('common.name')" />
</UFormGroup>
<UFormGroup name="initials" :label="$t('common.initials')" class="flex-1">
<UInput
v-model="state.initials"
name="initials"
type="text"
:placeholder="$t('common.initials')"
/>
<UInput v-model="state.initials" name="initials" type="text" :placeholder="$t('common.initials')" />
</UFormGroup>
<UFormGroup name="description" :label="$t('common.description')" class="flex-1">
Expand All @@ -142,8 +128,6 @@ onMounted(async () => updateUnitInForm());
name="description"
type="text"
:placeholder="$t('common.description')"
/>
</UFormGroup>
Expand All @@ -155,8 +139,6 @@ onMounted(async () => updateUnitInForm());
:options="availableAttributes"
:placeholder="selectedAttributes ? selectedAttributes.join(', ') : $t('common.na')"
:searchable-placeholder="$t('common.search_field')"
>
<template #option-empty="{ query: search }">
<q>{{ search }}</q> {{ $t('common.query_not_found') }}
Expand All @@ -181,8 +163,6 @@ onMounted(async () => updateUnitInForm());
name="homePostal"
type="text"
:placeholder="`${$t('common.department')} ${$t('common.postal_code')}`"
/>
</UFormGroup>
</div>
Expand Down
2 changes: 0 additions & 2 deletions app/components/centrum/units/UnitAssignUsersModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ const onSubmitThrottle = useThrottleFn(async () => {
:placeholder="$t('common.owner')"
trailing
by="userId"


>
<template #option="{ option: user }">
{{ `${user?.firstname} ${user?.lastname} (${user?.dateofbirth})` }}
Expand Down
6 changes: 0 additions & 6 deletions app/components/centrum/units/UnitStatusUpdateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ function updateReasonField(value: string): void {
name="code"
:placeholder="$t('common.code')"
:label="$t('common.code')"


/>
</UFormGroup>
</dd>
Expand All @@ -173,8 +171,6 @@ function updateReasonField(value: string): void {
type="text"
name="reason"
:placeholder="$t('common.reason')"


/>
</UFormGroup>
</dd>
Expand All @@ -194,8 +190,6 @@ function updateReasonField(value: string): void {
name="unitStatus"
:options="['&nbsp;', ...settings?.predefinedStatus.unitStatus]"
:searchable-placeholder="$t('common.search_field')"
@change="updateReasonField($event)"
>
<template #option="{ option }">
Expand Down
59 changes: 34 additions & 25 deletions app/components/documents/DocumentCommentEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ import { Comment } from '~~/gen/ts/resources/documents/comment';
import { NotificationType } from '~~/gen/ts/resources/notifications/notifications';
const props = defineProps<{
modelValue: Comment;
modelValue?: Comment;
}>();
const emit = defineEmits<{
(e: 'update:modelValue', comment: Comment): void;
(e: 'deleted', comment: Comment): void;
const emits = defineEmits<{
(e: 'update:modelValue', comment: Comment | undefined): void;
(e: 'deleted', id: string | undefined): void;
}>();
const comment = useVModel(props, 'modelValue', emits);
const modal = useModal();
const authStore = useAuthStore();
Expand All @@ -38,15 +40,15 @@ const state = reactive<Schema>({
});
async function editComment(documentId: string, commentId: string, values: Schema): Promise<void> {
const comment: Comment = {
id: commentId,
documentId,
comment: values.comment,
creatorJob: '',
};
try {
const { response } = await getGRPCDocStoreClient().editComment({ comment });
const { response } = await getGRPCDocStoreClient().editComment({
comment: {
id: commentId,
documentId,
comment: values.comment,
creatorJob: '',
},
});
editing.value = false;
resetForm();
Expand All @@ -55,7 +57,7 @@ async function editComment(documentId: string, commentId: string, values: Schema
return;
}
emit('update:modelValue', response.comment);
comment.value = response.comment;
} catch (e) {
handleGRPCError(e as RpcError);
throw e;
Expand All @@ -74,49 +76,56 @@ async function deleteComment(id: string): Promise<void> {
type: NotificationType.SUCCESS,
});
emit('deleted', props.modelValue);
emits('deleted', comment.value?.id);
} catch (e) {
handleGRPCError(e as RpcError);
throw e;
}
}
function resetForm(): void {
state.comment = props.modelValue.comment;
if (!comment.value) {
return;
}
state.comment = comment.value.comment;
}
onMounted(() => resetForm());
watch(props, () => resetForm());
const canSubmit = ref(true);
const onSubmitThrottle = useThrottleFn(async (event: FormSubmitEvent<Schema>) => {
if (!comment.value) {
return;
}
canSubmit.value = false;
await editComment(props.modelValue.documentId, props.modelValue.id, event.data).finally(() =>
await editComment(comment.value.documentId, comment.value.id, event.data).finally(() =>
useTimeoutFn(() => (canSubmit.value = true), 400),
);
}, 1000);
</script>

<template>
<li class="py-2">
<li v-if="comment" class="py-2">
<div v-if="!editing" class="flex space-x-3">
<div :class="[modelValue.deletedAt ? 'bg-warn-800' : '', 'flex-1 space-y-1']">
<div :class="[comment.deletedAt ? 'bg-warn-800' : '', 'flex-1 space-y-1']">
<div class="flex items-center justify-between">
<div class="flex items-center">
<CitizenInfoPopover :user="modelValue.creator" show-avatar-in-name />
<CitizenInfoPopover :user="comment.creator" show-avatar-in-name />
</div>

<div class="flex flex-1 items-center">
<GenericTime class="ml-2 text-sm" :value="modelValue.createdAt" />
<GenericTime class="ml-2 text-sm" :value="comment.createdAt" />
</div>

<div v-if="modelValue.deletedAt" class="flex flex-1 flex-row items-center justify-center gap-1.5">
<div v-if="comment.deletedAt" class="flex flex-1 flex-row items-center justify-center gap-1.5">
<UIcon name="i-mdi-trash-can" class="size-5 shrink-0" />
<span>{{ $t('common.deleted') }}</span>
</div>

<div v-if="modelValue.creatorId === activeChar?.userId || permissions.includes('superuser')">
<div v-if="comment.creatorId === activeChar?.userId || permissions.includes('superuser')">
<UButton
v-if="can('DocStoreService.PostComment').value"
variant="link"
Expand All @@ -130,15 +139,15 @@ const onSubmitThrottle = useThrottleFn(async (event: FormSubmitEvent<Schema>) =>
icon="i-mdi-trash-can"
@click="
modal.open(ConfirmModal, {
confirm: async () => deleteComment(modelValue.id),
confirm: async () => deleteComment(comment!.id),
})
"
/>
</div>
</div>
<p class="whitespace-pre-line break-words text-sm">
{{ modelValue.comment }}
{{ comment.comment }}
</p>
</div>
</div>
Expand Down
Loading

0 comments on commit 6b1a5ec

Please sign in to comment.