Skip to content

Commit ca21d46

Browse files
authored
Merge pull request #48 from onozaty/feature/45-disable_all_cutomizes
#45 Disable all customizes
2 parents 3437b2f + 5ea5182 commit ca21d46

File tree

8 files changed

+32
-2
lines changed

8 files changed

+32
-2
lines changed

app/controllers/view_customizes_controller.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class ViewCustomizesController < ApplicationController
22
layout 'admin'
33

44
before_action :require_admin
5-
before_action :find_view_customize, :except => [:index, :new, :create]
5+
before_action :find_view_customize, :except => [:index, :new, :create, :update_all]
66

77
helper :sort
88
include SortHelper
@@ -47,6 +47,13 @@ def update
4747
render :action => 'edit'
4848
end
4949

50+
def update_all
51+
ViewCustomize.update_all(view_customize_params.to_hash)
52+
53+
flash[:notice] = l(:notice_successful_update)
54+
redirect_to view_customizes_path
55+
end
56+
5057
def destroy
5158
@view_customize.destroy
5259
redirect_to view_customizes_path

app/views/view_customizes/index.html.erb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,14 @@
3737

3838
</table>
3939

40+
<p class="buttons">
41+
<%= link_to l(:label_disable_all),
42+
view_customizes_path(view_customize: {is_enabled: false}),
43+
:data => {:confirm => l(:text_are_you_sure)}, :method => :put,
44+
:class => 'icon icon-view_customize-disable' %>
45+
<%= link_to l(:label_enable_all),
46+
view_customizes_path(view_customize: {is_enabled: true}),
47+
:data => {:confirm => l(:text_are_you_sure)}, :method => :put,
48+
:class => 'icon icon-view_customize-enable' %>
49+
</p>
4050
<% end %>

assets/images/disable.png

587 Bytes
Loading

assets/images/enable.png

781 Bytes
Loading

assets/stylesheets/view_customize.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,11 @@ input#view_customize_comments {
6161
.icon-view_customize {
6262
background-image: url("../images/view_customize.png");
6363
}
64+
65+
.icon-view_customize-disable {
66+
background-image: url("../images/disable.png");
67+
}
68+
69+
.icon-view_customize-enable {
70+
background-image: url("../images/enable.png");
71+
}

config/locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ en:
33
label_view_customize: "View customize"
44
label_view_customize_plural: "View customizes"
55
label_view_customizes_new: "New view customize"
6+
label_disable_all: "Disable all"
7+
label_enable_all: "Enable all"
68
label_javascript: "JavaScript"
79
label_css: "CSS"
810
label_html: "HTML"

config/locales/ja.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ ja:
22
label_view_customize: "表示のカスタマイズ"
33
label_view_customize_plural: "表示のカスタマイズ"
44
label_view_customizes_new: "新しい表示のカスタマイズ"
5+
label_disable_all: "すべて無効に"
6+
label_enable_all: "すべて有効に"
57
label_javascript: "JavaScript"
68
label_css: "CSS"
79
label_html: "HTML"
8-
label_insertion_position_html_head: "全てのページのヘッダ"
10+
label_insertion_position_html_head: "全ページのヘッダ"
911
label_insertion_position_issue_form: "チケット入力欄の下"
1012
label_insertion_position_issue_show: "チケット詳細の下"
1113
field_path_pattern: "パスのパターン"

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
# See: http://guides.rubyonrails.org/routing.html
33
Rails.application.routes.draw do
44
resources :view_customizes
5+
put :view_customizes, to: 'view_customizes#update_all'
56
end

0 commit comments

Comments
 (0)