Display the message after settings updating is completed.

This commit is contained in:
takezoe
2013-07-09 21:33:46 +09:00
parent b3c3bf51ba
commit 0ed6a96781
2 changed files with 11 additions and 3 deletions

View File

@@ -5,11 +5,12 @@ import util.Directory._
import util.{UsersAuthenticator, OwnerAuthenticator} import util.{UsersAuthenticator, OwnerAuthenticator}
import jp.sf.amateras.scalatra.forms._ import jp.sf.amateras.scalatra.forms._
import org.apache.commons.io.FileUtils import org.apache.commons.io.FileUtils
import org.scalatra.FlashMapSupport
class SettingsController extends SettingsControllerBase class SettingsController extends SettingsControllerBase
with RepositoryService with AccountService with OwnerAuthenticator with UsersAuthenticator with RepositoryService with AccountService with OwnerAuthenticator with UsersAuthenticator
trait SettingsControllerBase extends ControllerBase { trait SettingsControllerBase extends ControllerBase with FlashMapSupport {
self: RepositoryService with AccountService with OwnerAuthenticator with UsersAuthenticator => self: RepositoryService with AccountService with OwnerAuthenticator with UsersAuthenticator =>
case class OptionsForm(description: Option[String], defaultBranch: String, isPrivate: Boolean) case class OptionsForm(description: Option[String], defaultBranch: String, isPrivate: Boolean)
@@ -37,7 +38,7 @@ trait SettingsControllerBase extends ControllerBase {
* Display the Options page. * Display the Options page.
*/ */
get("/:owner/:repository/settings/options")(ownerOnly { get("/:owner/:repository/settings/options")(ownerOnly {
settings.html.options(_) settings.html.options(_, flash.get("info"))
}) })
/** /**
@@ -45,6 +46,7 @@ trait SettingsControllerBase extends ControllerBase {
*/ */
post("/:owner/:repository/settings/options", optionsForm)(ownerOnly { (form, repository) => post("/:owner/:repository/settings/options", optionsForm)(ownerOnly { (form, repository) =>
saveRepositoryOptions(repository.owner, repository.name, form.description, form.defaultBranch, form.isPrivate) saveRepositoryOptions(repository.owner, repository.name, form.description, form.defaultBranch, form.isPrivate)
flash += "info" -> "Settings updated."
redirect("/%s/%s/settings/options".format(repository.owner, repository.name)) redirect("/%s/%s/settings/options".format(repository.owner, repository.name))
}) })

View File

@@ -1,9 +1,15 @@
@(repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context) @(repository: service.RepositoryService.RepositoryInfo, info: Option[Any])(implicit context: app.Context)
@import context._ @import context._
@import view.helpers._ @import view.helpers._
@html.main("Settings"){ @html.main("Settings"){
@html.header("settings", repository) @html.header("settings", repository)
@menu("options", repository){ @menu("options", repository){
@if(info.isDefined){
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
@info
</div>
}
<form id="form" method="post" action="@url(repository)/settings/options" validate="true"> <form id="form" method="post" action="@url(repository)/settings/options" validate="true">
<div class="box"> <div class="box">
<div class="box-header">Settings</div> <div class="box-header">Settings</div>