From b600a3613fa90d5da766fa0330f0c5a1a48ecefb Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Mon, 14 Jul 2025 00:19:35 +0200 Subject: [PATCH] implemented selecting tasks by estimated time --- frontend/src/Components/EstimatedTask.svelte | 27 ++++++++++++++++ .../src/routes/document/EstimateList.svelte | 31 ++++++++++++++----- .../routes/document/PositionSelector.svelte | 6 ++-- frontend/src/routes/document/View.svelte | 2 ++ .../de/srsoftware/umbrella/task/Task.java | 3 +- .../srsoftware/umbrella/task/TaskModule.java | 6 ++-- 6 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 frontend/src/Components/EstimatedTask.svelte diff --git a/frontend/src/Components/EstimatedTask.svelte b/frontend/src/Components/EstimatedTask.svelte new file mode 100644 index 0000000..860a9f7 --- /dev/null +++ b/frontend/src/Components/EstimatedTask.svelte @@ -0,0 +1,27 @@ + + +
+
+ {#if task.estimated_time} + onSelect(task)}> + {task.estimated_time} {t(task.estimated_time != 1 ? 'task.hours' : 'task.hour')} + + {/if} + {task.name} +
+
+ {@html task.description.rendered} +
+ {#if task.children} + + {/if} + +
\ No newline at end of file diff --git a/frontend/src/routes/document/EstimateList.svelte b/frontend/src/routes/document/EstimateList.svelte index 9ed25f8..65a025a 100644 --- a/frontend/src/routes/document/EstimateList.svelte +++ b/frontend/src/routes/document/EstimateList.svelte @@ -1,10 +1,10 @@ + +

{t('task.estimated_times')}

{#if error} {error} {/if} - {#if items} - {#each items as item,id} - onSelect(item)} /> + {#if projects} + {#each projects as project,pid} +
+ {project.name} + {#each project.tasks as task,tid} +
    +
  • + +
  • +
+ {/each} +
{/each} {/if}
\ No newline at end of file diff --git a/frontend/src/routes/document/PositionSelector.svelte b/frontend/src/routes/document/PositionSelector.svelte index 4f46221..48c8a1d 100644 --- a/frontend/src/routes/document/PositionSelector.svelte +++ b/frontend/src/routes/document/PositionSelector.svelte @@ -9,7 +9,7 @@ let select = $state(0); function estimateSelected(estimate){ - onSelect({estimate:estimate}); + onSelect({task:estimate}); close(); } @@ -40,8 +40,8 @@
- - + + {#if select == 0} diff --git a/frontend/src/routes/document/View.svelte b/frontend/src/routes/document/View.svelte index 5ce0acb..e4f2001 100644 --- a/frontend/src/routes/document/View.svelte +++ b/frontend/src/routes/document/View.svelte @@ -64,8 +64,10 @@ } function addPosition(selected){ + console.log(selected); let newPos = {}; if (selected.item) newPos['item']=selected.item.id; + if (selected.task) newPos['task']=selected.task.id; console.log(JSON.stringify({newPos:newPos})); } diff --git a/task/src/main/java/de/srsoftware/umbrella/task/Task.java b/task/src/main/java/de/srsoftware/umbrella/task/Task.java index 92d153e..3a7c2ba 100644 --- a/task/src/main/java/de/srsoftware/umbrella/task/Task.java +++ b/task/src/main/java/de/srsoftware/umbrella/task/Task.java @@ -5,6 +5,7 @@ import static de.srsoftware.tools.Optionals.nullIfEmpty; import static de.srsoftware.umbrella.core.Constants.*; import static de.srsoftware.umbrella.core.Constants.SHOW_CLOSED; import static de.srsoftware.umbrella.core.Constants.STATUS; +import static de.srsoftware.umbrella.core.Util.markdown; import static de.srsoftware.umbrella.task.Constants.*; import de.srsoftware.tools.Mappable; @@ -42,7 +43,7 @@ public record Task(long id, long projectId, Long parentTaskId, String name, Stri map.put(PROJECT_ID, projectId); map.put(PARENT_TASK_ID, parentTaskId); map.put(NAME, name); - map.put(DESCRIPTION, description); + map.put(DESCRIPTION, Map.of(SOURCE,description,RENDERED,markdown(description))); map.put(STATUS, status); map.put(ESTIMATED_TIME, estimatedTime); map.put(START_DATE,start); diff --git a/task/src/main/java/de/srsoftware/umbrella/task/TaskModule.java b/task/src/main/java/de/srsoftware/umbrella/task/TaskModule.java index 9e1be8c..855a484 100644 --- a/task/src/main/java/de/srsoftware/umbrella/task/TaskModule.java +++ b/task/src/main/java/de/srsoftware/umbrella/task/TaskModule.java @@ -73,8 +73,10 @@ public class TaskModule extends BaseHandler { projects.forEach(project -> { var projectMap = new HashMap<>(project.toMap()); var children = tree.values().stream().filter(root -> project.id() == (Long)root.get(PROJECT_ID)).toList(); - projectMap.put(FIELD_TASKS,children); - result.add(projectMap); + if (!children.isEmpty()) { + projectMap.put(FIELD_TASKS, children); + result.add(projectMap); + } }); return sendContent(ex,result); }