diff --git a/src/main/scala/app/LabelsController.scala b/src/main/scala/app/LabelsController.scala index 2ac47fc..3fe8c04 100644 --- a/src/main/scala/app/LabelsController.scala +++ b/src/main/scala/app/LabelsController.scala @@ -24,29 +24,33 @@ "editColor" -> trim(label("Color", text(required, color))) )(LabelForm.apply) - post("/:owner/:repository/issues/label/new", newForm)(collaboratorsOnly { (form, repository) => + get("/:owner/:repository/issues/labels")(collaboratorsOnly { repository => + issues.labels.html.list(getLabels(repository.owner, repository.name), repository, true) // TODO hasWritePermission + }) + + ajaxGet("/:owner/:repository/issues/labels/new")(collaboratorsOnly { repository => + issues.labels.html.edit(None, repository) + }) + + post("/:owner/:repository/issues/labels/new", newForm)(collaboratorsOnly { (form, repository) => createLabel(repository.owner, repository.name, form.labelName, form.color.substring(1)) - redirect(s"/${repository.owner}/${repository.name}/issues") + redirect(s"/${repository.owner}/${repository.name}/issues/labels") }) - ajaxGet("/:owner/:repository/issues/label/edit")(collaboratorsOnly { repository => - issues.labels.html.editlist(getLabels(repository.owner, repository.name), repository) - }) - - ajaxGet("/:owner/:repository/issues/label/:labelId/edit")(collaboratorsOnly { repository => + ajaxGet("/:owner/:repository/issues/labels/:labelId/edit")(collaboratorsOnly { repository => getLabel(repository.owner, repository.name, params("labelId").toInt).map { label => issues.labels.html.edit(Some(label), repository) } getOrElse NotFound() }) - ajaxPost("/:owner/:repository/issues/label/:labelId/edit", editForm)(collaboratorsOnly { (form, repository) => + post("/:owner/:repository/issues/labels/:labelId/edit", editForm)(collaboratorsOnly { (form, repository) => updateLabel(repository.owner, repository.name, params("labelId").toInt, form.labelName, form.color.substring(1)) - issues.labels.html.editlist(getLabels(repository.owner, repository.name), repository) + redirect(s"/${repository.owner}/${repository.name}/issues/labels") }) - ajaxGet("/:owner/:repository/issues/label/:labelId/delete")(collaboratorsOnly { repository => + get("/:owner/:repository/issues/labels/:labelId/delete")(collaboratorsOnly { repository => deleteLabel(repository.owner, repository.name, params("labelId").toInt) - issues.labels.html.editlist(getLabels(repository.owner, repository.name), repository) + redirect(s"/${repository.owner}/${repository.name}/issues/labels") }) /** diff --git a/src/main/twirl/issues/labels/edit.scala.html b/src/main/twirl/issues/labels/edit.scala.html index 649c093..c420b8d 100644 --- a/src/main/twirl/issues/labels/edit.scala.html +++ b/src/main/twirl/issues/labels/edit.scala.html @@ -1,18 +1,21 @@ @(label: Option[model.Label], repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context) @import context._ @import view.helpers._ -@defining((if(label.isEmpty) ("new", 190, 4) else ("edit", 180, 8))){ case (mode, width, margin) => -
-
+@defining(if(label.isEmpty) "new" else "edit"){ mode => +
+ - + -
- +
+
- + + + + @if(mode == "edit"){ } @@ -23,22 +26,15 @@ $('#newColor').colorpicker(); } else { $('#editColor').colorpicker(); - - $('#edit-label-form').submit(function(e){ - $.ajax($(this).attr('action'), { - type: 'POST', - data: $(this).serialize() - }) - .done(function(data){ - $('#label-edit').parent().empty().html(data); - }) - .fail(function(data, status){ - displayErrors($.parseJSON(data.responseText)); - }); - - return false; - }); } + + $.each($('form[validate=true]'), function(i, form){ + $(form).submit(validate); + }); + + $('.label-edit-cancel').click(function(e){ + closeLabelForm(); + }); });
diff --git a/src/main/twirl/issues/labels/editlist.scala.html b/src/main/twirl/issues/labels/editlist.scala.html deleted file mode 100644 index e62b0b6..0000000 --- a/src/main/twirl/issues/labels/editlist.scala.html +++ /dev/null @@ -1,47 +0,0 @@ -@(labels: List[model.Label], repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context) -@import context._ -@import view.helpers._ -
- - -
diff --git a/src/main/twirl/issues/labels/list.scala.html b/src/main/twirl/issues/labels/list.scala.html new file mode 100644 index 0000000..a83464c --- /dev/null +++ b/src/main/twirl/issues/labels/list.scala.html @@ -0,0 +1,100 @@ +@(labels: List[model.Label], + repository: service.RepositoryService.RepositoryInfo, + hasWritePermission: Boolean)(implicit context: app.Context) +@import context._ +@import view.helpers._ +@html.main(s"Labels - ${repository.owner}/${repository.name}"){ + @html.menu("issues", repository){ + @issues.html.tab("labels", hasWritePermission, repository) + + + + + + + + @labels.map { label => + + + + } + @if(labels.isEmpty){ + + + + } +
+ @labels.size labels +
+
+ +
+ x open issues +
+
+ @if(hasWritePermission){ +
+ Edit + Delete +
+ } +
+
+
+ No labels to show. + @if(hasWritePermission){ + Create a new label. + } +
+ } +} + diff --git a/src/main/twirl/issues/tab.scala.html b/src/main/twirl/issues/tab.scala.html index ff68ff9..1f2aa45 100644 --- a/src/main/twirl/issues/tab.scala.html +++ b/src/main/twirl/issues/tab.scala.html @@ -2,10 +2,10 @@ repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context) @import context._ @import view.helpers._ -