Skip to content

Commit

Permalink
fix: jobs get colleague labels perms issue
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 da9ab32 commit 0858265
Show file tree
Hide file tree
Showing 23 changed files with 2,407 additions and 2,422 deletions.
11 changes: 11 additions & 0 deletions app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ export default defineAppConfig({
},
},
card: {
header: {
padding: 'px-2 py-3 sm:px-4',
},
body: {
padding: 'px-2 py-3 sm:px-4',
},
footer: {
padding: 'px-2 py-3 sm:px-4',
},
Expand All @@ -147,6 +153,11 @@ export default defineAppConfig({
},
},
},
page: {
grid: {
wrapper: 'gap-4',
},
},
},

popover: {
Expand Down
2 changes: 1 addition & 1 deletion app/components/calendar/entry/EntryCreateOrUpdateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import DataErrorBlock from '~/components/partials/data/DataErrorBlock.vue';
import DataNoDataBlock from '~/components/partials/data/DataNoDataBlock.vue';
import DataPendingBlock from '~/components/partials/data/DataPendingBlock.vue';
import DatePickerPopoverClient from '~/components/partials/DatePickerPopover.client.vue';
import TiptapEditor from '~/components/partials/TiptapEditor.vue';
import TiptapEditor from '~/components/partials/editor/TiptapEditor.vue';
import { useCalendarStore } from '~/store/calendar';
import { useCompletorStore } from '~/store/completor';
import { AccessLevel } from '~~/gen/ts/resources/calendar/access';
Expand Down
2 changes: 1 addition & 1 deletion app/components/documents/DocumentCommentEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useNotificatorStore } from '~/store/notificator';
import type { Comment } from '~~/gen/ts/resources/documents/comment';
import { NotificationType } from '~~/gen/ts/resources/notifications/notifications';
import HTMLContent from '../partials/content/HTMLContent.vue';
import TiptapEditor from '../partials/TiptapEditor.vue';
import TiptapEditor from '../partials/editor/TiptapEditor.vue';
const props = defineProps<{
modelValue?: Comment;
Expand Down
2 changes: 1 addition & 1 deletion app/components/documents/DocumentComments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useNotificatorStore } from '~/store/notificator';
import type { Comment } from '~~/gen/ts/resources/documents/comment';
import { NotificationType } from '~~/gen/ts/resources/notifications/notifications';
import type { GetCommentsResponse } from '~~/gen/ts/services/docstore/docstore';
import TiptapEditor from '../partials/TiptapEditor.vue';
import TiptapEditor from '../partials/editor/TiptapEditor.vue';
const props = withDefaults(
defineProps<{
Expand Down
2 changes: 1 addition & 1 deletion app/components/documents/DocumentEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type { CreateDocumentRequest, UpdateDocumentRequest } from '~~/gen/ts/ser
import { markerFallbackIcon, markerIcons } from '../livemap/helpers';
import AccessManager from '../partials/access/AccessManager.vue';
import { enumToAccessLevelEnums } from '../partials/access/helpers';
import TiptapEditor from '../partials/TiptapEditor.vue';
import TiptapEditor from '../partials/editor/TiptapEditor.vue';
const props = defineProps<{
documentId?: string;
Expand Down
2 changes: 1 addition & 1 deletion app/components/documents/templates/TemplateEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import TemplateSchemaEditor, { type SchemaEditorValue } from '~/components/docum
import { zWorkflow, type ObjectSpecsValue } from '~/components/documents/templates/types';
import ColorPickerTW from '~/components/partials/ColorPickerTW.vue';
import IconSelectMenu from '~/components/partials/IconSelectMenu.vue';
import TiptapEditor from '~/components/partials/TiptapEditor.vue';
import AccessManager from '~/components/partials/access/AccessManager.vue';
import { enumToAccessLevelEnums, type AccessType } from '~/components/partials/access/helpers';
import TiptapEditor from '~/components/partials/editor/TiptapEditor.vue';
import { useAuthStore } from '~/store/auth';
import { useCompletorStore } from '~/store/completor';
import { useNotificatorStore } from '~/store/notificator';
Expand Down
20 changes: 16 additions & 4 deletions app/components/jobs/colleagues/ColleaguesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ function updateAbsenceDates(value: { userId: number; absenceBegin?: Timestamp; a
}
}
function toggleLabelInSearch(label: Label): void {
const idx = query.labels.findIndex((l) => l.id === label.id);
if (idx > -1) {
query.labels.splice(idx, 1);
} else {
query.labels.push(label);
}
}
const columns = [
{
key: 'name',
Expand Down Expand Up @@ -452,7 +461,7 @@ defineShortcuts({
<div v-else class="relative flex-1 overflow-x-auto">
<UPageGrid
:ui="{
wrapper: 'grid grid-cols-1 p-4 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4',
wrapper: 'grid grid-cols-1 p-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6',
}"
>
<UPageCard v-for="colleague in data?.colleagues" :key="colleague.userId">
Expand Down Expand Up @@ -508,18 +517,20 @@ defineShortcuts({
{{ $t('common.none', [$t('common.label', 2)]) }}
</span>
<div v-else class="flex max-w-full flex-row flex-wrap gap-1">
<UBadge
<UButton
v-for="label in colleague.props?.labels?.list"
:key="label.name"
:style="{ backgroundColor: label.color }"
class="justify-between gap-2"
:class="
isColourBright(hexToRgb(label.color, RGBBlack)!) ? '!text-black' : '!text-white'
"
size="sm"
size="xs"
:ui="{ padding: { xs: 'px-2 py-1' } }"
@click="toggleLabelInSearch(label)"
>
{{ label.name }}
</UBadge>
</UButton>
</div>
</div>

Expand Down Expand Up @@ -573,6 +584,7 @@ defineShortcuts({
:label="$t('common.show')"
icon="i-mdi-eye"
block
truncate
:to="{
name: 'jobs-colleagues-id-info',
params: { id: colleague.userId ?? 0 },
Expand Down
2 changes: 1 addition & 1 deletion app/components/mailer/EmailSettingsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { FormSubmitEvent } from '#ui/types';
import { z } from 'zod';
import { useMailerStore } from '~/store/mailer';
import { AccessLevel } from '~~/gen/ts/resources/mailer/access';
import TiptapEditor from '../partials/TiptapEditor.vue';
import TiptapEditor from '../partials/editor/TiptapEditor.vue';
import { canAccess } from './helpers';
withDefaults(
Expand Down
2 changes: 1 addition & 1 deletion app/components/mailer/MailerThread.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { AccessLevel } from '~~/gen/ts/resources/mailer/access';
import { NotificationType } from '~~/gen/ts/resources/notifications/notifications';
import ConfirmModal from '../partials/ConfirmModal.vue';
import HTMLContent from '../partials/content/HTMLContent.vue';
import TiptapEditor from '../partials/editor/TiptapEditor.vue';
import GenericTime from '../partials/elements/GenericTime.vue';
import Pagination from '../partials/Pagination.vue';
import TiptapEditor from '../partials/TiptapEditor.vue';
import EmailInfoPopover from './EmailInfoPopover.vue';
import { canAccess, generateResponseTitle } from './helpers';
import TemplateSelector from './TemplateSelector.vue';
Expand Down
2 changes: 1 addition & 1 deletion app/components/mailer/TemplateEditForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useNotificatorStore } from '~/store/notificator';
import type { Template } from '~~/gen/ts/resources/mailer/template';
import { NotificationType } from '~~/gen/ts/resources/notifications/notifications';
import type { CreateOrUpdateTemplateRequest } from '~~/gen/ts/services/mailer/mailer';
import TiptapEditor from '../partials/TiptapEditor.vue';
import TiptapEditor from '../partials/editor/TiptapEditor.vue';
const props = defineProps<{
template?: Template;
Expand Down
2 changes: 1 addition & 1 deletion app/components/mailer/TemplatesModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ListTemplatesResponse } from '~~/gen/ts/services/mailer/mailer';
import DataErrorBlock from '../partials/data/DataErrorBlock.vue';
import DataNoDataBlock from '../partials/data/DataNoDataBlock.vue';
import DataPendingBlock from '../partials/data/DataPendingBlock.vue';
import TiptapEditor from '../partials/TiptapEditor.vue';
import TiptapEditor from '../partials/editor/TiptapEditor.vue';
import { canAccess } from './helpers';
import TemplateEditForm from './TemplateEditForm.vue';
Expand Down
2 changes: 1 addition & 1 deletion app/components/mailer/ThreadCreateOrUpdateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { z } from 'zod';
import { useMailerStore } from '~/store/mailer';
import { useNotificatorStore } from '~/store/notificator';
import { NotificationType } from '~~/gen/ts/resources/notifications/notifications';
import TiptapEditor from '../partials/TiptapEditor.vue';
import TiptapEditor from '../partials/editor/TiptapEditor.vue';
import TemplateSelector from './TemplateSelector.vue';
import { defaultEmptyContent } from './helpers';
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions app/components/partials/editor/TiptapEditorImageModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script lang="ts" setup>
// TODO
</script>

<template>
<div>
<!-- TODO -->
</div>
</template>
2 changes: 1 addition & 1 deletion app/components/qualifications/QualificationEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type {
} from '~~/gen/ts/services/qualifications/qualifications';
import AccessManager from '../partials/access/AccessManager.vue';
import { enumToAccessLevelEnums, type AccessType } from '../partials/access/helpers';
import TiptapEditor from '../partials/TiptapEditor.vue';
import TiptapEditor from '../partials/editor/TiptapEditor.vue';
import ExamEditor from './exam/ExamEditor.vue';
const props = defineProps<{
Expand Down
2 changes: 1 addition & 1 deletion app/components/wiki/PageEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AccessLevel } from '~~/gen/ts/resources/wiki/access';
import type { Page, PageShort } from '~~/gen/ts/resources/wiki/page';
import AccessManager from '../partials/access/AccessManager.vue';
import { enumToAccessLevelEnums } from '../partials/access/helpers';
import TiptapEditor from '../partials/TiptapEditor.vue';
import TiptapEditor from '../partials/editor/TiptapEditor.vue';
const props = defineProps<{
modelValue?: Page | undefined;
Expand Down
85 changes: 19 additions & 66 deletions gen/go/proto/services/jobs/colleagues.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,36 +120,14 @@ func (s *Server) ListColleagues(ctx context.Context, req *ListColleaguesRequest)
SELECT(
jet.COUNT(tUser.ID).AS("datacount.totalcount"),
).
OPTIMIZER_HINTS(jet.OptimizerHint("idx_users_firstname_lastname_fulltext"))

if (slices.Contains(types, "Labels") || userInfo.SuperUser) && len(req.LabelIds) > 0 {
countStmt = countStmt.
FROM(
tUser.
LEFT_JOIN(tJobsUserProps,
tJobsUserProps.UserID.EQ(tUser.ID).
AND(tUser.Job.EQ(jet.String(userInfo.Job))),
).
INNER_JOIN(tUserLabels,
tUserLabels.UserID.EQ(tUser.ID).
AND(tUserLabels.Job.EQ(jet.String(userInfo.Job))),
).
LEFT_JOIN(tJobLabels,
tJobLabels.ID.EQ(tUserLabels.LabelID),
),
)
} else {
countStmt = countStmt.
FROM(
tUser.
LEFT_JOIN(tJobsUserProps,
tJobsUserProps.UserID.EQ(tUser.ID).
AND(tUser.Job.EQ(jet.String(userInfo.Job))),
),
)
}

countStmt = countStmt.
OPTIMIZER_HINTS(jet.OptimizerHint("idx_users_firstname_lastname_fulltext")).
FROM(
tUser.
LEFT_JOIN(tJobsUserProps,
tJobsUserProps.UserID.EQ(tUser.ID).
AND(tUser.Job.EQ(jet.String(userInfo.Job))),
),
).
WHERE(condition)

var count database.DataCount
Expand Down Expand Up @@ -213,42 +191,17 @@ func (s *Server) ListColleagues(ctx context.Context, req *ListColleaguesRequest)
tJobsUserProps.NamePrefix,
tJobsUserProps.NameSuffix,
).
OPTIMIZER_HINTS(jet.OptimizerHint("idx_users_firstname_lastname_fulltext"))

if (slices.Contains(types, "Labels") || userInfo.SuperUser) && len(req.LabelIds) > 0 {
stmt = stmt.
FROM(
tUser.
LEFT_JOIN(tUserProps,
tUserProps.UserID.EQ(tUser.ID),
).
LEFT_JOIN(tJobsUserProps,
tJobsUserProps.UserID.EQ(tUser.ID).
AND(tJobsUserProps.Job.EQ(jet.String(userInfo.Job))),
).
INNER_JOIN(tUserLabels,
tUserLabels.UserID.EQ(tUser.ID).
AND(tUserLabels.Job.EQ(jet.String(userInfo.Job))),
).
LEFT_JOIN(tJobLabels,
tJobLabels.ID.EQ(tUserLabels.LabelID),
),
)
} else {
stmt = stmt.
FROM(
tUser.
LEFT_JOIN(tUserProps,
tUserProps.UserID.EQ(tUser.ID),
).
LEFT_JOIN(tJobsUserProps,
tJobsUserProps.UserID.EQ(tUser.ID).
AND(tJobsUserProps.Job.EQ(jet.String(userInfo.Job))),
),
)
}

stmt = stmt.
OPTIMIZER_HINTS(jet.OptimizerHint("idx_users_firstname_lastname_fulltext")).
FROM(
tUser.
LEFT_JOIN(tUserProps,
tUserProps.UserID.EQ(tUser.ID),
).
LEFT_JOIN(tJobsUserProps,
tJobsUserProps.UserID.EQ(tUser.ID).
AND(tJobsUserProps.Job.EQ(jet.String(userInfo.Job))),
),
).
WHERE(condition).
OFFSET(req.Pagination.Offset).
GROUP_BY(tUser.ID).
Expand Down
4 changes: 2 additions & 2 deletions gen/go/proto/services/jobs/jobs_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/go/proto/services/jobs/service_perms.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0858265

Please sign in to comment.