Skip to content

Commit

Permalink
Merge pull request #46 from onozaty/develp/2.4.0
Browse files Browse the repository at this point in the history
Development for 2.4.0
  • Loading branch information
onozaty authored Sep 7, 2019
2 parents 68a0818 + 2963a12 commit 6545f21
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 6 deletions.
9 changes: 8 additions & 1 deletion app/controllers/view_customizes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class ViewCustomizesController < ApplicationController
layout 'admin'

before_action :require_admin
before_action :find_view_customize, :except => [:index, :new, :create]
before_action :find_view_customize, :except => [:index, :new, :create, :update_all]

helper :sort
include SortHelper
Expand Down Expand Up @@ -47,6 +47,13 @@ def update
render :action => 'edit'
end

def update_all
ViewCustomize.update_all(view_customize_params.to_hash)

flash[:notice] = l(:notice_successful_update)
redirect_to view_customizes_path
end

def destroy
@view_customize.destroy
redirect_to view_customizes_path
Expand Down
10 changes: 10 additions & 0 deletions app/views/view_customizes/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,14 @@

</table>

<p class="buttons">
<%= link_to l(:label_disable_all),
view_customizes_path(view_customize: {is_enabled: 0}),
:data => {:confirm => l(:text_are_you_sure)}, :method => :put,
:class => 'icon icon-view_customize-disable' %>
<%= link_to l(:label_enable_all),
view_customizes_path(view_customize: {is_enabled: 1}),
:data => {:confirm => l(:text_are_you_sure)}, :method => :put,
:class => 'icon icon-view_customize-enable' %>
</p>
<% end %>
Binary file added assets/images/disable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/enable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions assets/stylesheets/view_customize.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,11 @@ input#view_customize_comments {
.icon-view_customize {
background-image: url("../images/view_customize.png");
}

.icon-view_customize-disable {
background-image: url("../images/disable.png");
}

.icon-view_customize-enable {
background-image: url("../images/enable.png");
}
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ en:
label_view_customize: "View customize"
label_view_customize_plural: "View customizes"
label_view_customizes_new: "New view customize"
label_disable_all: "Disable all"
label_enable_all: "Enable all"
label_javascript: "JavaScript"
label_css: "CSS"
label_html: "HTML"
Expand Down
4 changes: 3 additions & 1 deletion config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ ja:
label_view_customize: "表示のカスタマイズ"
label_view_customize_plural: "表示のカスタマイズ"
label_view_customizes_new: "新しい表示のカスタマイズ"
label_disable_all: "すべて無効に"
label_enable_all: "すべて有効に"
label_javascript: "JavaScript"
label_css: "CSS"
label_html: "HTML"
label_insertion_position_html_head: "全てのページのヘッダ"
label_insertion_position_html_head: "全ページのヘッダ"
label_insertion_position_issue_form: "チケット入力欄の下"
label_insertion_position_issue_show: "チケット詳細の下"
field_path_pattern: "パスのパターン"
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
# See: http://guides.rubyonrails.org/routing.html
Rails.application.routes.draw do
resources :view_customizes
put :view_customizes, to: 'view_customizes#update_all'
end
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name 'View Customize plugin'
author 'onozaty'
description 'View Customize plugin for Redmine'
version '2.3.0'
version '2.4.0'
url 'https://github.com/onozaty/redmine-view-customize'
author_url 'https://github.com/onozaty'

Expand Down
8 changes: 5 additions & 3 deletions lib/view_customize/view_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module RedmineViewCustomize
class ViewHook < Redmine::Hook::ViewListener
def view_layouts_base_html_head(context={})

path = context[:request].path_info;
path = Redmine::CodesetUtil.replace_invalid_utf8(context[:request].path_info);

html = "\n<!-- [view customize plugin] path:#{path} -->\n"
html << stylesheet_link_tag("view_customize", plugin: "view_customize")
Expand All @@ -17,7 +17,8 @@ def view_layouts_base_html_head(context={})

def view_issues_form_details_bottom(context={})

return create_view_customize_html(context[:request].path_info, ViewCustomize::INSERTION_POSITION_ISSUE_FORM)
path = Redmine::CodesetUtil.replace_invalid_utf8(context[:request].path_info);
return create_view_customize_html(path, ViewCustomize::INSERTION_POSITION_ISSUE_FORM)
end

def view_issues_show_details_bottom(context={})
Expand All @@ -26,7 +27,8 @@ def view_issues_show_details_bottom(context={})
html << "ViewCustomize.context.issue = { id: #{context[:issue].id} };"
html << "\n//]]>\n</script>"

html << create_view_customize_html(context[:request].path_info, ViewCustomize::INSERTION_POSITION_ISSUE_SHOW)
path = Redmine::CodesetUtil.replace_invalid_utf8(context[:request].path_info);
html << create_view_customize_html(path, ViewCustomize::INSERTION_POSITION_ISSUE_SHOW)

return html
end
Expand Down

0 comments on commit 6545f21

Please sign in to comment.