diff --git a/src/cmd/webui/task/mod.rs b/src/cmd/webui/task/mod.rs index 366b31e1270850f2b593e17905fbf569b8c5f535..cd91412f6ee2ac0d8c3cbe884cfa06747898cd1c 100644 --- a/src/cmd/webui/task/mod.rs +++ b/src/cmd/webui/task/mod.rs @@ -94,6 +94,13 @@ pub(in crate::cmd::webui) async fn task_handler( .collect(), }; + let edit_heading = format!("Edit {}", task_view.short_id); + let edit_form_action = format!( + "/projects/{}/tasks/{}", + store.project_name(), + task_view.full_id + ); + Ok(TaskTemplate { all_projects, active_project: Some(name), @@ -102,6 +109,8 @@ pub(in crate::cmd::webui) async fn task_handler( blockers_open, blockers_resolved, subtasks, + edit_heading, + edit_form_action, }) }) .await; diff --git a/src/cmd/webui/task/views.rs b/src/cmd/webui/task/views.rs index b80fd5de0164ab9438bc2c85621ec791ae499fb9..9974112cd45e7d2baa23f9b29ea7d6c1b9f9402e 100644 --- a/src/cmd/webui/task/views.rs +++ b/src/cmd/webui/task/views.rs @@ -46,4 +46,8 @@ pub(super) struct TaskTemplate { pub(super) blockers_open: Vec, pub(super) blockers_resolved: Vec, pub(super) subtasks: Vec, + /// Pre-built heading for the edit dialog, e.g. "Edit td-XXXXXXX". + pub(super) edit_heading: String, + /// Pre-built form action URL for the edit dialog. + pub(super) edit_form_action: String, } diff --git a/templates/base.html b/templates/base.html index ffbd74d3fbed08d2d024264e0501aa2ba18065eb..5f6a1bb8f7d61f0d5f90cbcabdcba8d95f203d65 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,3 +1,4 @@ +{% import "macros.html" as macros %} @@ -54,71 +55,7 @@ - - -
-
-

New task

-
-
-
- - -
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
+ {% call macros::task_form_dialog("dlg-new-task", "New task", "", "Create", "create", all_projects, active_project, "nt", "", "", "task", "medium", "medium", "", "") %}{% endcall %} diff --git a/templates/macros.html b/templates/macros.html index 464a499139d68eb357352f06fa208815ebcdac30..f2f8b45473aa359092b3f223ad3ce9ecbc618fb5 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -132,3 +132,77 @@ {% endif %} {% endif %} {% endmacro %} + +{% macro task_form_dialog(dialog_id, heading, form_action, submit_label, mode, all_projects, active_project, prefix, title, description, task_type, priority, effort, parent, labels) %} + +
+
+

{{ heading }}

+
+
+ {% if mode == "create" %} +
+ + +
+ {% endif %} + + +
+
+ + +
+
+ + +
+
+ + +
+
+ {% if mode == "create" %} + + {% endif %} + + {% if mode == "edit" %} + + {% endif %} +
+
+ + +
+
+
+{% endmacro %} diff --git a/templates/task.html b/templates/task.html index cc78037fe744f4692342bd7bd694af36a7ffe5d6..acc386588ba6cc31b886cefc15d238bd5fed7b94 100644 --- a/templates/task.html +++ b/templates/task.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% import "macros.html" as macros %} {% block title %}{{ task.title }} — td{% endblock %} @@ -188,57 +189,5 @@ {% endif %} - - -
-
-

Edit {{ task.short_id }}

-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
+{% call macros::task_form_dialog("dlg-edit-task", edit_heading, edit_form_action, "Save", "edit", all_projects, active_project, "edit", task.title, task.description_raw, task.task_type, task.priority, task.effort, task.parent_id, "") %}{% endcall %} {% endblock %}