helper RolesHelper
SECTION=Navigation::SECTION_CONFIGURATION
+ BULK_LIMIT=1
before_filter :admin_required
verify :method => :post, :only => [:set_users, :set_groups], :redirect_to => {:action => 'global'}
params['qualifiers'] ||= 'TRK'
params['pageSize'] = 500
- @query_result = Internal.component_api.find(params).components().to_a
- @projects_ids = @query_result.collect{|component| component.getId()}
+ query_result = Internal.component_api.find(params)
+ components = query_result.components().to_a
+ total_results_count = query_result.paging.total.to_i
+
+ @projects_ids = components.collect{|component| component.getId()}
+ @qualifier = params[:qualifiers]
render :partial => 'apply_template_form',
- :locals => {:components => @projects_ids, :project_name => @query_result.size == 1 ? @query_result[0].name : nil, :qualifier => params[:qualifiers]}
+ :locals => {:project_name => components.size == 1 ? components[0].name : nil,
+ :empty => @projects_ids.nil? || @projects_ids.size == 0,
+ :overflow => total_results_count > BULK_LIMIT}
end
# POST /roles/apply_template?criteria
<form id="apply-template-form" method="post" action="<%= ApplicationController.root_context -%>/roles/apply_template">
- <% unless components.nil? %>
- <input type="hidden" name="components" id="apply-template-components" value="<%= components.join(',') %>"/>
+ <% unless @projects_ids.nil? %>
+ <input type="hidden" name="components" id="apply-template-components" value="<%= @projects_ids.join(',') %>"/>
<% end %>
<fieldset>
<div class="modal-head">
</div>
<div class="modal-body">
<div class="modal-error"/>
- <% if components.nil? %>
+ <% if empty %>
<div class="info">
<img src="<%= ApplicationController.root_context -%>/images/information.png" style="vertical-align: text-bottom"/>
<%= message 'projects_role.no_projects' -%>
</div>
+ <% elsif overflow %>
+ <div class="info">
+ <img src="<%= ApplicationController.root_context -%>/images/information.png" style="vertical-align: text-bottom"/>
+ <%= message 'projects_role.exceeds_projects_limit_xxx', :params => RolesController::BULK_LIMIT -%>
+ </div>
<% else %>
<div class="modal-field">
<%= label_tag 'template_key', 'Permission Template' %>
<%= select_tag('template_key', options_for_select(@permission_templates, -1), :style => 'width: 250px;') %>
<% unless project_name %>
- <span style="float:right" class="note">(<%= "#{components.size} #{message('qualifier.' + qualifier)}s" %>)</span><br/>
+ <span style="float:right" class="note">(<%= "#{@projects_ids.size} #{message('qualifier.' + @qualifier)}s" %>)</span><br/>
<% end %>
</div>
<% end %>
</div>
<div class="modal-foot">
- <% unless components.nil? %>
+ <% unless empty || overflow %>
<span id="apply-template-loading-image" class="loading-image hidden"><%= image_tag 'loading.gif' %></span>
<input type="submit" value="<%= message('apply') -%>" id="apply-template-submit" class="apply-template" onclick="return displayLoadingImage()" />
<% end %>