diff --git a/app/assets/images/desktop/personal_honor.svg b/app/assets/images/desktop/personal_honor.svg new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/admin/honors_controller.rb b/app/controllers/admin/honors_controller.rb index 3139752..0dd8d92 100644 --- a/app/controllers/admin/honors_controller.rb +++ b/app/controllers/admin/honors_controller.rb @@ -1,5 +1,6 @@ class Admin::HonorsController < OrbitMemberController layout "member_plugin" + include Admin::PersonalHonorsHelper before_action :set_honor, only: [:show, :edit , :update, :destroy] before_action :set_plugin @@ -15,28 +16,49 @@ class Admin::HonorsController < OrbitMemberController def new @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil @honor = Honor.new + + if params[:desktop] + render :layout => false + end end def create @member = MemberProfile.find(honor_params['member_profile_id']) rescue nil @honor = Honor.new(honor_params) @honor.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 = @honor.member_profile rescue nil + if params[:desktop] + render :layout => false + end end def update @member = @honor.member_profile rescue nil @honor.update_attributes(honor_params) @honor.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 @honor.destroy + respond_to do |format| + format.html { redirect_to(admin_honor_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_honors_controller.rb b/app/controllers/desktop/personal_honors_controller.rb new file mode 100644 index 0000000..115cca8 --- /dev/null +++ b/app/controllers/desktop/personal_honors_controller.rb @@ -0,0 +1,23 @@ +class Desktop::PersonalHonorsController < DesktopAdminController + include Admin::PersonalHonorsHelper + + def menu + user = OrbitHelper.current_user + [ + { + "title" => "List", + "layout" => "list" + }, + { + "title" => "Add/Edit", + "layout" => "form", + "new_path" => "/admin/members/#{user.member_profile.to_param}/honors/new" + } + ] + end + + def list + get_paper_list + end + +end \ No newline at end of file diff --git a/app/helpers/admin/personal_honors_helper.rb b/app/helpers/admin/personal_honors_helper.rb new file mode 100644 index 0000000..2a41f74 --- /dev/null +++ b/app/helpers/admin/personal_honors_helper.rb @@ -0,0 +1,19 @@ +module Admin::PersonalHonorsHelper + + def get_paper_list + user = current_user.nil? ? OrbitHelper.current_user : current_user + user_profile = user.member_profile + honors = Honor.where(:member_profile_id => user_profile.id) + honors = honors.collect do |h| + { + "id" => h.id.to_s, + "edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/honors/#{h.to_param}/edit", + "delete_url" => "/#{I18n.locale.to_s}/admin/honors/#{h.id.to_s}", + "paper_title" => h.award_name, + "keywords" => h.keywords, + "files" => [] + } + end + honors + end +end \ No newline at end of file diff --git a/lib/personal_honor/engine.rb b/lib/personal_honor/engine.rb index 77a8482..4a7af0b 100644 --- a/lib/personal_honor/engine.rb +++ b/lib/personal_honor/engine.rb @@ -7,6 +7,7 @@ module PersonalHonor personal_plugin :enable => true, :sort_number => '50', :app_name=>"Honor", :intro_app_name=>"PersonalHonorIntro",:path=>"/plugin/personal_honor/profile",:front_path=>"/profile",:admin_path=>"/admin/honors",:i18n=>'module_name.personal_honor', :module_app_name=>'PersonalHonor' version "0.1" + desktop_enabled true organization "Rulingcom" author "RD dep" intro "I am intro"