forked from saurabh/personal-project
Update sort.
This commit is contained in:
parent
f66629b9e4
commit
63ec149248
|
@ -25,7 +25,7 @@ class Admin::ProjectsController < OrbitMemberController
|
||||||
redirect_to :action=> 'index'
|
redirect_to :action=> 'index'
|
||||||
end
|
end
|
||||||
def merge
|
def merge
|
||||||
@projects=Project.order_by(:year=>'desc').map{|value| value}.group_by{|v| [v[:project_title],v[:unit]]}
|
@projects=Project.sort_date.map{|value| value}.group_by{|v| [v[:project_title],v[:unit]]}
|
||||||
@projects.each do |key,value|
|
@projects.each do |key,value|
|
||||||
if value.length<=1
|
if value.length<=1
|
||||||
@projects.delete key
|
@projects.delete key
|
||||||
|
@ -48,7 +48,7 @@ class Admin::ProjectsController < OrbitMemberController
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@projects = Project.order_by(:period_start_date=>'desc',:year=>'desc').page(params[:page]).per(10)
|
@projects = Project.sort_date.page(params[:page]).per(10)
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
|
@ -34,7 +34,9 @@ class Project
|
||||||
|
|
||||||
before_validation :add_http
|
before_validation :add_http
|
||||||
|
|
||||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year=>'desc', :period_start_date=>'desc') }
|
index({period_start_date: -1, _id: -1}, { unique: false, background: false })
|
||||||
|
scope :sort_date, ->{ order_by(:period_start_date=>'desc', :id => 'desc') }
|
||||||
|
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:period_start_date=>'desc', :id => 'desc') }
|
||||||
|
|
||||||
def duration
|
def duration
|
||||||
if !self.send('period_start_date').nil? or !self.send('period_end_date').nil?
|
if !self.send('period_start_date').nil? or !self.send('period_end_date').nil?
|
||||||
|
@ -81,7 +83,7 @@ class Project
|
||||||
|
|
||||||
fields_to_show = fields_to_show - fields_to_remove
|
fields_to_show = fields_to_show - fields_to_remove
|
||||||
|
|
||||||
plugin_datas = datas.sort_for_frontend.collect.with_index do |p,index|
|
plugin_datas = datas.sort_for_frontend.collect.with_index do |p,idx|
|
||||||
|
|
||||||
pd_data = []
|
pd_data = []
|
||||||
fields_to_show.collect do |t|
|
fields_to_show.collect do |t|
|
||||||
|
@ -102,7 +104,7 @@ class Project
|
||||||
{
|
{
|
||||||
"pd_datas" => pd_data,
|
"pd_datas" => pd_data,
|
||||||
"type-sort" => (p.project_type.sort_position.to_i rescue 1000),
|
"type-sort" => (p.project_type.sort_position.to_i rescue 1000),
|
||||||
"sort-index" => index
|
"sort-index" => idx
|
||||||
}
|
}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
<%
|
<%
|
||||||
if has_access?
|
if has_access?
|
||||||
@projects = Project.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
@projects = Project.where(member_profile_id: @member.id).sort_date.page(params[:page]).per(10)
|
||||||
else
|
else
|
||||||
@projects = Project.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
@projects = Project.where(is_hidden: false, member_profile_id: @member.id).sort_date.page(params[:page]).per(10)
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
<% if has_access? %>
|
<% if has_access? %>
|
||||||
<th><input type="checkbox" /></th>
|
<th><input type="checkbox" /></th>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<th class="span2"><%= t('personal_project.year') %></th>
|
<th class="span2"><%= t('personal_project.period') %></th>
|
||||||
<th class="span4"><%= t('personal_project.project_title') %></th>
|
<th class="span4"><%= t('personal_project.project_title') %></th>
|
||||||
<th class="span4"><%= t('personal_project.job_title') %></th>
|
<th class="span4"><%= t('personal_project.job_title') %></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
<%= check_box_tag 'to_change[]', project.id.to_s, false, :class => "list-check" %>
|
<%= check_box_tag 'to_change[]', project.id.to_s, false, :class => "list-check" %>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td><%= project.year %></td>
|
<td><%= project.duration %></td>
|
||||||
<td>
|
<td>
|
||||||
<% link = OrbitHelper.url_to_plugin_show(project.to_param,'personal_project') %>
|
<% link = OrbitHelper.url_to_plugin_show(project.to_param,'personal_project') %>
|
||||||
<%= (link == "#" ? project.project_title : link_to(project.project_title, link , target: "blank")) %>
|
<%= (link == "#" ? project.project_title : link_to(project.project_title, link , target: "blank")) %>
|
||||||
|
|
Loading…
Reference in New Issue