Some fix for the issues page.

This commit is contained in:
takezoe
2013-06-25 11:59:05 +09:00
parent 4f873d9296
commit 554508de9b
4 changed files with 65 additions and 26 deletions

View File

@@ -6,11 +6,11 @@ import service._
import util.{WritableRepositoryAuthenticator, ReadableRepositoryAuthenticator, UsersOnlyAuthenticator} import util.{WritableRepositoryAuthenticator, ReadableRepositoryAuthenticator, UsersOnlyAuthenticator}
class IssuesController extends IssuesControllerBase class IssuesController extends IssuesControllerBase
with IssuesService with RepositoryService with AccountService with LabelsService with IssuesService with RepositoryService with AccountService with LabelsService with MilestonesService
with UsersOnlyAuthenticator with ReadableRepositoryAuthenticator with WritableRepositoryAuthenticator with UsersOnlyAuthenticator with ReadableRepositoryAuthenticator with WritableRepositoryAuthenticator
trait IssuesControllerBase extends ControllerBase { trait IssuesControllerBase extends ControllerBase {
self: IssuesService with RepositoryService with LabelsService self: IssuesService with RepositoryService with LabelsService with MilestonesService
with UsersOnlyAuthenticator with ReadableRepositoryAuthenticator with WritableRepositoryAuthenticator => with UsersOnlyAuthenticator with ReadableRepositoryAuthenticator with WritableRepositoryAuthenticator =>
case class IssueForm(title: String, content: Option[String]) case class IssueForm(title: String, content: Option[String])
@@ -32,13 +32,20 @@ trait IssuesControllerBase extends ControllerBase {
val owner = params("owner") val owner = params("owner")
val repository = params("repository") val repository = params("repository")
getRepository(owner, repository, baseUrl) match {
case None => NotFound()
case Some(r) => {
// search condition // search condition
val closed = params.get("state") collect { val closed = params.get("state") collect {
case "closed" => true case "closed" => true
} getOrElse false } getOrElse false
issues.html.issues(searchIssue(owner, repository, closed), getLabels(owner, repository), issues.html.issues(searchIssue(owner, repository, closed),
getRepository(owner, repository, baseUrl).get) getLabels(owner, repository),
getMilestones(owner, repository).filter(_.closedDate.isEmpty),
r, isWritable(owner, repository, context.loginAccount))
}
}
} }
get("/:owner/:repository/issues/:id"){ get("/:owner/:repository/issues/:id"){

View File

@@ -38,7 +38,7 @@ trait LabelsControllerBase extends ControllerBase {
getRepository(owner, repository, baseUrl) match { getRepository(owner, repository, baseUrl) match {
case None => NotFound() case None => NotFound()
case Some(r) => issues.html.labellist(getLabels(owner, repository), r) case Some(r) => issues.html.labeleditlist(getLabels(owner, repository), r)
} }
}) })
@@ -65,7 +65,7 @@ trait LabelsControllerBase extends ControllerBase {
case None => NotFound() case None => NotFound()
case Some(r) => { case Some(r) => {
updateLabel(owner, repository, labelId, form.labelName, form.color.substring(1)) updateLabel(owner, repository, labelId, form.labelName, form.color.substring(1))
issues.html.labellist(getLabels(owner, repository), r) issues.html.labeleditlist(getLabels(owner, repository), r)
} }
} }
}) })
@@ -79,7 +79,7 @@ trait LabelsControllerBase extends ControllerBase {
case None => NotFound() case None => NotFound()
case Some(r) => { case Some(r) => {
deleteLabel(owner, repository, labelId) deleteLabel(owner, repository, labelId)
issues.html.labellist(getLabels(owner, repository), r) issues.html.labeleditlist(getLabels(owner, repository), r)
} }
} }
}) })

View File

@@ -1,4 +1,4 @@
@(issues: List[model.Issue], labels: List[model.Label], repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context) @(issues: List[model.Issue], labels: List[model.Label], milestones: List[model.Milestone], repository: service.RepositoryService.RepositoryInfo, isWrite: Boolean)(implicit context: app.Context)
@import context._ @import context._
@import view.helpers._ @import view.helpers._
@html.main("Issues - " + repository.owner + "/" + repository.name){ @html.main("Issues - " + repository.owner + "/" + repository.name){
@@ -7,12 +7,40 @@
<div class="row-fluid"> <div class="row-fluid">
<div class="span3"> <div class="span3">
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
<li class="active"><a href="#">Everyone's Issues</a></li> <li class="active">
<li><a href="#">Assigned to you</a></li> <a href="#">
<li><a href="#">Created by you</a></li> <span class="count-right">0</span>
Everyone's Issues
</a>
</li>
@if(loginAccount.isDefined){
<li>
<a href="#">
<span class="count-right">0</span>
Assigned to you
</a>
</li>
<li>
<a href="#">
<span class="count-right">0</span>
Created by you
</a>
</li>
}
</ul> </ul>
<hr/> <hr/>
No milestone selected No milestone selected
<div class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown">
<i class="icon-cog"></i>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
@milestones.map { milestone =>
<li><a href="#">@milestone.title</a></li>
}
</ul>
</div>
<hr/> <hr/>
<strong>Labels</strong> <strong>Labels</strong>
<div> <div>
@@ -30,11 +58,13 @@
</ul> </ul>
</div> </div>
</div> </div>
@if(isWrite){
<hr/> <hr/>
<input type="button" class="btn btn-block" id="manageLabel" data-toggle="button" value="Manage Labels"/> <input type="button" class="btn btn-block" id="manageLabel" data-toggle="button" value="Manage Labels"/>
<br/> <br/>
<strong>New label</strong> <strong>New label</strong>
@labeledit(None, repository) @labeledit(None, repository)
}
</div> </div>
<div class="span9"> <div class="span9">
<div class="pagination pull-right"> <div class="pagination pull-right">
@@ -80,6 +110,7 @@
</div> </div>
</div> </div>
} }
@if(isWrite){
<script> <script>
$(function(){ $(function(){
$('#manageLabel').click(function(){ $('#manageLabel').click(function(){
@@ -96,6 +127,7 @@ $(function(){
}); });
}); });
</script> </script>
}
<style type="text/css"> <style type="text/css">
ul.label-list { ul.label-list {
list-style-type: none; list-style-type: none;

View File

@@ -4,8 +4,8 @@
<ul class="label-list nav nav-pills nav-stacked"> <ul class="label-list nav nav-pills nav-stacked">
@labels.map { label => @labels.map { label =>
<li style="border: 1px solid white;"> <li style="border: 1px solid white;">
<a href="javascript:void(0);" class="label-edit-link" labelId="@label.labelId" labelName="@label.labelName" color="#@label.color"> <a href="javascript:void(0);" class="label-edit-link" data-label-id="@label.labelId">
<span class="count-right"><i class="icon-remove-circle" labelId="@label.labelId"></i></span> <span class="count-right"><i class="icon-remove-circle"></i></span>
<span style="background-color: #@label.color;" class="label-color">&nbsp;&nbsp;</span> <span style="background-color: #@label.color;" class="label-color">&nbsp;&nbsp;</span>
@label.labelName @label.labelName
</a> </a>
@@ -15,8 +15,8 @@
<script> <script>
$('i.icon-remove-circle').click(function(e){ $('i.icon-remove-circle').click(function(e){
e.stopPropagation(); e.stopPropagation();
if(confirm('Delete this label. Are you Sure?')){ if(confirm('Are you sure you want to delete this?')){
$.get('@path/@repository.owner/@repository.name/issues/label/' + $(this).attr('labelId') + '/delete', $.get('@path/@repository.owner/@repository.name/issues/label/' + $(this).parents('a').data('label-id') + '/delete',
function(data){ function(data){
var parent = $('#label-edit').parent(); var parent = $('#label-edit').parent();
$('#label-edit').remove(); $('#label-edit').remove();
@@ -27,10 +27,10 @@
}); });
$('a.label-edit-link').click(function(e){ $('a.label-edit-link').click(function(e){
if($('input[name=editLabelId]').val() != $(this).attr('labelId')){ if($('input[name=editLabelId]').val() != $(this).data('label-id')){
$('#editLabelArea').remove(); $('#editLabelArea').remove();
var element = this; var element = this;
$.get('@path/@repository.owner/@repository.name/issues/label/' + $(this).attr('labelId') + '/edit', $.get('@path/@repository.owner/@repository.name/issues/label/' + $(this).data('label-id') + '/edit',
function(data){ function(data){
$(element).parent().append(data); $(element).parent().append(data);
$('div#label-edit li').css('border', '1px solid white'); $('div#label-edit li').css('border', '1px solid white');