mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Let user choose columns and sort order of issue lists on "My page" (#1565).
git-svn-id: http://svn.redmine.org/redmine/trunk@16400 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
b878a427f2
commit
8c7898bb5d
@ -27,6 +27,7 @@ class MyController < ApplicationController
|
|||||||
helper :issues
|
helper :issues
|
||||||
helper :users
|
helper :users
|
||||||
helper :custom_fields
|
helper :custom_fields
|
||||||
|
helper :queries
|
||||||
|
|
||||||
def index
|
def index
|
||||||
page
|
page
|
||||||
|
|||||||
@ -44,16 +44,17 @@ module MyHelper
|
|||||||
|
|
||||||
# Renders a single block content
|
# Renders a single block content
|
||||||
def render_block_content(block, user)
|
def render_block_content(block, user)
|
||||||
unless Redmine::MyPage.blocks.key?(block)
|
unless block_definition = Redmine::MyPage.blocks[block]
|
||||||
Rails.logger.warn("Unknown block \"#{block}\" found in #{user.login} (id=#{user.id}) preferences")
|
Rails.logger.warn("Unknown block \"#{block}\" found in #{user.login} (id=#{user.id}) preferences")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
settings = user.pref.my_page_settings(block)
|
settings = user.pref.my_page_settings(block)
|
||||||
|
partial = block_definition[:partial]
|
||||||
begin
|
begin
|
||||||
render(:partial => "my/blocks/#{block}", :locals => {:user => user, :settings => settings})
|
render(:partial => partial, :locals => {:user => user, :settings => settings, :block => block})
|
||||||
rescue ActionView::MissingTemplate
|
rescue ActionView::MissingTemplate
|
||||||
Rails.logger.warn("Template missing for block \"#{block}\" found in #{user.login} (id=#{user.id}) preferences")
|
Rails.logger.warn("Partial \"#{partial}\" missing for block \"#{block}\" found in #{user.login} (id=#{user.id}) preferences")
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -80,30 +81,38 @@ module MyHelper
|
|||||||
Document.visible.order("#{Document.table_name}.created_on DESC").limit(10).to_a
|
Document.visible.order("#{Document.table_name}.created_on DESC").limit(10).to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
def issuesassignedtome_items
|
def issues_items(block, settings)
|
||||||
Issue.visible.open.
|
send "#{block}_items", settings
|
||||||
assigned_to(User.current).
|
|
||||||
limit(10).
|
|
||||||
includes(:status, :project, :tracker, :priority).
|
|
||||||
references(:status, :project, :tracker, :priority).
|
|
||||||
order("#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def issuesreportedbyme_items
|
def issuesassignedtome_items(settings)
|
||||||
Issue.visible.open.
|
query = IssueQuery.new(:name => l(:label_assigned_to_me_issues), :user => User.current)
|
||||||
where(:author_id => User.current.id).
|
query.add_filter 'assigned_to_id', '=', ['me']
|
||||||
limit(10).
|
query.column_names = settings[:columns].presence || ['project', 'tracker', 'status', 'subject']
|
||||||
includes(:status, :project, :tracker, :priority).
|
query.sort_criteria = settings[:sort].presence || [['priority', 'desc'], ['updated_on', 'desc']]
|
||||||
references(:status, :project, :tracker).
|
issues = query.issues(:limit => 10)
|
||||||
order("#{Issue.table_name}.updated_on DESC")
|
|
||||||
|
return issues, query
|
||||||
end
|
end
|
||||||
|
|
||||||
def issueswatched_items
|
def issuesreportedbyme_items(settings)
|
||||||
Issue.visible.open.
|
query = IssueQuery.new(:name => l(:label_reported_issues), :user => User.current)
|
||||||
on_active_project.watched_by(User.current.id).
|
query.add_filter 'author_id', '=', ['me']
|
||||||
preload(:status, :project, :tracker, :priority).
|
query.column_names = settings[:columns].presence || ['project', 'tracker', 'status', 'subject']
|
||||||
recently_updated.
|
query.sort_criteria = settings[:sort].presence || [['updated_on', 'desc']]
|
||||||
limit(10)
|
issues = query.issues(:limit => 10)
|
||||||
|
|
||||||
|
return issues, query
|
||||||
|
end
|
||||||
|
|
||||||
|
def issueswatched_items(settings)
|
||||||
|
query = IssueQuery.new(:name => l(:label_watched_issues), :user => User.current)
|
||||||
|
query.add_filter 'watcher_id', '=', ['me']
|
||||||
|
query.column_names = settings[:columns].presence || ['project', 'tracker', 'status', 'subject']
|
||||||
|
query.sort_criteria = settings[:sort].presence || [['updated_on', 'desc']]
|
||||||
|
issues = query.issues(:limit => 10)
|
||||||
|
|
||||||
|
return issues, query
|
||||||
end
|
end
|
||||||
|
|
||||||
def news_items
|
def news_items
|
||||||
|
|||||||
@ -161,7 +161,7 @@ module QueriesHelper
|
|||||||
content_tag('span', label + " " + value, :class => "total-for-#{column.name.to_s.dasherize}")
|
content_tag('span', label + " " + value, :class => "total-for-#{column.name.to_s.dasherize}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def column_header(query, column)
|
def column_header(query, column, options={})
|
||||||
if column.sortable?
|
if column.sortable?
|
||||||
css, order = nil, column.default_order
|
css, order = nil, column.default_order
|
||||||
if column.name.to_s == query.sort_criteria.first_key
|
if column.name.to_s == query.sort_criteria.first_key
|
||||||
@ -173,11 +173,21 @@ module QueriesHelper
|
|||||||
order = 'asc'
|
order = 'asc'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
sort_param = { :sort => query.sort_criteria.add(column.name, order).to_param }
|
param_key = options[:sort_param] || :sort
|
||||||
content = link_to(column.caption,
|
sort_param = { param_key => query.sort_criteria.add(column.name, order).to_param }
|
||||||
{:params => request.query_parameters.merge(sort_param)},
|
while sort_param.keys.first.to_s =~ /^(.+)\[(.+)\]$/
|
||||||
|
sort_param = {$1 => {$2 => sort_param.values.first}}
|
||||||
|
end
|
||||||
|
link_options = {
|
||||||
:title => l(:label_sort_by, "\"#{column.caption}\""),
|
:title => l(:label_sort_by, "\"#{column.caption}\""),
|
||||||
:class => css
|
:class => css
|
||||||
|
}
|
||||||
|
if options[:sort_link_options]
|
||||||
|
link_options.merge! options[:sort_link_options]
|
||||||
|
end
|
||||||
|
content = link_to(column.caption,
|
||||||
|
{:params => request.query_parameters.deep_merge(sort_param)},
|
||||||
|
link_options
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
content = column.caption
|
content = column.caption
|
||||||
|
|||||||
@ -386,6 +386,22 @@ class Query < ActiveRecord::Base
|
|||||||
new(attributes).build_from_params(params)
|
new(attributes).build_from_params(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def as_params
|
||||||
|
params = {}
|
||||||
|
filters.each do |field, options|
|
||||||
|
params[:f] ||= []
|
||||||
|
params[:f] << field
|
||||||
|
params[:op] ||= {}
|
||||||
|
params[:op][field] = options[:operator]
|
||||||
|
params[:v] ||= {}
|
||||||
|
params[:v][field] = options[:values]
|
||||||
|
end
|
||||||
|
params[:c] = column_names
|
||||||
|
params[:sort] = sort_criteria.to_param
|
||||||
|
params[:set_filter] = 1
|
||||||
|
params
|
||||||
|
end
|
||||||
|
|
||||||
def validate_query_filters
|
def validate_query_filters
|
||||||
filters.each_key do |field|
|
filters.each_key do |field|
|
||||||
if values_for(field)
|
if values_for(field)
|
||||||
|
|||||||
@ -128,6 +128,7 @@ class UserPreference < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_block_settings(block, settings)
|
def update_block_settings(block, settings)
|
||||||
|
block = block.to_s
|
||||||
block_settings = my_page_settings(block).merge(settings.symbolize_keys)
|
block_settings = my_page_settings(block).merge(settings.symbolize_keys)
|
||||||
my_page_settings[block] = block_settings
|
my_page_settings[block] = block_settings
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
<% query_options = nil unless defined?(query_options) %>
|
||||||
|
<% query_options ||= {} %>
|
||||||
|
|
||||||
<%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do -%>
|
<%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do -%>
|
||||||
<%= hidden_field_tag 'back_url', url_for(:params => request.query_parameters), :id => nil %>
|
<%= hidden_field_tag 'back_url', url_for(:params => request.query_parameters), :id => nil %>
|
||||||
<div class="autoscroll">
|
<div class="autoscroll">
|
||||||
@ -9,7 +12,7 @@
|
|||||||
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %>
|
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %>
|
||||||
</th>
|
</th>
|
||||||
<% query.inline_columns.each do |column| %>
|
<% query.inline_columns.each do |column| %>
|
||||||
<%= column_header(query, column) %>
|
<%= column_header(query, column, query_options) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|||||||
42
app/views/my/blocks/_issues.erb
Normal file
42
app/views/my/blocks/_issues.erb
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<% issues, query = issues_items(block, settings) %>
|
||||||
|
|
||||||
|
<div class="contextual">
|
||||||
|
<%= link_to_function l(:label_options), "$('##{block}-settings').toggle();", :class => 'icon-only icon-settings' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>
|
||||||
|
<%= link_to query.name, issues_path(query.as_params) %>
|
||||||
|
(<%= query.issue_count %>)
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<div id="<%= block %>-settings" style="display:none;">
|
||||||
|
<%= form_tag(my_page_path, :remote => true) do %>
|
||||||
|
<div class="box">
|
||||||
|
<%= render_query_columns_selection(query, :name => "settings[#{block}][columns]") %>
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
|
<%= submit_tag l(:button_save) %>
|
||||||
|
<%= link_to_function l(:button_cancel), "$('##{block}-settings').toggle();" %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% if issues.any? %>
|
||||||
|
<%= render :partial => 'issues/list',
|
||||||
|
:locals => {
|
||||||
|
:issues => issues,
|
||||||
|
:query => query,
|
||||||
|
:query_options => {
|
||||||
|
:sort_param => "settings[#{block}][sort]",
|
||||||
|
:sort_link_options => {:method => :post, :remote => true}
|
||||||
|
}
|
||||||
|
} %>
|
||||||
|
<% else %>
|
||||||
|
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% content_for :header_tags do %>
|
||||||
|
<%= auto_discovery_link_tag(:atom,
|
||||||
|
issues_path(query.as_params.merge(:format => 'atom', :key => User.current.rss_key)),
|
||||||
|
{:title => query.name}) %>
|
||||||
|
<% end %>
|
||||||
@ -1,15 +0,0 @@
|
|||||||
<% assigned_issues = issuesassignedtome_items %>
|
|
||||||
<h3>
|
|
||||||
<%= link_to l(:label_assigned_to_me_issues),
|
|
||||||
issues_path(:set_filter => 1, :assigned_to_id => 'me', :sort => 'priority:desc,updated_on:desc') %>
|
|
||||||
(<%= assigned_issues.limit(nil).count %>)
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
<%= render :partial => 'issues/list_simple', :locals => { :issues => assigned_issues.to_a } %>
|
|
||||||
|
|
||||||
<% content_for :header_tags do %>
|
|
||||||
<%= auto_discovery_link_tag(:atom,
|
|
||||||
{:controller => 'issues', :action => 'index', :set_filter => 1,
|
|
||||||
:assigned_to_id => 'me', :format => 'atom', :key => User.current.rss_key},
|
|
||||||
{:title => l(:label_assigned_to_me_issues)}) %>
|
|
||||||
<% end %>
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
<% reported_issues = issuesreportedbyme_items %>
|
|
||||||
<h3>
|
|
||||||
<%= link_to l(:label_reported_issues),
|
|
||||||
issues_path(:set_filter => 1, :status_id => 'o', :author_id => 'me', :sort => 'updated_on:desc') %>
|
|
||||||
(<%= reported_issues.limit(nil).count %>)
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
<%= render :partial => 'issues/list_simple', :locals => { :issues => reported_issues.to_a } %>
|
|
||||||
|
|
||||||
<% content_for :header_tags do %>
|
|
||||||
<%= auto_discovery_link_tag(:atom,
|
|
||||||
{:controller => 'issues', :action => 'index', :set_filter => 1,
|
|
||||||
:author_id => 'me', :format => 'atom', :key => User.current.rss_key},
|
|
||||||
{:title => l(:label_reported_issues)}) %>
|
|
||||||
<% end %>
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
<% watched_issues = issueswatched_items %>
|
|
||||||
<h3>
|
|
||||||
<%= link_to l(:label_watched_issues),
|
|
||||||
issues_path(:set_filter => 1, :watcher_id => 'me', :sort => 'updated_on:desc') %>
|
|
||||||
(<%= watched_issues.limit(nil).count %>)
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
|
|
||||||
<%= render :partial => 'issues/list_simple', :locals => { :issues => watched_issues.to_a } %>
|
|
||||||
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
<%= javascript_tag do %>
|
<%= javascript_tag do %>
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
$('#block-select').val('');
|
||||||
$('#list-top, #list-left, #list-right').sortable({
|
$('#list-top, #list-left, #list-right').sortable({
|
||||||
connectWith: '.block-receiver',
|
connectWith: '.block-receiver',
|
||||||
tolerance: 'pointer',
|
tolerance: 'pointer',
|
||||||
|
|||||||
@ -1,32 +1,38 @@
|
|||||||
|
<% tag_id = tag_name.gsub(/[\[\]]+/, '_').sub(/_+$/, '') %>
|
||||||
|
<% available_tag_id = "available_#{tag_id}" %>
|
||||||
|
<% selected_tag_id = "selected_#{tag_id}" %>
|
||||||
|
|
||||||
<table class="query-columns">
|
<table class="query-columns">
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left:0">
|
<td style="padding-left:0">
|
||||||
<%= label_tag "available_columns", l(:description_available_columns) %>
|
<%= label_tag available_tag_id, l(:description_available_columns) %>
|
||||||
<br />
|
<br />
|
||||||
<%= select_tag 'available_columns',
|
<%= select_tag 'available_columns',
|
||||||
options_for_select(query_available_inline_columns_options(query)),
|
options_for_select(query_available_inline_columns_options(query)),
|
||||||
|
:id => available_tag_id,
|
||||||
:multiple => true, :size => 10, :style => "width:150px",
|
:multiple => true, :size => 10, :style => "width:150px",
|
||||||
:ondblclick => "moveOptions(this.form.available_columns, this.form.selected_columns);" %>
|
:ondblclick => "moveOptions(this.form.#{available_tag_id}, this.form.#{selected_tag_id});" %>
|
||||||
</td>
|
</td>
|
||||||
<td class="buttons">
|
<td class="buttons">
|
||||||
<input type="button" value="→"
|
<input type="button" value="→"
|
||||||
onclick="moveOptions(this.form.available_columns, this.form.selected_columns);" /><br />
|
onclick="moveOptions(this.form.<%= available_tag_id %>, this.form.<%= selected_tag_id %>);" /><br />
|
||||||
<input type="button" value="←"
|
<input type="button" value="←"
|
||||||
onclick="moveOptions(this.form.selected_columns, this.form.available_columns);" />
|
onclick="moveOptions(this.form.<%= selected_tag_id %>, this.form.<%= available_tag_id %>);" />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= label_tag "selected_columns", l(:description_selected_columns) %>
|
<%= label_tag selected_tag_id, l(:description_selected_columns) %>
|
||||||
<br />
|
<br />
|
||||||
<%= select_tag tag_name,
|
<%= select_tag tag_name,
|
||||||
options_for_select(query_selected_inline_columns_options(query)),
|
options_for_select(query_selected_inline_columns_options(query)),
|
||||||
:id => 'selected_columns', :multiple => true, :size => 10, :style => "width:150px",
|
:id => selected_tag_id,
|
||||||
:ondblclick => "moveOptions(this.form.selected_columns, this.form.available_columns);" %>
|
:multiple => true, :size => 10, :style => "width:150px",
|
||||||
|
:ondblclick => "moveOptions(this.form.#{selected_tag_id}, this.form.#{available_tag_id});" %>
|
||||||
</td>
|
</td>
|
||||||
<td class="buttons">
|
<td class="buttons">
|
||||||
<input type="button" value="⇈" onclick="moveOptionTop(this.form.selected_columns);" /><br />
|
<input type="button" value="⇈" onclick="moveOptionTop(this.form.<%= selected_tag_id %>);" /><br />
|
||||||
<input type="button" value="↑" onclick="moveOptionUp(this.form.selected_columns);" /><br />
|
<input type="button" value="↑" onclick="moveOptionUp(this.form.<%= selected_tag_id %>);" /><br />
|
||||||
<input type="button" value="↓" onclick="moveOptionDown(this.form.selected_columns);" /><br />
|
<input type="button" value="↓" onclick="moveOptionDown(this.form.<%= selected_tag_id %>);" /><br />
|
||||||
<input type="button" value="⇊" onclick="moveOptionBottom(this.form.selected_columns);" />
|
<input type="button" value="⇊" onclick="moveOptionBottom(this.form.<%= selected_tag_id %>);" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -34,7 +40,7 @@
|
|||||||
<%= javascript_tag do %>
|
<%= javascript_tag do %>
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('.query-columns').closest('form').submit(function(){
|
$('.query-columns').closest('form').submit(function(){
|
||||||
$('#selected_columns option').prop('selected', true);
|
$('#<%= selected_tag_id %> option').prop('selected', true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -20,13 +20,13 @@ module Redmine
|
|||||||
include Redmine::I18n
|
include Redmine::I18n
|
||||||
|
|
||||||
CORE_BLOCKS = {
|
CORE_BLOCKS = {
|
||||||
'issuesassignedtome' => :label_assigned_to_me_issues,
|
'issuesassignedtome' => {:label => :label_assigned_to_me_issues, :partial => 'my/blocks/issues'},
|
||||||
'issuesreportedbyme' => :label_reported_issues,
|
'issuesreportedbyme' => {:label => :label_reported_issues, :partial => 'my/blocks/issues'},
|
||||||
'issueswatched' => :label_watched_issues,
|
'issueswatched' => {:label => :label_watched_issues, :partial => 'my/blocks/issues'},
|
||||||
'news' => :label_news_latest,
|
'news' => {:label => :label_news_latest, :partial => 'my/blocks/news'},
|
||||||
'calendar' => :label_calendar,
|
'calendar' => {:label => :label_calendar, :partial => 'my/blocks/calendar'},
|
||||||
'documents' => :label_document_plural,
|
'documents' => {:label => :label_document_plural, :partial => 'my/blocks/documents'},
|
||||||
'timelog' => :label_spent_time
|
'timelog' => {:label => :label_spent_time, :partial => 'my/blocks/timelog'}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Returns the available blocks
|
# Returns the available blocks
|
||||||
@ -36,8 +36,9 @@ module Redmine
|
|||||||
|
|
||||||
def self.block_options
|
def self.block_options
|
||||||
options = []
|
options = []
|
||||||
blocks.each do |k, v|
|
blocks.each do |block, block_options|
|
||||||
options << [l("my.blocks.#{v}", :default => [v, v.to_s.humanize]), k.dasherize]
|
label = block_options[:label]
|
||||||
|
options << [l("my.blocks.#{label}", :default => [label, label.to_s.humanize]), block.dasherize]
|
||||||
end
|
end
|
||||||
options
|
options
|
||||||
end
|
end
|
||||||
@ -46,7 +47,7 @@ module Redmine
|
|||||||
def self.additional_blocks
|
def self.additional_blocks
|
||||||
@@additional_blocks ||= Dir.glob("#{Redmine::Plugin.directory}/*/app/views/my/blocks/_*.{rhtml,erb}").inject({}) do |h,file|
|
@@additional_blocks ||= Dir.glob("#{Redmine::Plugin.directory}/*/app/views/my/blocks/_*.{rhtml,erb}").inject({}) do |h,file|
|
||||||
name = File.basename(file).split('.').first.gsub(/^_/, '')
|
name = File.basename(file).split('.').first.gsub(/^_/, '')
|
||||||
h[name] = name.to_sym
|
h[name] = {:label => name.to_sym, :partial => "my/blocks/#{name}"}
|
||||||
h
|
h
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1132,6 +1132,7 @@ div.wiki img {vertical-align:middle; max-width:100%;}
|
|||||||
|
|
||||||
.handle {cursor: move;}
|
.handle {cursor: move;}
|
||||||
|
|
||||||
|
#my-page .list th.checkbox, #my-page .list td.checkbox {display:none;}
|
||||||
/***** Gantt chart *****/
|
/***** Gantt chart *****/
|
||||||
.gantt_hdr {
|
.gantt_hdr {
|
||||||
position:absolute;
|
position:absolute;
|
||||||
|
|||||||
@ -797,7 +797,7 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||||||
assert_equal columns, session[:issue_query][:column_names].map(&:to_s)
|
assert_equal columns, session[:issue_query][:column_names].map(&:to_s)
|
||||||
|
|
||||||
# ensure only these columns are kept in the selected columns list
|
# ensure only these columns are kept in the selected columns list
|
||||||
assert_select 'select#selected_columns option' do
|
assert_select 'select[name=?] option', 'c[]' do
|
||||||
assert_select 'option', 3
|
assert_select 'option', 3
|
||||||
assert_select 'option[value=tracker]'
|
assert_select 'option[value=tracker]'
|
||||||
assert_select 'option[value=project]', 0
|
assert_select 'option[value=project]', 0
|
||||||
|
|||||||
@ -51,6 +51,47 @@ class MyControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_page_with_assigned_issues_block_and_no_custom_settings
|
||||||
|
preferences = User.find(2).pref
|
||||||
|
preferences.my_page_layout = {'top' => ['issuesassignedtome']}
|
||||||
|
preferences.my_page_settings = nil
|
||||||
|
preferences.save!
|
||||||
|
|
||||||
|
get :page
|
||||||
|
assert_select '#block-issuesassignedtome' do
|
||||||
|
assert_select 'table.issues' do
|
||||||
|
assert_select 'th a[data-remote=true][data-method=post]', :text => 'Tracker'
|
||||||
|
end
|
||||||
|
assert_select '#issuesassignedtome-settings' do
|
||||||
|
assert_select 'select[name=?]', 'settings[issuesassignedtome][columns][]'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_page_with_assigned_issues_block_and_custom_columns
|
||||||
|
preferences = User.find(2).pref
|
||||||
|
preferences.my_page_layout = {'top' => ['issuesassignedtome']}
|
||||||
|
preferences.my_page_settings = {'issuesassignedtome' => {:columns => ['tracker', 'subject', 'due_date']}}
|
||||||
|
preferences.save!
|
||||||
|
|
||||||
|
get :page
|
||||||
|
assert_select '#block-issuesassignedtome' do
|
||||||
|
assert_select 'table.issues td.due_date'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_page_with_assigned_issues_block_and_custom_sort
|
||||||
|
preferences = User.find(2).pref
|
||||||
|
preferences.my_page_layout = {'top' => ['issuesassignedtome']}
|
||||||
|
preferences.my_page_settings = {'issuesassignedtome' => {:sort => 'due_date'}}
|
||||||
|
preferences.save!
|
||||||
|
|
||||||
|
get :page
|
||||||
|
assert_select '#block-issuesassignedtome' do
|
||||||
|
assert_select 'table.issues.sort-by-due-date'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_page_with_all_blocks
|
def test_page_with_all_blocks
|
||||||
blocks = Redmine::MyPage.blocks.keys
|
blocks = Redmine::MyPage.blocks.keys
|
||||||
preferences = User.find(2).pref
|
preferences = User.find(2).pref
|
||||||
|
|||||||
@ -51,7 +51,7 @@ class SettingsControllerTest < Redmine::ControllerTest
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_select 'select[id=selected_columns][name=?]', 'settings[issue_list_default_columns][]' do
|
assert_select 'select[name=?]', 'settings[issue_list_default_columns][]' do
|
||||||
assert_select 'option', 4
|
assert_select 'option', 4
|
||||||
assert_select 'option[value=tracker]', :text => 'Tracker'
|
assert_select 'option[value=tracker]', :text => 'Tracker'
|
||||||
assert_select 'option[value=subject]', :text => 'Subject'
|
assert_select 'option[value=subject]', :text => 'Subject'
|
||||||
@ -59,7 +59,7 @@ class SettingsControllerTest < Redmine::ControllerTest
|
|||||||
assert_select 'option[value=updated_on]', :text => 'Updated'
|
assert_select 'option[value=updated_on]', :text => 'Updated'
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_select 'select[id=available_columns]' do
|
assert_select 'select[name=?]', 'available_columns[]' do
|
||||||
assert_select 'option[value=tracker]', 0
|
assert_select 'option[value=tracker]', 0
|
||||||
assert_select 'option[value=priority]', :text => 'Priority'
|
assert_select 'option[value=priority]', :text => 'Priority'
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user