Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ ViewCustomize = {
]
},
"issue": {
"id": 1
"id": 1,
"author": {"id": 2, "name": "John Smith"},
"lastUpdatedBy": {"id": 1, "name": "Redmine Admin"}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ ViewCustomize = {
]
},
"issue": {
"id": 1
"id": 1,
"author": {"id": 2, "name": "John Smith"},
"lastUpdatedBy": {"id": 1, "name": "Redmine Admin"}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Vagrant.configure("2") do |config|
config.vm.box = "onozaty/redmine-4.1"
config.vm.box = "onozaty/redmine-5.0"
config.vm.network "private_network", ip: "192.168.33.10"

config.vm.synced_folder ".", "/var/lib/redmine/plugins/view_customize", create: true, mount_options: ['dmode=755','fmode=655']
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.1.0'
version '3.2.0'
url 'https://github.com/onozaty/redmine-view-customize'
author_url 'https://github.com/onozaty'

Expand Down
17 changes: 16 additions & 1 deletion lib/redmine_view_customize/view_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,23 @@ def view_issues_form_details_bottom(context={})

def view_issues_show_details_bottom(context={})

issue = {
"id" => context[:issue].id,
"author" => {
"id" => context[:issue].author.id,
"name" => context[:issue].author.name
}
}

if context[:issue].last_updated_by.present?
issue["lastUpdatedBy"] = {
"id" => context[:issue].last_updated_by.id,
"name" => context[:issue].last_updated_by.name
}
end

html = "\n<script type=\"text/javascript\">\n//<![CDATA[\n"
html << "ViewCustomize.context.issue = { id: #{context[:issue].id} };"
html << "ViewCustomize.context.issue = #{issue.to_json};"
html << "\n//]]>\n</script>\n"

html << create_view_customize_html(context, ViewCustomize::INSERTION_POSITION_ISSUE_SHOW)
Expand Down
31 changes: 27 additions & 4 deletions test/unit/view_customize_view_hook_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class ViewCustomizeViewHookTest < ActiveSupport::TestCase
fixtures :projects, :users, :email_addresses, :user_preferences, :members, :member_roles, :roles,
:issues, :custom_fields, :custom_fields_projects, :custom_values,
:issues, :journals, :custom_fields, :custom_fields_projects, :custom_values,
:view_customizes

class Request
Expand Down Expand Up @@ -133,13 +133,13 @@ def test_view_issues_form_details_bottom
def test_view_issues_show_details_bottom

User.current = User.find(1)
issue = Issue.find(1)
issue = Issue.find(4)

expected = <<HTML

<script type=\"text/javascript\">
//<![CDATA[
ViewCustomize.context.issue = { id: 1 };
ViewCustomize.context.issue = {\"id\":4,\"author\":{\"id\":2,\"name\":\"John Smith\"}};
//]]>
</script>
<!-- view customize id:8 -->
Expand All @@ -148,7 +148,30 @@ def test_view_issues_show_details_bottom
</style>
HTML

html = @hook.view_issues_show_details_bottom({:request => Request.new("/issues/1"), :issue => issue, :project => @project_onlinestore})
html = @hook.view_issues_show_details_bottom({:request => Request.new("/issues/4"), :issue => issue, :project => @project_onlinestore})
assert_equal expected, html

end

def test_view_issues_show_details_bottom_with_journals

User.current = User.find(1)
issue = Issue.find(6)

expected = <<HTML

<script type=\"text/javascript\">
//<![CDATA[
ViewCustomize.context.issue = {\"id\":6,\"author\":{\"id\":2,\"name\":\"John Smith\"},\"lastUpdatedBy\":{\"id\":1,\"name\":\"Redmine Admin\"}};
//]]>
</script>
<!-- view customize id:8 -->
<style type=\"text/css\">
code_008
</style>
HTML

html = @hook.view_issues_show_details_bottom({:request => Request.new("/issues/6"), :issue => issue, :project => @project_onlinestore})
assert_equal expected, html

end
Expand Down