Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update plugin to latest Redmine version #10

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
40 changes: 16 additions & 24 deletions app/models/stuff_to_do.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ class StuffToDo < ActiveRecord::Base
belongs_to :user
acts_as_list :scope => :user

named_scope :doing_now, lambda { |user|
{
:conditions => { :user_id => user.id },
:limit => 5,
:order => 'position ASC'
}
scope :doing_now, ->(user) {
where(user_id: user.id).limit(5).order('position ASC')
}

# TODO: Rails bug
Expand All @@ -30,13 +26,8 @@ class StuffToDo < ActiveRecord::Base
#
# http://dev.rubyonrails.org/ticket/7257
#
named_scope :recommended, lambda { |user|
{
:conditions => { :user_id => user.id },
:limit => self.count,
:offset => 5,
:order => 'position ASC'
}
scope :recommended, ->(user) {
where(user_id: user.id).limit(StuffToDo.count).offset(5).order('position ASC')
}

# Filters the issues that are available to be added for a user.
Expand All @@ -53,10 +44,11 @@ def self.available(user, filter=nil)
if filter.is_a?(Project)
potential_stuff_to_do = active_and_visible_projects.sort
else
potential_stuff_to_do = Issue.find(:all,
:include => [:status, :priority, :project],
:conditions => conditions_for_available(filter),
:order => "#{Issue.table_name}.created_on DESC")
potential_stuff_to_do = filter_issues(
Issue.includes(:status, :priority, :project).
order("#{Issue.table_name}.created_on DESC"),
filter
).all
end

stuff_to_do = StuffToDo.find(:all, :conditions => { :user_id => user.id }).collect(&:stuff)
Expand Down Expand Up @@ -113,7 +105,7 @@ def self.remove_stale_assignments(issue)
# Project based ids need to be prefixed with +project+
def self.reorder_list(user, ids)
ids ||= []
id_position_mapping = ids.to_hash
id_position_mapping = Hash[*ids.map{|v| [ids.index(v), v]}.flatten]

issue_ids = {}
project_ids = {}
Expand Down Expand Up @@ -191,18 +183,18 @@ def self.use_setting
USE.index(Setting.plugin_stuff_to_do_plugin['use_as_stuff_to_do'])
end

def self.conditions_for_available(filter_by)
conditions_builder = ARCondition.new(["#{IssueStatus.table_name}.is_closed = ?", false ])
conditions_builder.add(["#{Project.table_name}.status = ?", Project::STATUS_ACTIVE])
def self.filter_issues(dataset, filter_by)
dataset = dataset.where("#{IssueStatus.table_name}.is_closed" => false).
where("#{Project.table_name}.status" => Project::STATUS_ACTIVE)

case
when filter_by.is_a?(User)
conditions_builder.add(["assigned_to_id = ?", filter_by.id])
dataset = dataset.where(assigned_to_id: filter_by.id)
when filter_by.is_a?(IssueStatus), filter_by.is_a?(Enumeration)
table_name = filter_by.class.table_name
conditions_builder.add(["#{table_name}.id = (?)", filter_by.id])
dataset = dataset.where("#{table_name}.id" => filter_by.id)
end

conditions_builder.conditions
dataset
end
end
2 changes: 1 addition & 1 deletion app/views/stuff_to_do/_time_grid.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<div id="logtime" style="display:none;">
<h2><%= l(:label_spent_time) %></h2>

<% labelled_tabular_form_for 'time_entry[]'.to_sym, @time_entry, :url => {}, :html => {:id => 'new-time-entry'} do |f| %>
<% labelled_form_for :'time_entry[]', @time_entry, :url => {}, :html => {:id => 'new-time-entry'} do |f| %>
<%= error_messages_for 'time_entry' %>
<%= back_url_hidden_field_tag %>

Expand Down
31 changes: 12 additions & 19 deletions app/views/stuff_to_do/_time_grid_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
<% form_tag({:action => 'time_grid'}, :id => 'query_form') do %>
<%= form_tag({:action => 'time_grid'}, :id => 'query_form') do %>
<fieldset id="date-range"><legend><%= l(:label_date_range) %></legend>
<%= select_month(@date.month, :prefix => "month", :discard_type => true) %>
<%= select_day(@date.day, :prefix => "day", :discard_type => true) %>
<%= select_year(@date.year, :prefix => "year", :discard_type => true) %>
</fieldset>

<p style="float:right; margin:0px;">
<%= link_to_remote("&#171; #{l(:label_previous)} #{l(:label_week).downcase}",
{:update => "time-grid", :url => { :action => 'time_grid', :date => @date - 7 }},
{:href => url_for(:action => 'time_grid', :date => @date - 7)})
%> |
<%= link_to_remote("#{l(:label_next)} #{l(:label_week).downcase} &#187;",
{:update => "time-grid", :url => { :action => 'time_grid', :date => @date + 7 }},
{:href => url_for(:action => 'time_grid', :date => @date + 7)})
%>
<%= link_to "&#171; #{l(:label_previous)} #{l(:label_week).downcase}".html_safe,
{ action: 'time_grid', date: @date - 7 },
{ class: 'time_grid_change_week' } %> |
<%= link_to "#{l(:label_next)} #{l(:label_week).downcase} &#187;".html_safe,
{ action: 'time_grid', date: @date + 7 },
{ class: 'time_grid_change_week' } %>
</p>

<p class="buttons">
<%= link_to_remote l(:button_apply),
{ :url => { :action => 'time_grid' },
:update => "time-grid",
:with => "Form.serialize('query_form')"
}, :class => 'icon icon-checked' %>

<%= link_to_remote l(:button_clear),
{ :url => { :action => 'time_grid' },
:update => "time-grid",
}, :class => 'icon icon-reload' %>
<%= link_to l(:button_apply), { action: 'time_grid' },
{ class: 'icon icon-checked time-grid-apply-date' } %>

<%= link_to l(:button_clear), { action: 'time_grid' },
{ class: 'icon icon-reload time-grid-reset-date' } %>
</p>
<% end %>

8 changes: 2 additions & 6 deletions app/views/stuff_to_do/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<div class="menu">
<% if User.current.admin? %>
<div class="user">
<% form_tag({ :controller => 'stuff_to_do', :action => 'index'}, :method => :get, :id => 'user_switch' ) do %>
<%= form_tag({ :controller => 'stuff_to_do', :action => 'index'}, :method => :get, :id => 'user_switch' ) do %>
<label for="user_id"><%= l(:stuff_to_do_label_view_user_list) %></label>
<%= collection_select(:user, :id, @users.sort, :id, :name, { }, { :name => 'user_id'}) %>
<% end %>
</div>

<div class="filter">
<% form_tag({}, :id => 'filter_form') do %>
<%= form_tag({}, :id => 'filter_form') do %>
<label for="filter"><%= l(:stuff_to_do_label_filter) %></label>
<%= select_tag("filter", filter_options(@filters, params[:filter])) %>
<% end %>
Expand All @@ -32,12 +32,8 @@

<% content_for :header_tags do %>
<%= stylesheet_link_tag "stuff_to_do.css", :plugin => "stuff_to_do_plugin", :media => 'all' %>
<%= javascript_include_tag 'jquery-1.2.6.min.js', :plugin => 'stuff_to_do_plugin' %>
<%= javascript_include_tag 'ui/ui.core.js', :plugin => 'stuff_to_do_plugin' %>
<%= javascript_include_tag 'ui/ui.sortable.js', :plugin => 'stuff_to_do_plugin' %>
<%= javascript_include_tag 'jquery.contextMenu.js', :plugin => 'stuff_to_do_plugin' %>
<%= javascript_include_tag 'facebox.js', :plugin => 'stuff_to_do_plugin' %>
<%= javascript_tag("jQuery.noConflict();") %>
<%= javascript_include_tag 'stuff-to-do.js', :plugin => 'stuff_to_do_plugin' %>
<%= javascript_tag("var user_id = #{@user.id};") %>
<%= javascript_tag "window._token = '#{form_authenticity_token}'" %>
Expand Down
Loading