Skip to content

Commit

Permalink
Merge pull request #5 from evolvingweb/redmine-5-compatibility
Browse files Browse the repository at this point in the history
Redmine 5 compatibility
  • Loading branch information
burak-ikiler-ew authored May 22, 2024
2 parents 07479c4 + f0e1d00 commit ed3c521
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 47 deletions.
38 changes: 0 additions & 38 deletions app/helpers/issues_controller_helper.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,46 @@
<% regex_find = '/\B'+Setting.plugin_redmine_mentions['trigger']+'(\w*)$/i'%>
<% regex_find = '/\B'+'@'+'(\w*)$/i'%>
<% if @project %>
<% users = @project.users.to_a.delete_if{|u| (u.type != 'User' || u.mail.empty?)}%>
<% else %>
<% users = User.active.to_a.delete_if{|u| (u.type != 'User' || u.mail.empty?)}%>
<% end %>
<% users_regex = users.collect{|u| "#{Setting.plugin_redmine_mentions['trigger']}#{u.login}"}.join('|')%>
<% users_regex = users.collect{|u| "#{'@'}#{u.login}"}.join('|')%>
<% regex_highlight = '/\B('+users_regex+')\b/g' %>
<% mapping = {} %>
<% journals = Journal.where("journalized_type = 'issue' AND journalized_id = :id", {id: @issue.id}) %>
<% journals.each do |journal| %>
<% details = JournalDetail.where("journal_id = :id", {id: journal.id}) %>
<% assignee = nil %>
<% status = nil %>
<% details.each do |detail| %>
<% if detail.prop_key == 'status_id' %>
<% status = detail.value %>
<% end %>
<% if detail.prop_key == 'assigned_to_id' %>
<% assignee = detail.value %>
<% end %>
<% end %>
<% if assignee && status %>
<% if !mapping.key?(assignee) %>
<% mapping[assignee] = [] %>
<% end %>
<% unless mapping[assignee].include? status %>
<% mapping[assignee].push(status) %>
<% end %>
<% end %>
<% end %>
<% listing = {} %>
<% IssueStatus.order("position").each { |status| listing[status.id] = "#{status.name}" } %>

<script>
var mentions = <%= users.collect{|u| "#{u.id}-#{u.login}"}.to_json.html_safe %>;
var id = 0;
var user = '';

var usersMapping = <%= self.map_users_to_states(users, @issue) %>;
var statuses = <%= self.status_listing %>;
var usersMapping = <%= mapping.to_json.html_safe %>;
var statuses = <%= listing.to_json.html_safe %>;

window.setInterval(function(){
var text = $('#issue_notes').val();
Expand Down
9 changes: 5 additions & 4 deletions init.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
require_dependency 'redmine_mentions_suggestions'

Rails.configuration.to_prepare do
require_dependency 'redmine_mentions_suggestions'
end
Redmine::Plugin.register :redmine_mentions_suggestions do
name 'Redmine Mentions Suggestions plugin'
author 'Evolving Web'
description 'Suggest assignee based on note text.'
version '0.0.1'
version '0.0.2'
url 'https://github.com/evolvingweb/redmine_mentions_suggestions'
author_url 'https://evolvingweb.ca'
end


3 changes: 2 additions & 1 deletion lib/redmine_mentions_suggestions.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Rails.configuration.to_prepare do

IssuesController.send :helper, IssuesControllerHelper
require_dependency 'redmine_mentions_suggestions/hooks'
end
module RedmineMentionsSuggestions
end

0 comments on commit ed3c521

Please sign in to comment.