Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions db/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ model Task {
element Element? @relation(fields: [elementId], references: [id])
autoAssignNew AutoAssignNew @default(NONE)
anonymous Boolean @default(false)
anonymousResponses Boolean @default(false)
}

model TaskLog {
Expand Down
1 change: 1 addition & 0 deletions src/pages/projects/[projectId]/tasks/[taskId]/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const EditTask = () => {
milestoneId: task.milestoneId,
autoAssignNew: task.autoAssignNew ?? "NONE",
anonymous: task.anonymous ?? false,
anonymousResponses: task.anonymousResponses ?? false,
tags: Array.isArray(task.tags)
? (task.tags as Tag[]).map((tag) => ({
id: tag.key, // Use 'key' as the ID
Expand Down
1 change: 1 addition & 0 deletions src/pages/projects/[projectId]/tasks/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const mapTaskToInitialValues = (task: any) => {
if ("startDate" in task && task.startDate) initial.startDate = new Date(task.startDate)
if ("containerId" in task) initial.containerId = task.containerId ?? null
if ("anonymous" in task) initial.anonymous = task.anonymous ?? false
if ("anonymousResponses" in task) initial.anonymousResponses = task.anonymousResponses ?? false

// Map contributors/teams from assignedMembers if present (kept minimal)
if (Array.isArray((task as any).assignedMembers)) {
Expand Down
1 change: 1 addition & 0 deletions src/summary/queries/getProjectData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default resolver.pipe(resolver.zod(GetProjectData), resolver.authorize(),
status: true,
// needed for anonymization downstream
anonymous: true,
anonymousResponses: true,
milestoneId: true,
// relations on task
milestone: {
Expand Down
20 changes: 12 additions & 8 deletions src/summary/utils/processProjectData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,21 @@ export function cleanProjectData(project: any) {
return member
})

// Scrub task fields for anonymous tasks
// Scrub task fields based on anonymous flags
if (Array.isArray(project.tasks)) {
project.tasks = project.tasks.map((task: any) => {
if (task && task.anonymous) {
return {
...task,
name: "Anonymous task",
description: "Anonymous task",
}
if (!task) return task
const scrubbed: any = { ...task }
if (task.anonymous) {
scrubbed.name = "Anonymous task"
scrubbed.description = "Anonymous task"
}
return task
if (task.anonymousResponses) {
scrubbed.taskLogs = Array.isArray(task.taskLogs)
? task.taskLogs.map((log: any) => ({ ...log, metadata: null }))
: task.taskLogs
}
return scrubbed
})
}

Expand Down
27 changes: 23 additions & 4 deletions src/tasks/components/TaskForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,18 @@ export function TaskForm<S extends z.ZodType<any, any>>(props: TaskFormProps<S>)
type="string" // 👈 add this line
/>
</div>
{/* Anonymous toggle */}
<div className="w-1/2 mt-4 flex flex-row">
{/* Anonymous toggles */}
<div className="w-1/2 mt-4 flex flex-col gap-3">
<label>
<span className="flex items-center">
Anonymous task{" "}
Hide task identity in project summary
<InformationCircleIcon
className="h-4 w-4 ml-2 text-info stroke-2"
data-tooltip-id="anonymous-info"
/>
<Tooltip
id="anonymous-info"
content="If enabled, task details (instructions, title) will not be shown in the project summary."
content="If enabled, the task name and instructions will be replaced with 'Anonymous task' in the project summary download."
className="z-[1099] ourtooltips"
/>
<Field<boolean> name="anonymous" type="checkbox" initialValue={false}>
Expand All @@ -307,6 +307,25 @@ export function TaskForm<S extends z.ZodType<any, any>>(props: TaskFormProps<S>)
</Field>
</span>
</label>
<label>
<span className="flex items-center">
Hide form responses in project summary
<InformationCircleIcon
className="h-4 w-4 ml-2 text-info stroke-2"
data-tooltip-id="anonymous-responses-info"
/>
<Tooltip
id="anonymous-responses-info"
content="If enabled, the filled-in form data will be excluded from the project summary. Who completed the task and when will still be tracked."
className="z-[1099] ourtooltips"
/>
<Field<boolean> name="anonymousResponses" type="checkbox" initialValue={false}>
{({ input }) => (
<input {...input} type="checkbox" className="toggle toggle-warning ml-4" />
)}
</Field>
</span>
</label>
</div>
</CollapseCard>

Expand Down
12 changes: 12 additions & 0 deletions src/tasks/components/TaskInformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ export const TaskInformation = () => {
<span className="font-semibold">Milestone:</span>{" "}
{task["milestone"] ? task["milestone"]!.name : "No milestone"}
</p>
{task.anonymous && (
<p>
<span className="font-semibold">Anonymous: </span>
<span className="badge badge-warning ml-1">Task identity hidden in project summary</span>
</p>
)}
{task.anonymousResponses && (
<p>
<span className="font-semibold">Anonymous responses: </span>
<span className="badge badge-warning ml-1">Form responses hidden in project summary</span>
</p>
)}
<p>
<span className="font-semibold">Created by: </span>
{pm.users[0].firstName
Expand Down
3 changes: 3 additions & 0 deletions src/tasks/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const FormTaskSchema = z
startDate: z.date().optional().nullable(),
autoAssignNew: z.nativeEnum(AutoAssignNew).optional().nullable(),
anonymous: z.boolean(),
anonymousResponses: z.boolean(),
})
.refine(
(data) => {
Expand Down Expand Up @@ -44,6 +45,7 @@ export const CreateTaskSchema = z.object({
rolesId: z.array(z.number()).optional().nullable(),
autoAssignNew: z.nativeEnum(AutoAssignNew).optional().nullable(),
anonymous: z.boolean(),
anonymousResponses: z.boolean(),
tags: z
.array(
z.object({
Expand All @@ -69,6 +71,7 @@ export const UpdateTaskSchema = z.object({
startDate: z.date().optional().nullable(),
autoAssignNew: z.nativeEnum(AutoAssignNew).optional().nullable(),
anonymous: z.boolean(),
anonymousResponses: z.boolean(),
tags: z
.array(
z.object({
Expand Down
Loading