diff --git a/src/main/scala/gitbucket/core/model/BasicTemplate.scala b/src/main/scala/gitbucket/core/model/BasicTemplate.scala index c3b8e1b..2ebb28c 100644 --- a/src/main/scala/gitbucket/core/model/BasicTemplate.scala +++ b/src/main/scala/gitbucket/core/model/BasicTemplate.scala @@ -38,6 +38,20 @@ byRepository(owner, repository) && (this.labelName === labelName.bind) } + trait PriorityTemplate extends BasicTemplate { self: Table[_] => + val priorityId = column[Int]("PRIORITY_ID") + val priorityName = column[String]("PRIORITY_NAME") + + def byPriority(owner: String, repository: String, priorityId: Int) = + byRepository(owner, repository) && (this.priorityId === priorityId.bind) + + def byPriority(userName: Rep[String], repositoryName: Rep[String], priorityId: Rep[Int]) = + byRepository(userName, repositoryName) && (this.priorityId === priorityId) + + def byPriority(owner: String, repository: String, priorityName: String) = + byRepository(owner, repository) && (this.priorityName === priorityName.bind) + } + trait MilestoneTemplate extends BasicTemplate { self: Table[_] => val milestoneId = column[Int]("MILESTONE_ID") diff --git a/src/main/scala/gitbucket/core/model/Priorities.scala b/src/main/scala/gitbucket/core/model/Priorities.scala new file mode 100644 index 0000000..a585079 --- /dev/null +++ b/src/main/scala/gitbucket/core/model/Priorities.scala @@ -0,0 +1,39 @@ +package gitbucket.core.model + +trait PriorityComponent extends TemplateComponent { self: Profile => + import profile.api._ + + lazy val Priorities = TableQuery[Priorities] + + class Priorities(tag: Tag) extends Table[Priority](tag, "PRIORITY") with PriorityTemplate { + override val priorityId = column[Int]("PRIORITY_ID", O AutoInc) + override val priorityName = column[String]("PRIORITY_NAME") + val ordering = column[Int]("ORDERING") + val color = column[String]("COLOR") + def * = (userName, repositoryName, priorityId, priorityName, ordering, color) <> (Priority.tupled, Priority.unapply) + + def byPrimaryKey(owner: String, repository: String, priorityId: Int) = byPriority(owner, repository, priorityId) + def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], priorityId: Rep[Int]) = byPriority(userName, repositoryName, priorityId) + } +} + +case class Priority ( + userName: String, + repositoryName: String, + priorityId: Int = 0, + priorityName: String, + ordering: Int = 0, + color: String){ + + val fontColor = { + val r = color.substring(0, 2) + val g = color.substring(2, 4) + val b = color.substring(4, 6) + + if(Integer.parseInt(r, 16) + Integer.parseInt(g, 16) + Integer.parseInt(b, 16) > 408){ + "000000" + } else { + "ffffff" + } + } +} diff --git a/src/main/scala/gitbucket/core/model/Profile.scala b/src/main/scala/gitbucket/core/model/Profile.scala index 332e7ea..876188c 100644 --- a/src/main/scala/gitbucket/core/model/Profile.scala +++ b/src/main/scala/gitbucket/core/model/Profile.scala @@ -47,6 +47,7 @@ with IssueCommentComponent with IssueLabelComponent with LabelComponent + with PriorityComponent with MilestoneComponent with PullRequestComponent with RepositoryComponent