From cf0455487bdbb135aafe24677c06cb15f3574242 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 2 Jun 2016 14:50:10 +0800 Subject: [PATCH] sort by key for roles to display in chart --- app/helpers/admin/journal_papers_helper.rb | 2 +- app/views/admin/journal_papers/analysis.html.erb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/helpers/admin/journal_papers_helper.rb b/app/helpers/admin/journal_papers_helper.rb index 881af51..a5abbbb 100644 --- a/app/helpers/admin/journal_papers_helper.rb +++ b/app/helpers/admin/journal_papers_helper.rb @@ -118,7 +118,7 @@ module Admin::JournalPapersHelper def get_data_for_excel(year_start,year_end) data = [] - roles = Role.where(:disabled => false, :title.ne => "", :title.ne => nil) + roles = Role.where(:disabled => false, :title.ne => "", :title.ne => nil).asc(:key) roles.each do |role| d = {} d["name"] = role.title diff --git a/app/views/admin/journal_papers/analysis.html.erb b/app/views/admin/journal_papers/analysis.html.erb index c0dc089..b278374 100644 --- a/app/views/admin/journal_papers/analysis.html.erb +++ b/app/views/admin/journal_papers/analysis.html.erb @@ -56,12 +56,12 @@
- + Export
- <% Role.where(:disabled => false, :title.ne => "", :title.ne => nil).each do |role| %> + <% Role.where(:disabled => false, :title.ne => "", :title.ne => nil).asc(:key).each do |role| %>

<%= role.title %>

@@ -79,6 +79,7 @@ $("#generate_excel").on("click",function(){ window.location.href = "/admin/journal_papers/download_excel.xlsx?" + "year_start=" + form.form.find("select[name=start_year]").val() + "&year_end=" + form.form.find("select[name=end_year]").val(); + return false; }) $("#generate_graph").on("click",function(){