if has_role?(:user, @project)
open_action_plans = ActionPlan.find(:all, :conditions => ['status= ? AND project_id=?', ActionPlan::STATUS_OPEN, @project.id],
:include => 'reviews', :order => 'dead_line ASC')
- closed_action_plans = ActionPlan.find(:all, :conditions => ['status= ? AND project_id=?', ActionPlan::STATUS_CLOSED, @project.id],
- :include => 'reviews', :order => 'dead_line ASC')
div_id = "action-plan-widget-#{widget.id.to_s}"
%>
</table>
<% end %>
-<%
- unless closed_action_plans.size ==0
- table_id = "closed-action-plan-table-#{widget.id.to_s}"
- link_id = "closed-action-plan-link-#{widget.id.to_s}"
-%>
- <script type="text/javascript">
- function displayClosedActionPlans() {
- var table = $('<%= table_id -%>');
- var link = $('<%= link_id -%>');
- if (table.visible()) {
- table.hide();
- link.update("<%= message('widget.action_plans.show_closed_action_plans') -%>");
- } else {
- table.show();
- link.update("<%= message('widget.action_plans.hide_closed_action_plans') -%>");
- }
- }
- </script>
- <div style="margin-top:10px; font-size:93%"><a href="#" onclick="displayClosedActionPlans();" id ="<%= link_id -%>"><%= message('widget.action_plans.show_closed_action_plans') -%></a></div>
- <table class="width100 actionPlans" style="display:none" id="<%= table_id -%>">
- <thead>
- <tr>
- <th colspan="3"></th>
- </tr>
- </thead>
- <tbody>
- <%
- closed_action_plans.each do |plan|
- %>
- <tr>
- <td class="nowrap"><%= h(plan.name) -%></td>
- <td class="nowrap small" align="right"><%= plan.dead_line ? plan.dead_line.strftime("%d %b %Y") : ' ' -%></td>
- <% if plan.progress[:total]==0 %>
- <td class="noprogress nowrap"><%= message('action_plans.no_reviews_linked_to_action_plan') -%></td>
- <% else %>
- <td class="progress">
- <%= render :partial => 'action_plans/progress', :locals => {:action_plan => plan} -%>
- </td>
- <% end %>
- </tr>
- <%
- end
- %>
- </tbody>
- </table>
-<% end %>
-
</div>
<% end %>
</script>
<div class="line-block">
- <div style="float:right">
- <a href="<%= url_for url_options.merge({:action => 'index'}) -%>&action_plan_id=<%= first_action_plan.id -%>" id="planned-review-more-link_<%= widget.id -%>">
- <%= message('widgets.more') -%>
- </a>
- </div>
-
<h3>
<%= title -%>
<select class="small" style="margin-left: 20px" onchange="showActionPlanOpenReviews(this.value);" id="select-action-plan_<%= widget.id -%>">
action_plans.open_reviews_x_percent=Open reviews - {0}% ({1} reviews)
action_plans.reopen=Reopen
action_plans.close=Close
-action_plans.show_closed_action_plans=Show closed action plans
-action_plans.hide_closed_action_plans=Hide closed action plans
+action_plans.closed_action_plan=Closed action plans
#------------------------------------------------------------------------------
widget.action_plans.description=Shows all the open action plans of the project
widget.action_plans.title=Open action plans
widget.action_plans.no_action_plan=No action plan
-widget.action_plans.show_closed_action_plans=Show closed action plans
-widget.action_plans.hide_closed_action_plans=Hide closed action plans
widget.planned_reviews.name=Planned reviews
widget.planned_reviews.description=Shows all the planned reviews of the project, gathered by action plan
def load_action_plans
@open_action_plans = ActionPlan.find(:all, :conditions => ['status=? AND project_id=?', ActionPlan::STATUS_OPEN, @resource.id], :include => 'reviews', :order => 'dead_line ASC')
- @closed_action_plans = ActionPlan.find(:all, :conditions => ['status=? AND project_id=?', ActionPlan::STATUS_CLOSED, @resource.id], :include => 'reviews', :order => 'dead_line ASC')
+ @closed_action_plans = ActionPlan.find(:all, :conditions => ['status=? AND project_id=?', ActionPlan::STATUS_CLOSED, @resource.id], :include => 'reviews', :order => 'dead_line DESC')
end
end
action_plan_id = options['action_plan_id']
if action_plan_id
action_plan = ActionPlan.find action_plan_id.to_i, :include => 'reviews'
- if action_plan
+ if action_plan && action_plan.reviews.size>0
conditions << 'id in (:ids)'
values[:ids]=action_plan.reviews.map { |r| r.id }
+ else
+ # no action plan or action plan is empty => no need to look into the database
+ no_need_for_db_request = true
end
elsif options['unplanned']
conditions << 'id not in (:ids)'
sort = 'reviews.updated_at DESC'
end
- Review.find(:all, :include => ['review_comments', 'project', 'assignee', 'resource', 'user'], :conditions => [conditions.join(' AND '), values], :order => sort, :limit => 200)
+ found_reviews = []
+ found_reviews = Review.find(:all, :include => ['review_comments', 'project', 'assignee', 'resource', 'user'], :conditions => [conditions.join(' AND '), values], :order => sort, :limit => 200) unless no_need_for_db_request
+ found_reviews
end
<td id="desc"><%= h(plan.user.name) -%></td>
<td class="thin nowrap right">
<%= link_to message('edit'), :action => 'edit', :id => @resource.id, :plan_id => plan.id, :class => 'action' -%>
+
<%
close_confirmation_message = {}
if plan.open? && plan.has_open_reviews?
%>
<%= link_to message('action_plans.close'),
{:action => 'change_status', :id => @resource.id, :plan_id => plan.id}, {:method => 'POST', :class => 'action'}.merge(close_confirmation_message) -%>
+
<%= link_to message('delete'), {:action => 'delete', :id => @resource.id, :plan_id => plan.id}, {:method => 'POST', :confirm => message('action_plans.confirm_delete'), :class => 'action'} -%>
</td>
</tr>
<% unless @closed_action_plans.empty? %>
- <script type="text/javascript">
- function displayClosedActionPlans() {
- var table = $('closedActionPlans');
- var link = $('showClosedActionPlanLink');
- if (table.visible()) {
- table.hide();
- link.update("<%= message('action_plans.show_closed_action_plans') -%>");
- } else {
- table.show();
- link.update("<%= message('action_plans.hide_closed_action_plans') -%>");
- }
- }
- </script>
- <div style="margin-top:30px;"><a href="#" onclick="displayClosedActionPlans();" id ="showClosedActionPlanLink">
- <%= message('action_plans.show_closed_action_plans') -%></a>
- </div>
- <table class="width100 data sortable actionPlans" style="display:none" id="closedActionPlans">
+ <br/><br/>
+ <h1><%= message('action_plans.closed_action_plan') -%></h1>
+
+ <table class="width100 data sortable actionPlans" id="closedActionPlans">
<thead>
<tr>
<th class="thin nowrap"><%= message('action_plans.col.status') -%></th>
<td class="thin nowrap right">
<%= link_to message('action_plans.reopen'),
{:action => 'change_status', :id => @resource.id, :plan_id => plan.id}, {:method => 'POST', :class => 'action'} -%>
+
<%= link_to message('delete'), {:action => 'delete', :id => @resource.id, :plan_id => plan.id}, {:method => 'POST', :confirm => message('action_plans.confirm_delete'), :class => 'action'} -%>
</td>
</tr>
to_date = DateTime.now
search_options['to'] = to_date
end
- reviews = Review.search(search_options)
+ found_reviews = Review.search(search_options)
+ reviews = select_authorized(:user, found_reviews, :project)
# table pagination
page_size = 20
end
%>
-<div class="line-block">
- <div style="float:right">
- <a href="<%= url_for search_options.merge({:controller => 'project_reviews', :action => 'index'}) -%>">
- <%= message('widgets.more') -%>
- </a>
- </div>
- <h3><%= title -%></h3>
-</div>
+<h3><%= title -%></h3>
<div id="reviews-widget-<%= widget_id -%>">
<%= render :partial => 'project/widgets/reviews/reviews_list',