diff --git a/app/assets/images/desktop/personal_experience.svg b/app/assets/images/desktop/personal_experience.svg new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/admin/experiences_controller.rb b/app/controllers/admin/experiences_controller.rb index b98a3dc..1480fce 100644 --- a/app/controllers/admin/experiences_controller.rb +++ b/app/controllers/admin/experiences_controller.rb @@ -1,5 +1,6 @@ class Admin::ExperiencesController < OrbitMemberController layout "member_plugin" + include Admin::PersonalExperiencesHelper before_action :set_experience, only: [:show, :edit , :update, :destroy] before_action :set_plugin @@ -15,28 +16,48 @@ class Admin::ExperiencesController < OrbitMemberController def new @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil @experience = Experience.new + if params[:desktop] + render :layout => false + end end def create @member = MemberProfile.find(experience_params['member_profile_id']) rescue nil @experience = Experience.new(experience_params) @experience.save - redirect_to params['referer_url'] + if params[:desktop] == "true" + render json: {"data" => get_paper_list}.to_json + else + redirect_to params['referer_url'] + end end def edit @member = @experience.member_profile rescue nil + if params[:desktop] + render :layout => false + end end def update @member = @experience.member_profile rescue nil @experience.update_attributes(experience_params) @experience.save - redirect_to params['referer_url'] + if params[:desktop] == "true" + render json: {"data" => get_paper_list}.to_json + else + redirect_to params['referer_url'] + end end def destroy @experience.destroy + respond_to do |format| + format.html { redirect_to(admin_experiences_url) } + # format.xml { head :ok } + format.js + format.json {render json: {"success" => true}} + end end def toggle_hide diff --git a/app/controllers/desktop/personal_experiences_controller.rb b/app/controllers/desktop/personal_experiences_controller.rb new file mode 100644 index 0000000..62cc67e --- /dev/null +++ b/app/controllers/desktop/personal_experiences_controller.rb @@ -0,0 +1,23 @@ +class Desktop::PersonalExperiencesController < DesktopAdminController + include Admin::PersonalExperiencesHelper + + def menu + user = OrbitHelper.current_user + [ + { + "title" => "List", + "layout" => "list" + }, + { + "title" => "Add/Edit", + "layout" => "form", + "new_path" => "/admin/members/#{user.member_profile.to_param}/experiences/new" + } + ] + end + + def list + get_paper_list + end + +end \ No newline at end of file diff --git a/app/helpers/admin/personal_experiences_helper.rb b/app/helpers/admin/personal_experiences_helper.rb new file mode 100644 index 0000000..f708392 --- /dev/null +++ b/app/helpers/admin/personal_experiences_helper.rb @@ -0,0 +1,20 @@ +module Admin::PersonalExperiencesHelper + + def get_paper_list + user = current_user.nil? ? OrbitHelper.current_user : current_user + user_profile = user.member_profile + experiences = Experience.where(:member_profile_id => user_profile.id) + experiences = experiences.collect do |e| + { + "id" => e.id.to_s, + "edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/experiences/#{e.to_param}/edit", + "delete_url" => "/#{I18n.locale.to_s}/admin/experiences/#{e.id.to_s}", + "paper_title" => e.organizationt_title, + "keywords" => e.keywords, + "abstract" => [], + "files" => [] + } + end + experiences + end +end \ No newline at end of file diff --git a/lib/personal_experience/engine.rb b/lib/personal_experience/engine.rb index 8f627ec..7b68fc1 100644 --- a/lib/personal_experience/engine.rb +++ b/lib/personal_experience/engine.rb @@ -6,6 +6,7 @@ module PersonalExperience base_url File.expand_path File.dirname(__FILE__) personal_plugin :enable => true, :sort_number => '45', :app_name=>"Experience", :intro_app_name=>"PersonalExperienceIntro",:path=>"/plugin/personal_experience/profile",:front_path=>"/profile",:admin_path=>"/admin/experiences",:i18n=>'module_name.personal_experience', :module_app_name=>'PersonalExperience' version "0.1" + desktop_enabled true organization "Rulingcom" author "RD dep" intro "I am intro"