diff --git a/app/assets/javascripts/personal_experience/jquery-ui.min.js b/app/assets/javascripts/personal_experience/jquery-ui-sortable.min.js similarity index 100% rename from app/assets/javascripts/personal_experience/jquery-ui.min.js rename to app/assets/javascripts/personal_experience/jquery-ui-sortable.min.js diff --git a/app/controllers/admin/experiences_controller.rb b/app/controllers/admin/experiences_controller.rb index e8352cd..8d7c66a 100644 --- a/app/controllers/admin/experiences_controller.rb +++ b/app/controllers/admin/experiences_controller.rb @@ -147,7 +147,7 @@ class Admin::ExperiencesController < OrbitMemberController uid = path[-2].split("-").last uid = uid.split("?").first end - @experience = Experience.find_by(:uid => uid) rescue Experience.find("53c4fd3548345219f04c0000") + @experience = Experience.find_by(:uid => uid) rescue Experience.find(params[:id]) end def find_experience diff --git a/app/models/experience.rb b/app/models/experience.rb index b4b6a57..7241401 100644 --- a/app/models/experience.rb +++ b/app/models/experience.rb @@ -25,6 +25,8 @@ class Experience before_validation :add_http + scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:start_date=>'desc', :end_date => "asc") } + def duration if !self.start_date.nil? or !self.end_date.nil? (self.start_date.strftime('%Y.%m') rescue "")+' ~ '+(self.end_date.strftime('%Y.%m') rescue I18n.t('personal_experience.up_to_today')) @@ -40,10 +42,10 @@ class Experience def self.get_plugin_datas_to_member(datas) fields_to_show = [ + "experience_type", "organizationt_title", "department", "job_title", - "experience_type", "duration" ] @@ -53,7 +55,7 @@ class Experience } end - plugin_datas = datas.where(:is_hidden=>false).order_by(:end_date=>'desc', :start_date=>'desc').collect do |p| + plugin_datas = datas.sort_for_frontend.collect do |p| pd_data = [] fields_to_show.collect do |t| @@ -68,7 +70,7 @@ class Experience end pd_data << { "data_title" => date } elsif t == "experience_type" - pd_data << {"data_title" => p.experience_type.title} + pd_data << {"data_title" => (p.experience_type.title rescue "")} else pd_data << { "data_title" => p.send(t) } end @@ -76,7 +78,7 @@ class Experience { "pd_datas" => pd_data, - "type-sort" => p.experience_type.sort_position + "type-sort" => (p.experience_type.sort_position rescue 1000) } end diff --git a/app/views/admin/experiences/_form.html.erb b/app/views/admin/experiences/_form.html.erb index fc131fc..cb61eef 100644 --- a/app/views/admin/experiences/_form.html.erb +++ b/app/views/admin/experiences/_form.html.erb @@ -133,7 +133,7 @@