diff --git a/src/main/scala/app/LabelsController.scala b/src/main/scala/app/LabelsController.scala index 9432031..3dee982 100644 --- a/src/main/scala/app/LabelsController.scala +++ b/src/main/scala/app/LabelsController.scala @@ -3,6 +3,7 @@ import jp.sf.amateras.scalatra.forms._ import service._ import util.WritableRepositoryAuthenticator +import org.scalatra._ class LabelsController extends LabelsControllerBase with LabelsService with RepositoryService with AccountService with WritableRepositoryAuthenticator @@ -12,12 +13,17 @@ case class LabelForm(labelName: String, color: String) - val labelForm = mapping( + val newForm = mapping( "newLabelName" -> trim(label("Label name", text(required, maxlength(100)))), "newColor" -> trim(label("Color", text(required, maxlength(7)))) )(LabelForm.apply) - post("/:owner/:repository/issues/label/new", labelForm)(writableRepository { form => + val editForm = mapping( + "editLabelName" -> trim(label("Label name", text(required, maxlength(100)))), + "editColor" -> trim(label("Color", text(required, maxlength(7)))) + )(LabelForm.apply) + + post("/:owner/:repository/issues/label/new", newForm)(writableRepository { form => val owner = params("owner") val repository = params("repository") @@ -37,4 +43,14 @@ } }) + post("/:owner/:repository/issues/label/:labelId/edit", editForm)(writableRepository { form => + val owner = params("owner") + val repository = params("repository") + val labelId = params("labelId").toInt + +// createLabel(owner, repository, form.labelName, form.color.substring(1)) +// + Ok("label updated.") + }) + } \ No newline at end of file diff --git a/src/main/twirl/issues/labeledit.scala.html b/src/main/twirl/issues/labeledit.scala.html index 27a3f72..d111a33 100644 --- a/src/main/twirl/issues/labeledit.scala.html +++ b/src/main/twirl/issues/labeledit.scala.html @@ -2,7 +2,9 @@ @import context._ @defining((if(label.isEmpty) ("new", 190, 4) else ("edit", 180, 8))){ case (mode, width, margin) =>
-
+ @@ -26,6 +28,10 @@ $('#editLabelForm').click(function(e){ e.stopPropagation(); }); + + $.each($('form[validate=true]'), function(i, form){ + $(form).submit(validate); + }); }