diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-05-01 00:31:43 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-05-01 00:31:43 +0900 |
commit | f1051e1e7e70aa9c9864b3826060397ec508260b (patch) | |
tree | b73b12fa717371ec94a10561685477a6bf06112b | |
parent | fc1a42bdab0d47f22c84dd70f5a9f36ccc7522bb (diff) | |
download | aclog-f1051e1e7e70aa9c9864b3826060397ec508260b.tar.gz |
web: settings/index: refactor
-rw-r--r-- | app/assets/stylesheets/base.scss | 4 | ||||
-rw-r--r-- | app/controllers/settings_controller.rb | 5 | ||||
-rw-r--r-- | app/views/settings/index.html.haml | 14 | ||||
-rw-r--r-- | config/routes.rb | 2 |
4 files changed, 16 insertions, 9 deletions
diff --git a/app/assets/stylesheets/base.scss b/app/assets/stylesheets/base.scss index a97e0bd..6c58c56 100644 --- a/app/assets/stylesheets/base.scss +++ b/app/assets/stylesheets/base.scss @@ -183,3 +183,7 @@ img.loading-image { margin: 30px 0; text-align: center; } + +.checkbox input[type="checkbox"] { + margin: 4px 0 0; +} diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 6e0c375..b58c93c 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -5,7 +5,7 @@ class SettingsController < ApplicationController end def update - @account.update(notification_enabled: params[:notification_enabled] == "true") + @account.update(notification_enabled: !!params[:notification_enabled]) redirect_to action: "index" end @@ -25,7 +25,8 @@ class SettingsController < ApplicationController private def set_account - return redirect_to "/i/login" unless logged_in? + return redirect_to "/i/login?redirect_after_login=" + CGI.escape(url_for(only_path: true)) unless logged_in? + @account = current_user.account end end diff --git a/app/views/settings/index.html.haml b/app/views/settings/index.html.haml index d0a4f53..fb72845 100644 --- a/app/views/settings/index.html.haml +++ b/app/views/settings/index.html.haml @@ -1,12 +1,14 @@ - title "Settings" .container .row - %h1.col-sm-3.col-md-offset-1.setting Settings + .col-sm-3.col-md-offset-1 + .sidebar + %h1 Settings .col-sm-9.col-md-7.col-lg-6 - = form_tag "/i/settings/update", method: :post do + = form_tag settings_update_path, method: "post" do .checkbox - = check_box_tag :notification_enabled, true, @account.notification_enabled - = label_tag :notification_enabled, t("views.settings.enable_notification") + %input{type: "checkbox", name: "notification_enabled", checked: @account.notification_enabled ? "checked" : nil} + %label{for: "notification_enabled"}= t("views.settings.enable_notification") .form-group - = submit_tag "Submit", class: "btn btn-default" - = link_to t("views.settings.confirm_deactivation"), { controller: "settings", action: "confirm_deactivation" }, class: "btn btn-link" + %input.btn.btn-default{type: "submit"} + %a.btn.btn-link{href: url_for(only_path: true, controller: "settings", action: "confirm_deactivation")}= t("views.settings.confirm_deactivation") diff --git a/config/routes.rb b/config/routes.rb index 4558e47..2acd4d3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -14,7 +14,7 @@ Rails.application.routes.draw do post "/i/:id/import" => "tweets#import", as: "import", constraints: { id: /\d+/ } get "/i/settings" => "settings#index", as: "settings" - post "/i/settings/update" => "settings#update" + post "/i/settings/update" => "settings#update", as: "settings_update" get "/i/settings/confirm_deactivation" => "settings#confirm_deactivation" post "/i/settings/deactivate" => "settings#deactivate" |