Skip to content

Commit

Permalink
Tweak notification pulldown presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
takezoe committed Jul 25, 2017
1 parent f53e49f commit a1de140
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/main/scala/gitbucket/notifications/model/Watch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ case class Watch(
)

object Watch {
abstract sealed class Notification(val id: String, val name: String)
case object Watching extends Notification("watching", "Watching")
case object NotWatching extends Notification("not_watching", "Not watching")
case object Ignoring extends Notification("ignoring", "Ignoring")
abstract sealed class Notification(val id: String, val name: String, val description: String)
case object Watching extends Notification("watching", "Watching", "Notify all conversations.")
case object NotWatching extends Notification("not_watching", "Not watching", "Notify when participating.")
case object Ignoring extends Notification("ignoring", "Ignoring", "Never notify.")

object Notification {
val values: Seq[Notification] = Seq(Watching, NotWatching, Ignoring)
Expand Down
13 changes: 10 additions & 3 deletions src/main/twirl/gitbucket/notifications/watch.scala.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
@(notification: gitbucket.notifications.model.Watch.Notification,
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
@gitbucket.core.helper.html.dropdown("Notifications"){
@gitbucket.core.helper.html.dropdown(value = notification.name, right = true){
@gitbucket.notifications.model.Watch.Notification.values.map { n =>
<li>
<a href="#" class="watch" data-id="@n.id">
@gitbucket.core.helper.html.checkicon(notification.id == n.id) @n.name
@gitbucket.core.helper.html.checkicon(notification.id == n.id)
<span class="notification-label strong">@n.name</span>
<div class="muted small">@n.description</div>
</a>
</li>
}
}
<script>
$(function(){
$('a.watch').click(function(){
var notification = $(this).data('id');
var selected = $(this);
var notification = selected.data('id');
$.post('@helpers.url(repository)/watch',
{ notification : notification },
function(){
$('a.watch i.octicon-check').removeClass('octicon-check');
$('a.watch[data-id=' + notification + '] i').addClass('octicon-check');

// Update button label
var label = selected.find('span.notification-label').text().trim();
selected.parents('div.btn-group').find('button>span.strong').text(label);
}
);
return false;
Expand Down

0 comments on commit a1de140

Please sign in to comment.