diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index b925afd..3b1a6a5 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -33,6 +33,14 @@ def show @meta_keywords = @project.meta_keywords @project_expense_total = @project.items.where(:is_expense => true).sum(:total) @project_revenue_total = @project.items.where(:is_expense => false).sum(:total) + + + @child_categories = @project.categories.roots + @categories_by_total = Hash.new + @child_categories.each do |cat| + @categories_by_total[cat.expenditure_items_total] = cat + end + @categories_by_total = Hash[@categories_by_total.sort.reverse] end # just redirect over to show, this is because of old Google cached links. diff --git a/app/views/projects/show.html.slim b/app/views/projects/show.html.slim index c0cdf36..39064f7 100644 --- a/app/views/projects/show.html.slim +++ b/app/views/projects/show.html.slim @@ -47,18 +47,17 @@ div class="row" div class="row" div class="span6 barchart-widget" h1 Categories - - for category in @project.categories.roots + + - @categories_by_total.each_pair do |total,child_category| div class="bar-container" div class="bar-category-text" - h3 - = link_to category.name, organization_project_category_path(@organization, @project, category) - ' - = number_to_currency(category.expenditure_items_total, :precision => 0) + = link_to child_category.name, organization_project_category_path(@organization, @project, child_category) + ' + = number_to_currency(total, :precision => 0) div class="progress progress-danger" - div class="bar" style="width: #{((category.expenditure_items_total)/@project_expense_total)*100.to_i}%;" - = number_to_currency(Item.where(:category_id => category.subtree_ids).where(:is_expense => false).sum(:total)+category.items.where(:is_expense => false).sum(:total), :precision => 0) + div class="bar" style="width: #{((total/@project_expense_total)*100).to_i}%;" div class="progress progress-success" - div class="bar" style="width: #{((Item.where(:category_id => category.subtree_ids).where(:is_expense => false).sum(:total)/@project.items.where(:is_expense => false).sum(:total))*100).to_i}%;" + div class="bar" style="width: #{((child_category.revenue_items_total/@project_revenue_total)*100).to_i}%;" div class="span6" == render :partial => 'shared/comments' hr diff --git a/app/views/shared/_comments.html.slim b/app/views/shared/_comments.html.slim index 3c3a22f..17f2d96 100644 --- a/app/views/shared/_comments.html.slim +++ b/app/views/shared/_comments.html.slim @@ -4,14 +4,6 @@ javascript: - function disqus_config() { - this.callbacks.onNewComment = [function() { trackComment(); }]; - } - - function trackComment() { - alert('New comment posted.'); - } - var disqus_shortname = 'budgetvision'; // required: replace example with your forum shortname (function() {