Support squad selection when creating issues
This commit is contained in:
@@ -259,19 +259,14 @@ final class ApiClient {
|
|||||||
Models.Issue createIssue(String title, String description, String workspaceId, String projectId,
|
Models.Issue createIssue(String title, String description, String workspaceId, String projectId,
|
||||||
String status, String priority, Models.Assignee assignee, String dueDate,
|
String status, String priority, Models.Assignee assignee, String dueDate,
|
||||||
String parentIssueId) throws Exception {
|
String parentIssueId) throws Exception {
|
||||||
JSONObject body = new JSONObject();
|
return createIssue(title, description, workspaceId, projectId, null, status, priority, assignee, dueDate, parentIssueId);
|
||||||
body.put("title", title);
|
}
|
||||||
body.put("description", description == null || description.isEmpty() ? JSONObject.NULL : description);
|
|
||||||
body.put("workspace_id", workspaceId);
|
Models.Issue createIssue(String title, String description, String workspaceId, String projectId,
|
||||||
if (projectId != null) body.put("project_id", projectId);
|
String teamId, String status, String priority, Models.Assignee assignee, String dueDate,
|
||||||
if (parentIssueId != null && !parentIssueId.isEmpty()) body.put("parent_issue_id", parentIssueId);
|
String parentIssueId) throws Exception {
|
||||||
if (status != null) body.put("status", status);
|
JSONObject body = IssuePayloads.createIssue(title, description, workspaceId, projectId, teamId, status, priority,
|
||||||
if (priority != null) body.put("priority", priority);
|
assignee, dueDate, parentIssueId);
|
||||||
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 new Models.Issue(requestObject("POST", "/api/issues", query(null, "workspace_id", workspaceId), body));
|
return new Models.Issue(requestObject("POST", "/api/issues", query(null, "workspace_id", workspaceId), body));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6856,6 +6856,7 @@ private fun PilotIssueForm(
|
|||||||
var projectIndex by remember(issue?.id, options.projects.size) {
|
var projectIndex by remember(issue?.id, options.projects.size) {
|
||||||
mutableIntStateOf((options.projects.indexOfFirst { it.id == issue?.projectId } + 1).coerceAtLeast(0))
|
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) {
|
var statusIndex by remember(issue?.id) {
|
||||||
mutableIntStateOf(Models.STATUS_VALUES.indexOf(issue?.status ?: "todo").coerceAtLeast(0))
|
mutableIntStateOf(Models.STATUS_VALUES.indexOf(issue?.status ?: "todo").coerceAtLeast(0))
|
||||||
}
|
}
|
||||||
@@ -6943,6 +6944,7 @@ private fun PilotIssueForm(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
val projectId = if (projectIndex == 0) null else options.projects[projectIndex - 1].id
|
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 dueDateText = if (dueDateEnabled) dueDate.trim() else ""
|
||||||
val status = Models.STATUS_VALUES[statusIndex]
|
val status = Models.STATUS_VALUES[statusIndex]
|
||||||
val priority = Models.PRIORITY_VALUES[priorityIndex]
|
val priority = Models.PRIORITY_VALUES[priorityIndex]
|
||||||
@@ -6956,7 +6958,7 @@ private fun PilotIssueForm(
|
|||||||
val result = withContext(Dispatchers.IO) {
|
val result = withContext(Dispatchers.IO) {
|
||||||
runCatching {
|
runCatching {
|
||||||
val saved = if (issue == null) {
|
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 {
|
} else {
|
||||||
api.updateIssue(issue, titleText, description, projectId, status, priority, assignee, dueDateText)
|
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(
|
IssueFormMenuRow(
|
||||||
eyebrow = if (zh) "负责人" else "Assignee",
|
eyebrow = if (zh) "负责人" else "Assignee",
|
||||||
title = assignees[assigneeIndex].name,
|
title = assignees[assigneeIndex].name,
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user