sort by key for roles to display in chart

This commit is contained in:
Harry Bomrah 2016-06-02 14:50:10 +08:00
parent 0e6994b3ac
commit cf0455487b
2 changed files with 4 additions and 3 deletions

View File

@ -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

View File

@ -56,12 +56,12 @@
</div>
<div class="form-actions">
<button id="generate_graph" class="btn btn-info">Graphs</button>
<button id="generate_excel" class="btn btn-primary">Export</button>
<a href="" id="generate_excel" class="btn btn-primary">Export</a>
</div>
</form>
</div>
<div class="analysis-show-area hide in">
<% 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| %>
<div class="role muted" data-role-id="<%= role.id.to_s %>">
<h3><%= role.title %></h3>
<div class="graph-area">
@ -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(){