todo_widget: Allow task list title to be set and edited by author.

Users can now name task lists by providing the task list title in the
`/todo` command on the same line. Example: `/todo School Work`. If no
title is provided by the user, "Task list" (which is also the
placeholder) is used as default.

The author of a task list can later edit / update the task list title
in the todo widget, just like the question in the poll widget.

Fixes part of #20213.
This commit is contained in:
N-Shar-ma
2022-07-29 07:55:31 +05:30
committed by Tim Abbott
parent b30eb4c4fc
commit 6df3ad251a
10 changed files with 390 additions and 21 deletions

View File

@@ -29,12 +29,21 @@ const poll_widget_extra_data_schema = z
})
.nullable();
export const todo_widget_extra_data_schema = z
.object({
task_list_title: z.string().optional(),
})
.nullable();
const widget_data_event_schema = z.object({
sender_id: z.number(),
data: z.discriminatedUnion("widget_type", [
z.object({widget_type: z.literal("poll"), extra_data: poll_widget_extra_data_schema}),
z.object({widget_type: z.literal("zform"), extra_data: zform_widget_extra_data_schema}),
z.object({widget_type: z.literal("todo"), extra_data: z.null()}),
z.object({
widget_type: z.literal("todo"),
extra_data: todo_widget_extra_data_schema,
}),
]),
});