Skip to content

Commit

Permalink
fix: delete/restore buttons and fix wrong default access type
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Trost <[email protected]>
  • Loading branch information
galexrt committed Dec 22, 2024
1 parent e845503 commit c3af720
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 27 deletions.
12 changes: 3 additions & 9 deletions app/components/documents/DocumentView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -403,21 +403,15 @@ defineShortcuts({
"
block
class="flex-1 flex-col"
:color="!doc.deletedAt ? 'red' : undefined"
:color="!doc.deletedAt ? 'red' : 'green'"
:icon="!doc.deletedAt ? 'i-mdi-trash-can' : 'i-mdi-restore'"
:label="!doc.deletedAt ? $t('common.delete') : $t('common.restore')"
@click="
modal.open(ConfirmModal, {
confirm: async () => deleteDocument(documentId),
})
"
>
<template v-if="!doc.deletedAt">
{{ $t('common.delete') }}
</template>
<template v-else>
{{ $t('common.restore') }}
</template>
</UButton>
/>
</div>
</template>
</UDashboardToolbar>
Expand Down
2 changes: 0 additions & 2 deletions app/components/jobs/timeclock/TimeclockList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ const {
async function listTimeclockEntries(): Promise<ListTimeclockResponse> {
try {
console.log('TEST1');
if (!isBefore(query.date.start, query.date.end)) {
query.date.start = query.mode > TimeclockMode.DAILY ? subWeeks(query.date.end, 1) : query.date.start;
}
Expand Down Expand Up @@ -148,7 +147,6 @@ async function listTimeclockEntries(): Promise<ListTimeclockResponse> {
const call = getGRPCJobsTimeclockClient().listTimeclock(req);
const { response } = await call;
console.log('TEST2', response);
return response;
} catch (e) {
Expand Down
10 changes: 7 additions & 3 deletions app/components/mailer/MailerThread.vue
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,14 @@ const onSubmitThrottle = useThrottleFn(async (event: FormSubmitEvent<Schema>) =>
<UDivider>
<GenericTime :value="message.createdAt" type="short" />

<UTooltip v-if="isSuperuser" :text="$t('common.delete')" square class="ml-2">
<UTooltip
v-if="isSuperuser"
:text="!message.deletedAt ? $t('common.delete') : $t('common.restore')"
class="ml-2"
>
<UButton
icon="i-mdi-trash-can-outline"
color="red"
:color="!message.deletedAt ? 'red' : 'green'"
:icon="!message.deletedAt ? 'i-mdi-trash-can' : 'i-mdi-restore'"
variant="ghost"
size="xs"
@click="
Expand Down
2 changes: 1 addition & 1 deletion app/components/partials/access/AccessManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ watch(usersAccess, setFromPropsUsers);
watch(qualificationsAccess, setFromPropsQualifications);
function addEntry(): void {
let idx = aTypes.value.findIndex((at) => at.name === props.defaultAccessType);
let idx = aTypes.value.findIndex((at) => at.type === props.defaultAccessType);
if (idx === -1) {
idx = aTypes.value.length - 1;
}
Expand Down
9 changes: 4 additions & 5 deletions app/components/qualifications/QualificationView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,15 @@ const accordionItems = computed(() =>

<UButton
v-if="can('QualificationsService.DeleteQualification').value && canDo.delete"
icon="i-mdi-trash-can"
color="red"
:color="!qualification.deletedAt ? 'red' : 'green'"
:icon="!qualification.deletedAt ? 'i-mdi-trash-can' : 'i-mdi-restore'"
:label="!qualification.deletedAt ? $t('common.delete') : $t('common.restore')"
@click="
modal.open(ConfirmModal, {
confirm: async () => deleteQualification(qualification!.id),
})
"
>
{{ $t('common.delete') }}
</UButton>
/>
</div>
</template>
</UDashboardToolbar>
Expand Down
6 changes: 3 additions & 3 deletions app/components/wiki/PageView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ const accordionItems = computed(() =>
can('WikiService.DeletePage').value &&
checkPageAccess(page.access, page.meta.creator, AccessLevel.OWNER)
"
:text="$t('common.delete')"
:text="!page.meta.deletedAt ? $t('common.delete') : $t('common.restore')"
>
<UButton
color="red"
icon="i-mdi-trash-can"
:color="!page.meta.deletedAt ? 'red' : 'green'"
:icon="!page.meta.deletedAt ? 'i-mdi-trash-can' : 'i-mdi-restore'"
@click="
modal.open(ConfirmModal, {
confirm: async () => page && deletePage(page.id),
Expand Down
9 changes: 6 additions & 3 deletions app/pages/mail/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,13 @@ onBeforeMount(async () => {
/>
</UTooltip>

<UTooltip v-if="isSuperuser" :text="$t('common.delete')">
<UTooltip
v-if="isSuperuser"
:text="!selectedThread.deletedAt ? $t('common.delete') : $t('common.restore')"
>
<UButton
icon="i-mdi-trash-can-outline"
color="red"
:color="!selectedThread.deletedAt ? 'red' : 'green'"
:icon="!selectedThread.deletedAt ? 'i-mdi-trash-can-outline' : 'i-mdi-restore'"
variant="ghost"
@click="
modal.open(ConfirmModal, {
Expand Down
7 changes: 6 additions & 1 deletion gen/go/proto/services/mailer/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,11 +626,16 @@ func (s *Server) DeleteEmail(ctx context.Context, req *DeleteEmailRequest) (*Del
req.Id,
)

deletedAtTime := jet.CURRENT_TIMESTAMP()
if email != nil && email.DeletedAt != nil && userInfo.SuperUser {
deletedAtTime = jet.TimestampExp(jet.NULL)
}

tEmails := table.FivenetMailerEmails
stmt := tEmails.
UPDATE().
SET(
tEmails.DeletedAt.SET(jet.CURRENT_TIMESTAMP()),
tEmails.DeletedAt.SET(deletedAtTime),
).
WHERE(jet.AND(
tEmails.ID.EQ(jet.Uint64(req.Id)),
Expand Down
1 change: 1 addition & 0 deletions gen/go/proto/services/mailer/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ func (s *Server) DeleteMessage(ctx context.Context, req *DeleteMessageRequest) (
deletedAtTime = jet.TimestampExp(jet.NULL)
}

tMessages := table.FivenetMailerMessages
stmt := tMessages.
UPDATE(
tMessages.DeletedAt,
Expand Down
1 change: 1 addition & 0 deletions gen/go/proto/services/mailer/thread.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ func (s *Server) DeleteThread(ctx context.Context, req *DeleteThreadRequest) (*D
deletedAtTime = jet.TimestampExp(jet.NULL)
}

tThreads := table.FivenetMailerThreads
stmt := tThreads.
UPDATE(
tThreads.DeletedAt,
Expand Down
1 change: 1 addition & 0 deletions gen/go/proto/services/qualifications/qualifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ func (s *Server) DeleteQualification(ctx context.Context, req *DeleteQualificati
deletedAtTime = jet.TimestampExp(jet.NULL)
}

tQuali := table.FivenetQualifications
stmt := tQuali.
UPDATE(
tQuali.DeletedAt,
Expand Down

0 comments on commit c3af720

Please sign in to comment.