Skip to content

Commit

Permalink
Merge pull request #338 from gtt-project/support-redmine-6
Browse files Browse the repository at this point in the history
Support Redmine 6
  • Loading branch information
dkastl authored Nov 18, 2024
2 parents 15c0439 + 9cdc7b5 commit 4a1a4a8
Show file tree
Hide file tree
Showing 25 changed files with 180 additions and 111 deletions.
27 changes: 14 additions & 13 deletions .github/workflows/test-postgis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ jobs:
strategy:
fail-fast: false
matrix:
redmine_version: [5.0-stable, 5.1-stable, master]
ruby_version: ['3.0', '3.1', '3.2']
db_version: [12-3.4, 16-3.4]
redmine_version: [5.1-stable, 6.0-stable, master]
ruby_version: ['3.1', '3.2', '3.3']
db_version: [13-3.4, 17-3.5]
include:
- system_test: true
redmine_version: 5.1-stable
ruby_version: '3.2'
redmine_version: 6.0-stable
ruby_version: '3.3'
exclude:
- redmine_version: 5.0-stable
ruby_version: '3.2'
- redmine_version: 5.1-stable
ruby_version: '3.3'
- redmine_version: master

services:
Expand Down Expand Up @@ -106,8 +106,9 @@ jobs:
- name: Adjust Gem environment
run: |
case "${{ matrix.redmine_version }}" in
master)
echo "GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION=9.0.1" >> ${GITHUB_ENV}
5.1-stable)
echo "GEM_RGEO_ACTIVERECORD_VERSION=7.0.1" >> ${GITHUB_ENV}
echo "GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION=7.1.1" >> ${GITHUB_ENV}
;;
esac
Expand Down Expand Up @@ -142,11 +143,11 @@ jobs:
GOOGLE_CHROME_OPTS_ARGS: "headless,disable-gpu,no-sandbox,disable-dev-shm-usage"
working-directory: redmine
run: |
bundle exec rake redmine:plugins:test:units NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0"
bundle exec rake redmine:plugins:test:functionals NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0"
bundle exec rake redmine:plugins:test:integration NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0"
bundle exec rails test plugins/redmine_gtt/test/unit
bundle exec rails test plugins/redmine_gtt/test/functional
bundle exec rails test plugins/redmine_gtt/test/integration
if [ ${{ matrix.system_test }} = "true" ]; then
bundle exec rake redmine:plugins:test:system NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0"
bundle exec rails test plugins/redmine_gtt/test/system
fi
- name: Run uninstall test
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ source 'https://rubygems.org'
# Define gem versions with environment variables or default versions
gem_versions = {
pg: ENV['GEM_PG_VERSION'] || '1.5.3',
rgeo: ENV['GEM_RGEO_VERSION'] || '3.0.0',
rgeo_activerecord: ENV['GEM_RGEO_ACTIVERECORD_VERSION'] || '7.0.1',
activerecord_postgis_adapter: ENV['GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION'] || '7.1.1'
rgeo: ENV['GEM_RGEO_VERSION'] || '3.0.1',
rgeo_activerecord: ENV['GEM_RGEO_ACTIVERECORD_VERSION'] || '8.0.0',
activerecord_postgis_adapter: ENV['GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION'] || '10.0.0'
}

gem 'deface'
Expand Down
2 changes: 1 addition & 1 deletion app/models/gtt_map_layer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Map layer model
#
# Configuration is stored as json
class GttMapLayer < ActiveRecord::Base
class GttMapLayer < (defined?(ApplicationRecord) == 'constant' ? ApplicationRecord : ActiveRecord::Base)
self.inheritance_column = 'none'

validates :name, presence: true
Expand Down
2 changes: 1 addition & 1 deletion app/views/gtt_map_layers/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="contextual">
<%= link_to t('map_layer.new'), new_gtt_map_layer_path, :class => 'icon icon-add' %>
<%= link_to (Redmine::VERSION.to_s >= '6.0.0') ? sprite_icon('add', t('map_layer.new')) : t('map_layer.new'), new_gtt_map_layer_path, :class => 'icon icon-add' %>
</div>

<%= title t('map_layer.plural') %>
Expand Down
2 changes: 2 additions & 0 deletions app/views/issues/show.api.rsb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ api.issue do
api.user(:id => journal.user_id, :name => journal.user.name) unless journal.user.nil?
api.notes journal.notes
api.created_on journal.created_on
api.updated_on journal.updated_on
api.updated_by(:id => journal.updated_by.id, :name => journal.updated_by.name) unless journal.updated_by.nil?
api.private_notes journal.private_notes
api.array :details do
journal.visible_details.each do |detail|
Expand Down
1 change: 1 addition & 0 deletions app/views/projects/index.api.rsb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ api.array :projects, api_meta(:total_count => @project_count, :offset => @offset
api.name project.name
api.identifier project.identifier
api.description project.description
api.homepage project.homepage
api.parent(:id => project.parent.id, :name => project.parent.name) if project.parent && project.parent.visible?
api.status project.status
api.is_public project.is_public?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,27 @@
<textarea name="<%= l(:title_geojson_upload) %>" placeholder="<%= l(:placeholder_geojson_upload) %>" class="ui-widget ui-state-default ui-corner-all"></textarea>
<input type="file" id="file-selector" accept=".json,.geojson">
</div>

<%= javascript_include_tag 'main', plugin: 'redmine_gtt' %>
<% geocoder = { enabled: false } %>
<% if Setting.plugin_redmine_gtt['enable_geocoding_on_map'] == 'true' %>
<% geocoder = {
enabled: true,
provider: Setting.plugin_redmine_gtt['default_geocoder_provider'],
options: (JSON.parse(Setting.plugin_redmine_gtt['default_geocoder_options']) rescue {})
} %>
<% end %>
<%= tag.div data: {
lon: Setting.plugin_redmine_gtt['default_map_center_longitude'],
lat: Setting.plugin_redmine_gtt['default_map_center_latitude'],
zoom: Setting.plugin_redmine_gtt['default_map_zoom_level'],
maxzoom: Setting.plugin_redmine_gtt['default_map_maxzoom_level'],
vector_minzoom: Setting.plugin_redmine_gtt['vector_minzoom_level'],
fit_maxzoom: Setting.plugin_redmine_gtt['default_map_fit_maxzoom_level'],
geocoder: geocoder,
plugin_settings: Setting.plugin_redmine_gtt.select { |key, value| key.to_s.match(/^(?!default).+/) },
i18n: l(:gtt_js).to_json.html_safe
}, id: 'gtt-defaults', style: 'display:none' %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%= tag.meta(
name: 'gtt-font-custom-icons',
content: asset_path('plugin_assets/redmine_gtt/custom-icons.woff2')) %>
<%= tag.meta(
name: 'gtt-font-mdi-webfont',
content: asset_path('plugin_assets/redmine_gtt/materialdesignicons-webfont.woff2')) %>
9 changes: 3 additions & 6 deletions app/views/settings/gtt/_general.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<div class="box tabular settings">
<h3><%= l(:select_default_map_settings) %></h3>

<p>
Expand Down Expand Up @@ -41,9 +40,8 @@
:size => 10) %>
</p>

</div>
<hr>

<div class="box tabular settings">
<h3><%= l(:select_edit_geometry_settings) %></h3>

<p>
Expand All @@ -62,9 +60,9 @@
<%= content_tag(:label, l(:label_enable_geojson_upload_on_issue_map)) %>
<%= check_box_tag 'settings[enable_geojson_upload_on_issue_map]', true, @settings[:enable_geojson_upload_on_issue_map] %>
</p>
</div>

<div class="box tabular settings">
<hr>

<h3><%= l(:select_other_gtt_settings) %></h3>

<p>
Expand All @@ -81,4 +79,3 @@
<%= content_tag(:label, l(:label_hide_map_for_invalid_geom)) %>
<%= check_box_tag 'settings[hide_map_for_invalid_geom]', 1, Setting.plugin_redmine_gtt['hide_map_for_invalid_geom'] %>
</p>
</div>
2 changes: 0 additions & 2 deletions app/views/settings/gtt/_geocoder.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<div class="box tabular settings">
<h3><%= l(:select_default_geocoder_settings) %></h3>

<p>
Expand Down Expand Up @@ -27,7 +26,6 @@
:rows => 10,
:cols => 100) %>
</p>
</div>

<script>
document.getElementById('geocoder_load_example').addEventListener('click', (event) => {
Expand Down
11 changes: 7 additions & 4 deletions app/views/settings/gtt/_settings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@
});
}

// Activate tab if it is specified in the URL
document.addEventListener('DOMContentLoaded', function() {

// Activate tab if it is specified in the URL
var tab = getQueryParam('tab');
if (tab) {
activateTab(tab);
}
});

// Apply settings
window.gtt_setting()
// Apply GTT settings
if (typeof window.gtt_setting === 'function') {
window.gtt_setting();
}
});
<% end %>
30 changes: 15 additions & 15 deletions app/views/settings/gtt/_styling.html.erb
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<div class="box tabular settings">
<h3><%= l(:select_default_tracker_icon) %></h3>

<% Tracker.sorted.each do |t| %>
<p>
<%= content_tag :label, t.name %>
<%= select_tag "settings[tracker_#{t.id}]", "<option>#{@settings["tracker_#{t.id}"]}</option>".html_safe %>
<i id="icon_settings_tracker_<%= t.id %>"></i>
</p>
<p>
<%= content_tag :label, t.name %>
<%= select_tag "settings[tracker_#{t.id}]", "<option>#{@settings["tracker_#{t.id}"]}</option>".html_safe %>
<i id="icon_settings_tracker_<%= t.id %>"></i>
</p>
<% end %>
</div>

<div class="box tabular settings">
<hr>

<h3><%= l(:select_default_status_color) %></h3>

<% IssueStatus.sorted.each do |t| %>
<p>
<%= content_tag :label, t.name %>
<%= color_field_tag "settings[status_#{t.id}]", @settings["status_#{t.id}"] %>
</p>
<p>
<%= content_tag :label, t.name %>
<%= color_field_tag "settings[status_#{t.id}]", @settings["status_#{t.id}"] %>
</p>
<% end %>
</div>

<div class="box tabular settings">
<hr>

<h3><%= l(:select_other_style_settings) %></h3>

<p>
<%= content_tag(:label, l(:gtt_settings_vector_minzoom_level)) %>
<%= text_field_tag('settings[vector_minzoom_level]',
@settings['vector_minzoom_level'],
:size => 10 ) %>
</p>
</div>
6 changes: 6 additions & 0 deletions app/views/users/index.api.rsb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ api.array :users, api_meta(:total_count => @user_count, :offset => @offset, :lim
api.passwd_changed_on user.passwd_changed_on
api.avatar_url gravatar_url(user.mail, {rating: nil, size: nil, default: Setting.gravatar_default}) if Setting.gravatar_enabled?
api.twofa_scheme user.twofa_scheme
api.status user.status

if user.geom
api.geojson (params[:format] == "json") ? user.geojson : user.geojson.to_json
else
api.geojson nil
end

api.auth_source do
api.id user.auth_source.id
api.name user.auth_source.name
end if include_in_api_response?('auth_source') && user.auth_source.present?

render_api_custom_values user.visible_custom_field_values, api
end
end
Expand Down
5 changes: 5 additions & 0 deletions app/views/users/show.api.rsb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ api.user do

render_api_custom_values @user.visible_custom_field_values, api

api.auth_source do
api.id @user.auth_source.id
api.name @user.auth_source.name
end if User.current.admin? && include_in_api_response?('auth_source') && @user.auth_source.present?

api.array :groups do |groups|
@user.groups.each do |group|
api.group :id => group.id, :name => group.name
Expand Down
2 changes: 2 additions & 0 deletions config/icon_source.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: gtt-map
svg: map
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ en:
select_edit_geometry_settings: "Set edit geometry settings:"
select_default_geocoder_settings: "Set Geocoder settings:"

select_other_style_settings: "Other style settings"

project_module_gtt: "GTT"
permission_manage_gtt_settings: "Manage GTT settings"
permission_view_gtt_settings: "View GTT settings"
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
to: 'projects#update_gtt_configuration',
as: :update_gtt_configuration

# Todo: check if this route should start with "/assets" for consistency
get '/plugin_assets/redmine_gtt/javascripts/index.js.map', to: 'gtt#map'

scope 'gtt' do
Expand Down
11 changes: 5 additions & 6 deletions init.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# Global Hooks
require File.expand_path('../lib/redmine_gtt/hooks/view_layouts_base_html_head_hook', __FILE__)
require File.expand_path('../lib/redmine_gtt/view_hooks', __FILE__)
require_relative 'lib/redmine_gtt/view_hooks'

Redmine::Plugin.register :redmine_gtt do
name 'Redmine GTT plugin'
author 'Georepublic'
author_url 'https://github.com/georepublic'
url 'https://github.com/gtt-project/redmine_gtt'
description 'Adds location-based task management and maps'
version '5.1.2'
version '6.0.0'

requires_redmine :version_or_higher => '5.0.0'
requires_redmine :version_or_higher => '5.1.0'

project_module :gtt do
permission :manage_gtt_settings, {
Expand Down Expand Up @@ -44,7 +42,8 @@
menu :admin_menu,
:gtt_map_layers,
{ controller: 'gtt_map_layers', action: 'index' },
caption: :'map_layer.plural', html: { class: 'icon icon-gtt-map' }
caption: :'map_layer.plural', html: { class: 'icon icon-gtt-map' },
:icon => 'gtt-map', :plugin => :redmine_gtt
end

# Register MIME Types
Expand Down
45 changes: 0 additions & 45 deletions lib/redmine_gtt/hooks/view_layouts_base_html_head_hook.rb

This file was deleted.

9 changes: 6 additions & 3 deletions lib/redmine_gtt/view_hooks.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

module RedmineGtt
class ViewHooks < Redmine::Hook::ViewListener
include ActionView::Context

# Render partials in various views
render_on :view_account_left_bottom,
partial: 'redmine_gtt/hooks/view_account_left_bottom'

Expand All @@ -14,8 +15,10 @@ class ViewHooks < Redmine::Hook::ViewListener
render_on :view_issues_form_details_top,
partial: 'redmine_gtt/hooks/view_issues_form_details_top'

render_on :view_layouts_base_html_head,
partial: 'redmine_gtt/hooks/view_layouts_base_html_head'

render_on :view_layouts_base_body_bottom,
partial: 'redmine_gtt/hooks/view_layouts_base_body_bottom'

end
end
Loading

0 comments on commit 4a1a4a8

Please sign in to comment.