Skip to content

Commit

Permalink
Merge pull request #99 from onozaty/develop/v3.3.0
Browse files Browse the repository at this point in the history
Develop v3.3.0
  • Loading branch information
onozaty authored Jan 17, 2023
2 parents 0cb37b0 + 1ee381d commit d03ffd6
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ bundle exec rake redmine:plugins:migrate RAILS_ENV=production
チケットの入力欄は、トラッカーやステータスを変えると再構成されますが、「Bottom of issue form」を指定しておくと再構成された際に再度実行されるので、入力欄に対する処理はこれを指定すると便利です。
* 「Bottom of issue detail」 : チケットの詳細表示の下部。
* 「Bottom of all pages」 : 全てのページの末尾(HTML body内で一番下の部分)。
* 「Issues context menu」 : チケット一覧のコンテキストメニュー。

該当ページにコードの挿入位置に該当する箇所が無かった場合、コードは埋め込まれません。たとえば、「Path pattern」と「Project pattern」の設定が無く、全ページが対象となっても、「Insertion position」に「Bottom of issue detail」を指定していると、チケットの詳細表示画面でしかコードが実行されないことになります。

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ If the project pattern was set, the code will not be inserted if the current pro
Issue input fields are reconstructed when trackers or statuses are changed. If "Bottom of issue form" is specified, it will be executed again when reconstructed.
* "Bottom of issue detail"
* "Bottom of all pages" (Last in HTML body)
* "Issues context menu"

If there is no part corresponding to the insertion position of the code on the page, the code is not insert.
For example, even if there are no "Path pattern" and "Project pattern" settings and all pages are targeted, if "Bottom of issue detail" is specified for "Insertion position", it will be executed only on the issue detail page.
Expand Down
4 changes: 3 additions & 1 deletion app/models/view_customize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ class ViewCustomize < ActiveRecord::Base
INSERTION_POSITION_HTML_BOTTOM = "html_bottom"
INSERTION_POSITION_ISSUE_FORM = "issue_form"
INSERTION_POSITION_ISSUE_SHOW = "issue_show"
INSERTION_POSITION_ISSUES_CONTEXT_MENU = "issues_context_menu"

@@insertion_positions = {
:label_insertion_position_html_head => INSERTION_POSITION_HTML_HEAD,
:label_insertion_position_issue_form => INSERTION_POSITION_ISSUE_FORM,
:label_insertion_position_issue_show => INSERTION_POSITION_ISSUE_SHOW,
:label_insertion_position_html_bottom => INSERTION_POSITION_HTML_BOTTOM
:label_insertion_position_html_bottom => INSERTION_POSITION_HTML_BOTTOM,
:label_insertion_position_issues_context_menu => INSERTION_POSITION_ISSUES_CONTEXT_MENU
}

def customize_types
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ en:
label_insertion_position_html_bottom: "Bottom of all pages"
label_insertion_position_issue_form: "Bottom of issue form"
label_insertion_position_issue_show: "Bottom of issue detail"
label_insertion_position_issues_context_menu: "Issues context menu"
field_path_pattern: "Path pattern"
field_project_pattern: "Project pattern"
field_insertion_position: "Insertion position"
Expand Down
1 change: 1 addition & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ja:
label_insertion_position_html_bottom: "全ページの末尾"
label_insertion_position_issue_form: "チケット入力欄の下"
label_insertion_position_issue_show: "チケット詳細の下"
label_insertion_position_issues_context_menu: "チケット一覧のコンテキストメニュー"
field_path_pattern: "パスのパターン"
field_project_pattern: "プロジェクトのパターン"
field_insertion_position: "挿入位置"
Expand Down
1 change: 1 addition & 0 deletions config/locales/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ zh-TW:
label_insertion_position_html_bottom: "所有頁面的底部"
label_insertion_position_issue_form: "議題清單底部"
label_insertion_position_issue_show: "議題詳情頁面"
label_insertion_position_issues_context_menu: "議題上下文菜單"
field_path_pattern: "路徑表達式"
field_project_pattern: "專案表達式"
field_insertion_position: "嵌入位置"
Expand Down
1 change: 1 addition & 0 deletions config/locales/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ zh:
label_insertion_position_html_bottom: "所有页面的底部"
label_insertion_position_issue_form: "问题(issue)表单底部"
label_insertion_position_issue_show: "问题(issue)详情页面"
label_insertion_position_issues_context_menu: "问题(issue)上下文菜单"
field_path_pattern: "路径表达式"
field_project_pattern: "项目表达式"
field_insertion_position: "嵌入位置"
Expand Down
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 '3.2.0'
version '3.3.0'
url 'https://github.com/onozaty/redmine-view-customize'
author_url 'https://github.com/onozaty'

Expand Down
4 changes: 4 additions & 0 deletions lib/redmine_view_customize/view_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def view_issues_show_details_bottom(context={})

return html
end

def view_issues_context_menu_end(context={})
return "\n" + create_view_customize_html(context, ViewCustomize::INSERTION_POSITION_ISSUES_CONTEXT_MENU)
end

private

Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/view_customizes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,14 @@ view_customize_009:
customize_type: javascript
comments: comment_009
project_pattern: ""
view_customize_010:
id: 10
path_pattern: ""
code: code_010
is_enabled: true
is_private: false
author_id: 1
insertion_position: issues_context_menu
customize_type: javascript
comments: comment_010
project_pattern: ""
18 changes: 18 additions & 0 deletions test/unit/view_customize_view_hook_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,24 @@ def test_view_layouts_base_body_bottom
assert_equal expected, html
end

def test_view_issues_context_menu_end

User.current = User.find(1)

expected = <<HTML
<!-- view customize id:10 -->
<script type=\"text/javascript\">
//<![CDATA[
code_010
//]]>
</script>
HTML

html = @hook.view_issues_context_menu_end({:request => Request.new("/issues")})
assert_equal expected, html
end

def test_view_issues_form_details_bottom

User.current = User.find(1)
Expand Down

0 comments on commit d03ffd6

Please sign in to comment.