diff --git a/src/main/scala/gitbucket/core/controller/IssuesController.scala b/src/main/scala/gitbucket/core/controller/IssuesController.scala
index 4d3776e90e..5763f6dc64 100644
--- a/src/main/scala/gitbucket/core/controller/IssuesController.scala
+++ b/src/main/scala/gitbucket/core/controller/IssuesController.scala
@@ -111,7 +111,7 @@ trait IssuesControllerBase extends ControllerBase {
getMilestonesWithIssueCount(repository.owner, repository.name),
getPriorities(repository.owner, repository.name),
getLabels(repository.owner, repository.name),
- getCustomFields(repository.owner, repository.name).filter(_.enableForIssues),
+ getCustomFieldsWithValue(repository.owner, repository.name, issueId.toInt).filter(_._1.enableForIssues),
isIssueEditable(repository),
isIssueManageable(repository),
isIssueCommentManageable(repository),
diff --git a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala
index 87e5ec75e5..879d5347dd 100644
--- a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala
+++ b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala
@@ -135,7 +135,7 @@ trait PullRequestsControllerBase extends ControllerBase {
getMilestonesWithIssueCount(repository.owner, repository.name),
getPriorities(repository.owner, repository.name),
getLabels(repository.owner, repository.name),
- getCustomFields(repository.owner, repository.name).filter(_.enableForPullRequests),
+ getCustomFieldsWithValue(repository.owner, repository.name, issueId).filter(_._1.enableForPullRequests),
isEditable(repository),
isManageable(repository),
hasDeveloperRole(pullreq.requestUserName, pullreq.requestRepositoryName, context.loginAccount),
diff --git a/src/main/scala/gitbucket/core/service/CustomFieldsService.scala b/src/main/scala/gitbucket/core/service/CustomFieldsService.scala
index f222a71cab..aa4f2a719b 100644
--- a/src/main/scala/gitbucket/core/service/CustomFieldsService.scala
+++ b/src/main/scala/gitbucket/core/service/CustomFieldsService.scala
@@ -12,6 +12,17 @@ trait CustomFieldsService {
def getCustomFields(owner: String, repository: String)(implicit s: Session): List[CustomField] =
CustomFields.filter(_.byRepository(owner, repository)).sortBy(_.fieldId asc).list
+ def getCustomFieldsWithValue(owner: String, repository: String, issueId: Int)(
+ implicit s: Session
+ ): List[(CustomField, Option[IssueCustomField])] = {
+ CustomFields
+ .filter(_.byRepository(owner, repository))
+ .joinLeft(IssueCustomFields)
+ .on { case (t1, t2) => t1.fieldId === t2.fieldId && t2.issueId === issueId.bind }
+ .sortBy { case (t1, t2) => t1.fieldId }
+ .list
+ }
+
def getCustomField(owner: String, repository: String, fieldId: Int)(implicit s: Session): Option[CustomField] =
CustomFields.filter(_.byPrimaryKey(owner, repository, fieldId)).firstOption
@@ -72,7 +83,7 @@ trait CustomFieldsService {
value: String
)(implicit s: Session): Unit = {
val customFieldValue = field.fieldType match {
- case "text" =>
+ case "string" =>
Some(
IssueCustomField(
userName = userName,
@@ -85,7 +96,7 @@ trait CustomFieldsService {
dateValue = None
)
)
- case "int" =>
+ case "number" =>
Some(
IssueCustomField(
userName = userName,
diff --git a/src/main/twirl/gitbucket/core/issues/create.scala.html b/src/main/twirl/gitbucket/core/issues/create.scala.html
index f4c9c19b26..35a73fb08e 100644
--- a/src/main/twirl/gitbucket/core/issues/create.scala.html
+++ b/src/main/twirl/gitbucket/core/issues/create.scala.html
@@ -32,7 +32,19 @@
- @gitbucket.core.issues.html.issueinfo(None, Nil, Nil, collaborators, milestones.map(x => (x, 0, 0)), priorities, defaultPriority, labels, customFields, isManageable, repository)
+ @gitbucket.core.issues.html.issueinfo(
+ issue = None,
+ comments = Nil,
+ issueLabels = Nil,
+ collaborators = collaborators,
+ milestones = milestones.map(x => (x, 0, 0)),
+ priorities= priorities,
+ defaultPriority = defaultPriority,
+ labels = labels,
+ customFields = customFields.map((_, None)),
+ isManageable = isManageable,
+ repository = repository
+ )
diff --git a/src/main/twirl/gitbucket/core/issues/issue.scala.html b/src/main/twirl/gitbucket/core/issues/issue.scala.html
index bcccb20f83..087206a5fc 100644
--- a/src/main/twirl/gitbucket/core/issues/issue.scala.html
+++ b/src/main/twirl/gitbucket/core/issues/issue.scala.html
@@ -5,7 +5,7 @@
milestones: List[(gitbucket.core.model.Milestone, Int, Int)],
priorities: List[gitbucket.core.model.Priority],
labels: List[gitbucket.core.model.Label],
- customFields: List[gitbucket.core.model.CustomField],
+ customFields: List[(gitbucket.core.model.CustomField, Option[gitbucket.core.model.IssueCustomField])],
isEditable: Boolean,
isManageable: Boolean,
isCommentManageable: Boolean,
@@ -57,7 +57,19 @@
@gitbucket.core.issues.html.commentform(issue, true, isEditable, isManageable, repository)
- @gitbucket.core.issues.html.issueinfo(Some(issue), comments, issueLabels, collaborators, milestones, priorities, None, labels, customFields, isManageable, repository)
+ @gitbucket.core.issues.html.issueinfo(
+ issue = Some(issue),
+ comments = comments,
+ issueLabels = issueLabels,
+ collaborators = collaborators,
+ milestones = milestones,
+ priorities = priorities,
+ defaultPriority = None,
+ labels = labels,
+ customFields = customFields,
+ isManageable = isManageable,
+ repository = repository
+ )
}
diff --git a/src/main/twirl/gitbucket/core/issues/issueinfo.scala.html b/src/main/twirl/gitbucket/core/issues/issueinfo.scala.html
index 8830166460..ff67c58929 100644
--- a/src/main/twirl/gitbucket/core/issues/issueinfo.scala.html
+++ b/src/main/twirl/gitbucket/core/issues/issueinfo.scala.html
@@ -6,7 +6,7 @@
priorities: List[gitbucket.core.model.Priority],
defaultPriority: Option[gitbucket.core.model.Priority],
labels: List[gitbucket.core.model.Label],
- customFields: List[gitbucket.core.model.CustomField],
+ customFields: List[(gitbucket.core.model.CustomField, Option[gitbucket.core.model.IssueCustomField])],
isManageable: Boolean,
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
@@ -149,22 +149,38 @@
}
-@customFields.map { customField =>
+@customFields.map { case (field, value) =>
diff --git a/src/main/twirl/gitbucket/core/pulls/compare.scala.html b/src/main/twirl/gitbucket/core/pulls/compare.scala.html
index 43f1810303..abcbfb003f 100644
--- a/src/main/twirl/gitbucket/core/pulls/compare.scala.html
+++ b/src/main/twirl/gitbucket/core/pulls/compare.scala.html
@@ -102,7 +102,19 @@
- @gitbucket.core.issues.html.issueinfo(None, Nil, Nil, collaborators, milestones.map((_, 0, 0)), priorities, defaultPriority, labels, customFields, hasOriginWritePermission, repository)
+ @gitbucket.core.issues.html.issueinfo(
+ issue = None,
+ comments = Nil,
+ issueLabels = Nil,
+ collaborators = collaborators,
+ milestones = milestones.map((_, 0, 0)),
+ priorities = priorities,
+ defaultPriority = defaultPriority,
+ labels = labels,
+ customFields = customFields.map((_, None)),
+ isManageable = hasOriginWritePermission,
+ repository = repository
+ )
diff --git a/src/main/twirl/gitbucket/core/pulls/conversation.scala.html b/src/main/twirl/gitbucket/core/pulls/conversation.scala.html
index 53273d28e4..c4b9f4814a 100644
--- a/src/main/twirl/gitbucket/core/pulls/conversation.scala.html
+++ b/src/main/twirl/gitbucket/core/pulls/conversation.scala.html
@@ -8,7 +8,7 @@
milestones: List[(gitbucket.core.model.Milestone, Int, Int)],
priorities: List[gitbucket.core.model.Priority],
labels: List[gitbucket.core.model.Label],
- customFields: List[gitbucket.core.model.CustomField],
+ customFields: List[(gitbucket.core.model.CustomField, Option[gitbucket.core.model.IssueCustomField])],
isEditable: Boolean,
isManageable: Boolean,
isManageableForkedRepository: Boolean,
@@ -51,7 +51,19 @@
}
- @gitbucket.core.issues.html.issueinfo(Some(issue), comments.toList, issueLabels, collaborators, milestones, priorities, None, labels, customFields, isManageable, repository)
+ @gitbucket.core.issues.html.issueinfo(
+ Some(issue),
+ comments.toList,
+ issueLabels,
+ collaborators,
+ milestones,
+ priorities,
+ None,
+ labels,
+ customFields,
+ isManageable,
+ repository
+ )