Skip to content

Commit

Permalink
Merge pull request #57 from cat-in-136/redmine6-rails7
Browse files Browse the repository at this point in the history
Support for Redmine6 (Rails7)
  • Loading branch information
cat-in-136 authored Dec 1, 2024
2 parents d2fcb00 + a3844a8 commit 2fb3c34
Show file tree
Hide file tree
Showing 15 changed files with 149 additions and 52 deletions.
31 changes: 16 additions & 15 deletions .github/workflows/redmine_plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ jobs:
fail-fast: false
matrix:
mat_env:
- '3.3 redmica/redmica@v3.1.0'
- '3.3 redmica/redmica@v3.0.4'
- '3.2 redmica/redmica@v2.4.2'
- '3.2 redmica/redmica@v2.3.2'
- '3.1 redmica/redmica@v2.2.3'
- '3.0 redmica/redmica@v2.2.3'
- '2.7 redmica/redmica@v2.2.3'
- '3.2 redmine/redmine@5.1.0'
- '3.1 redmine/redmine@5.0.6'
- '3.0 redmine/redmine@5.0.6'
- '3.3 redmine/redmine@6.0.1'
- '3.2 redmine/redmine@5.1.4'
- '3.1 redmine/redmine@5.0.10'
- '3.0 redmine/redmine@5.0.10'
- '2.7 redmine/redmine@4.2.11'
- '2.6 redmine/redmine@4.2.11'
- '2.6 redmine/redmine@4.1.7'
- '2.6 redmine/redmine@4.0.9'
- '2.5 redmine/redmine@4.0.9'
experimental: [false]
include:
- mat_env: '3.2 redmica/redmica@master'
- mat_env: '3.3 redmica/redmica@master'
experimental: true
steps:
- run: |
Expand All @@ -43,11 +44,11 @@ jobs:
ruby-version: ${{ env.RUBY_VERSION }}

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: ./${{ env.PLUGIN_NAME }}
- name: Set up Redmine
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ env.REDMINE_REPOSITORY }}
ref: ${{ env.REDMINE_REF }}
Expand All @@ -56,28 +57,28 @@ jobs:
- name: Copy the plugin files to plugin directory
run: cp -pr ./${{ env.PLUGIN_NAME }} ./redmine/plugins/${{ env.PLUGIN_NAME }}
- name: Create redmine/config/database.yml
uses: DamianReeves/write-file-action@v1.2
uses: DamianReeves/write-file-action@v1.3
with:
path: ./redmine/config/database.yml
contents: |
test:
adapter: sqlite3
database: db/redmine_test.db
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ./redmine/vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('./redmine/**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: uninitialized constant Nokogiri::HTML4 Issue HACK ref. https://qiita.com/Mattani/items/c4bcc95a72b69d1c0489
uses: DamianReeves/write-file-action@v1.2
- name: "'LoadError: cannot load such file -- blankslate' Issue HACK ref. https://www.redmine.org/issues/40802#note-11"
uses: DamianReeves/write-file-action@v1.3
with:
path: ./redmine/Gemfile.local
contents: |
gem 'loofah', '~> 2.20.0'
if: contains(fromJSON('["2.6 redmine/redmine@4.1.7", "2.6 redmine/redmine@4.0.9", "2.5 redmine/redmine@4.0.9"]'), matrix.mat_env)
gem 'builder', '~> 3.2.4'
if: contains(fromJSON('["3.2 redmica/redmica@v2.4.2", "3.2 redmica/redmica@v2.3.2", "3.1 redmica/redmica@v2.2.3", "3.0 redmica/redmica@v2.2.3", "2.7 redmica/redmica@v2.2.3", "2.6 redmine/redmine@4.1.7", "2.6 redmine/redmine@4.0.9", "2.5 redmine/redmine@4.0.9", "2.6 redmine/redmine@4.2.11", "2.7 redmine/redmine@4.2.11"]'), matrix.mat_env)

- name: Before script
run: |
Expand Down
5 changes: 3 additions & 2 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/cat-in

== License

MIT License.
See the 'LICENSE.md' file.
* Codes: MIT License.
* Legacy Icons: famfamfam-silk: {CC-By-2.5}[https://creativecommons.org/licenses/by/2.5/] by Mark James http://www.famfamfam.com/lab/icons/silk/
* Vector Icons: {Tabler Icons}[https://tabler.io/]: MIT License

2 changes: 1 addition & 1 deletion app/controllers/scheduling_polls_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class SchedulingPollsController < ApplicationController
unloadable
unloadable if respond_to?(:unloadable)

before_action :set_scheduling_poll, :only => [:edit, :update, :show, :vote]
before_action :set_scheduling_poll_by_issue_id, :only => [:show_by_issue]
Expand Down
10 changes: 10 additions & 0 deletions app/helpers/scheduling_polls_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,14 @@ def render_date_related_parameter_of_issue(issue)
s.html_safe
end

if defined? IconsHelper # redmine >= 6.0
include IconsHelper
def scheduling_icon_with_label(icon_name, label_text, icon_only: false, size: 18, css_class: nil)
label_classes = ["icon-label"]
label_classes << "hidden" if icon_only
plugin = 'redmine_scheduling_poll'
sprite_icon(icon_name, size: size, css_class: css_class, plugin: plugin) + content_tag(:span, label_text, class: label_classes.join(' '))
end
end

end
4 changes: 2 additions & 2 deletions app/models/scheduling_poll.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class SchedulingPoll < ActiveRecord::Base
unloadable
class SchedulingPoll < (defined?(ApplicationRecord) == 'constant' ? ApplicationRecord : ActiveRecord::Base)
unloadable if respond_to?(:unloadable)

belongs_to :issue
has_many :scheduling_poll_items, :dependent => :destroy
Expand Down
4 changes: 2 additions & 2 deletions app/models/scheduling_poll_item.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class SchedulingPollItem < ActiveRecord::Base
unloadable
class SchedulingPollItem < (defined?(ApplicationRecord) == 'constant' ? ApplicationRecord : ActiveRecord::Base)
unloadable if respond_to?(:unloadable)

belongs_to :scheduling_poll
has_many :scheduling_votes, :dependent => :destroy
Expand Down
4 changes: 2 additions & 2 deletions app/models/scheduling_vote.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class SchedulingVote < ActiveRecord::Base
unloadable
class SchedulingVote < (defined?(ApplicationRecord) == 'constant' ? ApplicationRecord : ActiveRecord::Base)
unloadable if respond_to?(:unloadable)

belongs_to :user
belongs_to :scheduling_poll_item
Expand Down
18 changes: 11 additions & 7 deletions app/views/scheduling_polls/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@
<tfoot>
<tr>
<td colspan="3">
<%= link_to_function l(:label_add_scheduling_poll_item), "scheduling_polls_add_item(\"#{escape_javascript(add_item_tmpl)}\")", :class => 'icon icon-add', :id => 'scheduling_poll_add_item_link' %>
<% if defined? scheduling_icon_with_label %><%# redmine >= 6.0 %>
<%= link_to_function(scheduling_icon_with_label('add', l(:label_add_scheduling_poll_item)),
"scheduling_polls_add_item(\"#{escape_javascript(add_item_tmpl)}\")",
:class => 'icon icon-add', :id => 'scheduling_poll_add_item_link') %>
<% else %>
<%= link_to_function l(:label_add_scheduling_poll_item), "scheduling_polls_add_item(\"#{escape_javascript(add_item_tmpl)}\")", :class => 'icon icon-add', :id => 'scheduling_poll_add_item_link' %>
<% end %>
</td>
</tr>
</tfoot>
Expand All @@ -33,6 +39,7 @@
<%= f.submit l(:label_update_scheduling_poll_items) %>
</div>

<% include_calendar_headers_tags %>
<%= javascript_tag <<EOD
function scheduling_polls_update_date_picker(enable) {
"use strict";
Expand All @@ -42,13 +49,10 @@ function scheduling_polls_update_date_picker(enable) {
enable = ($("form .ui-datepicker-trigger").length > 0)? false : true;
}
if (enable) {
$("form .scheduling_poll_item_text:not([disabled]):not([readonly])").datepicker({
$("form .scheduling_poll_item_text:not([disabled]):not([readonly])").datepicker($.extend(datepickerOptions, {
dateFormat: '#{Setting.plugin_redmine_scheduling_poll["scheduling_poll_item_date_format"]}',
showOn: 'button', buttonImageOnly: true,
buttonImage: '#{path_to_image('/images/calendar.png')}',
showButtonPanel: true, showWeek: true, showOtherMonths: true,
selectOtherMonths: true, changeMonth: true, changeYear: true
});
showOn: 'button', buttonImageOnly: true
}));
} else {
$("form .scheduling_poll_item_text").datepicker("destroy");
}
Expand Down
31 changes: 23 additions & 8 deletions app/views/scheduling_polls/_scheduling_poll_item_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,28 @@
<%= f_item.hidden_field :position, :value => f_item.index %>
</td>
<td class="reorder">
<%= link_to_function image_tag('2uparrow.png', :alt => l(:label_sort_highest), :plugin => 'redmine_scheduling_poll'),
"scheduling_poll_move_item_position(-2, #{f_item.index})", :title => l(:label_sort_highest) %>
<%= link_to_function image_tag('1uparrow.png', :alt => l(:label_sort_higher), :plugin => 'redmine_scheduling_poll'),
"scheduling_poll_move_item_position(-1, #{f_item.index})", :title => l(:label_sort_higher) %>
<%= link_to_function image_tag('1downarrow.png', :alt => l(:label_sort_lower), :plugin => 'redmine_scheduling_poll'),
"scheduling_poll_move_item_position(+1, #{f_item.index})", :title => l(:label_sort_lower) %>
<%= link_to_function image_tag('2downarrow.png', :alt => l(:label_sort_lowest), :plugin => 'redmine_scheduling_poll'),
"scheduling_poll_move_item_position(+2, #{f_item.index})", :title => l(:label_sort_lowest) %>
<% if defined? scheduling_icon_with_label %><%# redmine >= 6.0 %>
<%= link_to_function(scheduling_icon_with_label('arrows-up', l(:label_sort_highest)),
"scheduling_poll_move_item_position(-2, #{f_item.index})", :title => l(:label_sort_highest),
:class => 'icon-only icon-arrows-up') %>
<%= link_to_function(scheduling_icon_with_label('arrow-up', l(:label_sort_higher)),
"scheduling_poll_move_item_position(-1, #{f_item.index})", :title => l(:label_sort_higher),
:class => 'icon-only icon-arrow-up') %>
<%= link_to_function(scheduling_icon_with_label('arrow-down', l(:label_sort_lower)),
"scheduling_poll_move_item_position(+1, #{f_item.index})", :title => l(:label_sort_lower),
:class => 'icon-only icon-arrow-down') %>
<%= link_to_function(scheduling_icon_with_label('arrows-down', l(:label_sort_lowest)),
"scheduling_poll_move_item_position(+2, #{f_item.index})", :title => l(:label_sort_lowest),
:class => 'icon-only icon-arrows-down') %>
<% else %>
<%= link_to_function image_tag('2uparrow.png', :alt => l(:label_sort_highest), :plugin => 'redmine_scheduling_poll'),
"scheduling_poll_move_item_position(-2, #{f_item.index})", :title => l(:label_sort_highest) %>
<%= link_to_function image_tag('1uparrow.png', :alt => l(:label_sort_higher), :plugin => 'redmine_scheduling_poll'),
"scheduling_poll_move_item_position(-1, #{f_item.index})", :title => l(:label_sort_higher) %>
<%= link_to_function image_tag('1downarrow.png', :alt => l(:label_sort_lower), :plugin => 'redmine_scheduling_poll'),
"scheduling_poll_move_item_position(+1, #{f_item.index})", :title => l(:label_sort_lower) %>
<%= link_to_function image_tag('2downarrow.png', :alt => l(:label_sort_lowest), :plugin => 'redmine_scheduling_poll'),
"scheduling_poll_move_item_position(+2, #{f_item.index})", :title => l(:label_sort_lowest) %>
<% end %>
</td>
</tr>
14 changes: 12 additions & 2 deletions app/views/scheduling_polls/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@

<div id="scheduling-poll" class="box">
<div class="contextual">
<%= link_to l(:label_edit_scheduling_poll_items), scheduling_poll_edit_url(@poll), :class => 'icon icon-edit' %>
<% if defined? scheduling_icon_with_label %><%# redmine >= 6.0 %>
<%= link_to(scheduling_icon_with_label('edit', l(:label_edit_scheduling_poll_items)),
scheduling_poll_edit_url(@poll), :class => 'icon icon-edit') %>
<% else %>
<%= link_to l(:label_edit_scheduling_poll_items), scheduling_poll_edit_url(@poll), :class => 'icon icon-edit' %>
<% end %>
</div>
<h3><%= @poll.issue.subject %></h3>

Expand Down Expand Up @@ -59,7 +64,12 @@
</div>
<% if User.current.allowed_to?(:vote_schduling_polls, @poll.issue.project) %>
<div>
<%= link_to_function l(:label_add_comment_with_scheduling_poll_vote), '$("#vote_comment_fields").show();$(this).hide()', :class => 'icon icon-comment' %>
<% if defined? scheduling_icon_with_label %><%# redmine >= 6.0 %>
<%= link_to_function(scheduling_icon_with_label('comment', l(:label_add_comment_with_scheduling_poll_vote)),
'$("#vote_comment_fields").show();$(this).hide()', :class => 'icon icon-comment') %>
<% else %>
<%= link_to_function l(:label_add_comment_with_scheduling_poll_vote), '$("#vote_comment_fields").show();$(this).hide()', :class => 'icon icon-comment' %>
<% end %>
<div id="vote_comment_fields" style="display: none;">
<%= text_area_tag :vote_comment, '', :class => 'wiki-edit' %>
<% if Redmine::VERSION::MAJOR >= 4 %><%# redmine >= 4.0 %>
Expand Down
42 changes: 42 additions & 0 deletions assets/images/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions config/icon_source.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- name: add
svg: circle-plus
- name: edit
svg: edit
- name: comment
svg: message
- name: arrows-up
svg: arrows-up
- name: arrow-up
svg: arrow-up
- name: arrow-down
svg: arrow-down
- name: arrows-down
svg: arrows-down
4 changes: 2 additions & 2 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
require File.expand_path('../lib/redmine_scheduling_poll/hooks', __FILE__)

Redmine::Plugin.register :redmine_scheduling_poll do
requires_redmine :version_or_higher => '4.0.0'
requires_redmine :version_or_higher => '4.2.0'

name 'Scheduling Poll plugin'
author '@cat_in_136'
description 'provide simple polls to scheduling appointments'
version '5.0.0'
version '6.0.0'
url 'https://github.com/cat-in-136/redmine_scheduling_poll'
author_url 'https://github.com/cat-in-136/'

Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/scheduling_polls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
schduling_polls_001:
id: 1
issue_id: 1
created_at: <%= 1.minute.ago.to_s(:db) %>
created_at: <%= 1.minute.ago %>
schduling_polls_002:
id: 2
issue_id: 2
created_at: <%= 1.minute.ago.to_s(:db) %>
created_at: <%= 1.minute.ago %>
14 changes: 7 additions & 7 deletions test/fixtures/scheduling_votes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@ scheduling_vote_001:
user_id: 1
scheduling_poll_item_id: 1
value: 3
created_at: <%= 1.minute.ago.to_s(:db) %>
created_at: <%= 1.minute.ago %>
scheduling_vote_002:
id: 2
user_id: 1
scheduling_poll_item_id: 2
value: 3
created_at: <%= 1.minute.ago.to_s(:db) %>
created_at: <%= 1.minute.ago %>
scheduling_vote_003:
id: 3
user_id: 1
scheduling_poll_item_id: 3
value: 3
created_at: <%= 1.minute.ago.to_s(:db) %>
created_at: <%= 1.minute.ago %>
scheduling_vote_004:
id: 4
user_id: 2
scheduling_poll_item_id: 1
value: 2
created_at: <%= 1.minute.ago.to_s(:db) %>
created_at: <%= 1.minute.ago %>
scheduling_vote_005:
id: 5
user_id: 2
scheduling_poll_item_id: 2
value: 3
created_at: <%= 1.minute.ago.to_s(:db) %>
created_at: <%= 1.minute.ago %>
scheduling_vote_006:
id: 6
user_id: 2
scheduling_poll_item_id: 3
value: 4
created_at: <%= 1.minute.ago.to_s(:db) %>
created_at: <%= 1.minute.ago %>
scheduling_vote_007:
id: 7
user_id: 3
scheduling_poll_item_id: 1
value: 1
created_at: <%= 1.minute.ago.to_s(:db) %>
created_at: <%= 1.minute.ago %>

0 comments on commit 2fb3c34

Please sign in to comment.