Skip to content

Commit 31f6828

Browse files
committed
allow for data to be anonymous
1 parent 1c4c898 commit 31f6828

8 files changed

Lines changed: 54 additions & 12 deletions

File tree

db/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ model Task {
215215
element Element? @relation(fields: [elementId], references: [id])
216216
autoAssignNew AutoAssignNew @default(NONE)
217217
anonymous Boolean @default(false)
218+
anonymousResponses Boolean @default(false)
218219
}
219220

220221
model TaskLog {

src/pages/projects/[projectId]/tasks/[taskId]/edit.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const EditTask = () => {
5555
milestoneId: task.milestoneId,
5656
autoAssignNew: task.autoAssignNew ?? "NONE",
5757
anonymous: task.anonymous ?? false,
58+
anonymousResponses: task.anonymousResponses ?? false,
5859
tags: Array.isArray(task.tags)
5960
? (task.tags as Tag[]).map((tag) => ({
6061
id: tag.key, // Use 'key' as the ID

src/pages/projects/[projectId]/tasks/new.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const mapTaskToInitialValues = (task: any) => {
2929
if ("startDate" in task && task.startDate) initial.startDate = new Date(task.startDate)
3030
if ("containerId" in task) initial.containerId = task.containerId ?? null
3131
if ("anonymous" in task) initial.anonymous = task.anonymous ?? false
32+
if ("anonymousResponses" in task) initial.anonymousResponses = task.anonymousResponses ?? false
3233

3334
// Map contributors/teams from assignedMembers if present (kept minimal)
3435
if (Array.isArray((task as any).assignedMembers)) {

src/summary/queries/getProjectData.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export default resolver.pipe(resolver.zod(GetProjectData), resolver.authorize(),
5757
status: true,
5858
// needed for anonymization downstream
5959
anonymous: true,
60+
anonymousResponses: true,
6061
milestoneId: true,
6162
// relations on task
6263
milestone: {

src/summary/utils/processProjectData.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,21 @@ export function cleanProjectData(project: any) {
2424
return member
2525
})
2626

27-
// Scrub task fields for anonymous tasks
27+
// Scrub task fields based on anonymous flags
2828
if (Array.isArray(project.tasks)) {
2929
project.tasks = project.tasks.map((task: any) => {
30-
if (task && task.anonymous) {
31-
return {
32-
...task,
33-
name: "Anonymous task",
34-
description: "Anonymous task",
35-
}
30+
if (!task) return task
31+
const scrubbed: any = { ...task }
32+
if (task.anonymous) {
33+
scrubbed.name = "Anonymous task"
34+
scrubbed.description = "Anonymous task"
3635
}
37-
return task
36+
if (task.anonymousResponses) {
37+
scrubbed.taskLogs = Array.isArray(task.taskLogs)
38+
? task.taskLogs.map((log: any) => ({ ...log, metadata: null }))
39+
: task.taskLogs
40+
}
41+
return scrubbed
3842
})
3943
}
4044

src/tasks/components/TaskForm.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,18 +286,18 @@ export function TaskForm<S extends z.ZodType<any, any>>(props: TaskFormProps<S>)
286286
type="string" // 👈 add this line
287287
/>
288288
</div>
289-
{/* Anonymous toggle */}
290-
<div className="w-1/2 mt-4 flex flex-row">
289+
{/* Anonymous toggles */}
290+
<div className="w-1/2 mt-4 flex flex-col gap-3">
291291
<label>
292292
<span className="flex items-center">
293-
Anonymous task{" "}
293+
Hide task identity in project summary
294294
<InformationCircleIcon
295295
className="h-4 w-4 ml-2 text-info stroke-2"
296296
data-tooltip-id="anonymous-info"
297297
/>
298298
<Tooltip
299299
id="anonymous-info"
300-
content="If enabled, task details (instructions, title) will not be shown in the project summary."
300+
content="If enabled, the task name and instructions will be replaced with 'Anonymous task' in the project summary download."
301301
className="z-[1099] ourtooltips"
302302
/>
303303
<Field<boolean> name="anonymous" type="checkbox" initialValue={false}>
@@ -307,6 +307,25 @@ export function TaskForm<S extends z.ZodType<any, any>>(props: TaskFormProps<S>)
307307
</Field>
308308
</span>
309309
</label>
310+
<label>
311+
<span className="flex items-center">
312+
Hide form responses in project summary
313+
<InformationCircleIcon
314+
className="h-4 w-4 ml-2 text-info stroke-2"
315+
data-tooltip-id="anonymous-responses-info"
316+
/>
317+
<Tooltip
318+
id="anonymous-responses-info"
319+
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."
320+
className="z-[1099] ourtooltips"
321+
/>
322+
<Field<boolean> name="anonymousResponses" type="checkbox" initialValue={false}>
323+
{({ input }) => (
324+
<input {...input} type="checkbox" className="toggle toggle-warning ml-4" />
325+
)}
326+
</Field>
327+
</span>
328+
</label>
310329
</div>
311330
</CollapseCard>
312331

src/tasks/components/TaskInformation.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ export const TaskInformation = () => {
4848
<span className="font-semibold">Milestone:</span>{" "}
4949
{task["milestone"] ? task["milestone"]!.name : "No milestone"}
5050
</p>
51+
{task.anonymous && (
52+
<p>
53+
<span className="font-semibold">Anonymous: </span>
54+
<span className="badge badge-warning ml-1">Task identity hidden in project summary</span>
55+
</p>
56+
)}
57+
{task.anonymousResponses && (
58+
<p>
59+
<span className="font-semibold">Anonymous responses: </span>
60+
<span className="badge badge-warning ml-1">Form responses hidden in project summary</span>
61+
</p>
62+
)}
5163
<p>
5264
<span className="font-semibold">Created by: </span>
5365
{pm.users[0].firstName

src/tasks/schemas.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const FormTaskSchema = z
1515
startDate: z.date().optional().nullable(),
1616
autoAssignNew: z.nativeEnum(AutoAssignNew).optional().nullable(),
1717
anonymous: z.boolean(),
18+
anonymousResponses: z.boolean(),
1819
})
1920
.refine(
2021
(data) => {
@@ -44,6 +45,7 @@ export const CreateTaskSchema = z.object({
4445
rolesId: z.array(z.number()).optional().nullable(),
4546
autoAssignNew: z.nativeEnum(AutoAssignNew).optional().nullable(),
4647
anonymous: z.boolean(),
48+
anonymousResponses: z.boolean(),
4749
tags: z
4850
.array(
4951
z.object({
@@ -69,6 +71,7 @@ export const UpdateTaskSchema = z.object({
6971
startDate: z.date().optional().nullable(),
7072
autoAssignNew: z.nativeEnum(AutoAssignNew).optional().nullable(),
7173
anonymous: z.boolean(),
74+
anonymousResponses: z.boolean(),
7275
tags: z
7376
.array(
7477
z.object({

0 commit comments

Comments
 (0)