diff --git a/app/src/main/java/ai/multica/app/ApiClient.java b/app/src/main/java/ai/multica/app/ApiClient.java index 4e393b6..bfa4642 100644 --- a/app/src/main/java/ai/multica/app/ApiClient.java +++ b/app/src/main/java/ai/multica/app/ApiClient.java @@ -259,19 +259,14 @@ final class ApiClient { Models.Issue createIssue(String title, String description, String workspaceId, String projectId, String status, String priority, Models.Assignee assignee, String dueDate, String parentIssueId) throws Exception { - JSONObject body = new JSONObject(); - body.put("title", title); - body.put("description", description == null || description.isEmpty() ? JSONObject.NULL : description); - body.put("workspace_id", workspaceId); - if (projectId != null) body.put("project_id", projectId); - if (parentIssueId != null && !parentIssueId.isEmpty()) body.put("parent_issue_id", parentIssueId); - if (status != null) body.put("status", status); - if (priority != null) body.put("priority", priority); - if (dueDate != null && !dueDate.isEmpty()) body.put("due_date", dueDate); else body.put("due_date", JSONObject.NULL); - if (assignee != null && assignee.id != null) { - body.put("assignee_id", assignee.id); - body.put("assignee_type", assignee.type); - } + return createIssue(title, description, workspaceId, projectId, null, status, priority, assignee, dueDate, parentIssueId); + } + + Models.Issue createIssue(String title, String description, String workspaceId, String projectId, + String teamId, String status, String priority, Models.Assignee assignee, String dueDate, + String parentIssueId) throws Exception { + JSONObject body = IssuePayloads.createIssue(title, description, workspaceId, projectId, teamId, status, priority, + assignee, dueDate, parentIssueId); return new Models.Issue(requestObject("POST", "/api/issues", query(null, "workspace_id", workspaceId), body)); } diff --git a/app/src/main/java/ai/multica/app/ComposePilotActivity.kt b/app/src/main/java/ai/multica/app/ComposePilotActivity.kt index 5dc419a..12d64a4 100644 --- a/app/src/main/java/ai/multica/app/ComposePilotActivity.kt +++ b/app/src/main/java/ai/multica/app/ComposePilotActivity.kt @@ -6856,6 +6856,7 @@ private fun PilotIssueForm( var projectIndex by remember(issue?.id, options.projects.size) { mutableIntStateOf((options.projects.indexOfFirst { it.id == issue?.projectId } + 1).coerceAtLeast(0)) } + var teamIndex by remember(issue?.id, options.squads.size) { mutableIntStateOf(0) } var statusIndex by remember(issue?.id) { mutableIntStateOf(Models.STATUS_VALUES.indexOf(issue?.status ?: "todo").coerceAtLeast(0)) } @@ -6943,6 +6944,7 @@ private fun PilotIssueForm( return } val projectId = if (projectIndex == 0) null else options.projects[projectIndex - 1].id + val teamId = if (!editing && teamIndex > 0) options.squads[teamIndex - 1].id else null val dueDateText = if (dueDateEnabled) dueDate.trim() else "" val status = Models.STATUS_VALUES[statusIndex] val priority = Models.PRIORITY_VALUES[priorityIndex] @@ -6956,7 +6958,7 @@ private fun PilotIssueForm( val result = withContext(Dispatchers.IO) { runCatching { val saved = if (issue == null) { - api.createIssue(titleText, description, session.workspace.id, projectId, status, priority, assignee, dueDateText, parentIssueId) + api.createIssue(titleText, description, session.workspace.id, projectId, teamId, status, priority, assignee, dueDateText, parentIssueId) } else { api.updateIssue(issue, titleText, description, projectId, status, priority, assignee, dueDateText) } @@ -7185,6 +7187,31 @@ private fun PilotIssueForm( ) }, ) + if (!editing) { + IssueFormMenuRow( + eyebrow = if (zh) "小队" else "Squad", + title = if (teamIndex == 0) { + if (zh) "不选择小队" else "No squad" + } else { + options.squads[teamIndex - 1].name + }, + subtitle = null, + contentDescription = "Issue Form Squad", + options = listOf( + IssueFormMenuOption( + label = if (zh) "不选择小队" else "No squad", + selected = teamIndex == 0, + onClick = { teamIndex = 0 }, + ) + ) + options.squads.mapIndexed { index, squad -> + IssueFormMenuOption( + label = squad.name, + selected = teamIndex == index + 1, + onClick = { teamIndex = index + 1 }, + ) + }, + ) + } IssueFormMenuRow( eyebrow = if (zh) "负责人" else "Assignee", title = assignees[assigneeIndex].name, diff --git a/app/src/main/java/ai/multica/app/IssuePayloads.java b/app/src/main/java/ai/multica/app/IssuePayloads.java new file mode 100644 index 0000000..dc5f21a --- /dev/null +++ b/app/src/main/java/ai/multica/app/IssuePayloads.java @@ -0,0 +1,28 @@ +package ai.multica.app; + +import org.json.JSONObject; + +final class IssuePayloads { + private IssuePayloads() { + } + + static JSONObject createIssue(String title, String description, String workspaceId, String projectId, + String teamId, String status, String priority, Models.Assignee assignee, + String dueDate, String parentIssueId) throws Exception { + JSONObject body = new JSONObject(); + body.put("title", title); + body.put("description", description == null || description.isEmpty() ? JSONObject.NULL : description); + body.put("workspace_id", workspaceId); + if (projectId != null) body.put("project_id", projectId); + if (teamId != null && !teamId.trim().isEmpty()) body.put("team_id", teamId.trim()); + if (parentIssueId != null && !parentIssueId.isEmpty()) body.put("parent_issue_id", parentIssueId); + if (status != null) body.put("status", status); + if (priority != null) body.put("priority", priority); + if (dueDate != null && !dueDate.isEmpty()) body.put("due_date", dueDate); else body.put("due_date", JSONObject.NULL); + if (assignee != null && assignee.id != null) { + body.put("assignee_id", assignee.id); + body.put("assignee_type", assignee.type); + } + return body; + } +}