diff --git a/app/assets/images/desktop/personal_conference.svg b/app/assets/images/desktop/personal_conference.svg new file mode 100644 index 0000000..823708f --- /dev/null +++ b/app/assets/images/desktop/personal_conference.svg @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/app/controllers/admin/writing_conferences_controller.rb b/app/controllers/admin/writing_conferences_controller.rb index 82aa57e..d01287f 100644 --- a/app/controllers/admin/writing_conferences_controller.rb +++ b/app/controllers/admin/writing_conferences_controller.rb @@ -1,5 +1,6 @@ class Admin::WritingConferencesController < OrbitMemberController layout "member_plugin" + include Admin::PersonalConferencesHelper before_action :set_writing_conference, only: [:show, :edit , :update, :destroy] before_action :set_plugin @@ -15,24 +16,39 @@ class Admin::WritingConferencesController < OrbitMemberController def new @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil @writing_conference = WritingConference.new + + if params[:desktop] + render :layout => false + end end def create @member = MemberProfile.find(conference_params['member_profile_id']) rescue nil @writing_conference = WritingConference.new(conference_params) @writing_conference.save - redirect_to params['referer_url'] + if params[:desktop] == "true" + render json: get_paper_list.to_json + else + redirect_to params['referer_url'] + end end def edit @member = @writing_conference.member_profile + if params[:desktop] + render :layout => false + end end def update @member = @writing_conference.member_profile @writing_conference.update_attributes(conference_params) @writing_conference.save - redirect_to params['referer_url'] + if params[:desktop] == "true" + render json: get_paper_list.to_json + else + redirect_to params['referer_url'] + end end def destroy diff --git a/app/controllers/desktop/personal_conferences_controller.rb b/app/controllers/desktop/personal_conferences_controller.rb new file mode 100644 index 0000000..cb460d3 --- /dev/null +++ b/app/controllers/desktop/personal_conferences_controller.rb @@ -0,0 +1,23 @@ +class Desktop::PersonalConferencesController < DesktopAdminController + include Admin::PersonalConferencesHelper + + def menu + user = OrbitHelper.current_user + [ + { + "title" => "List", + "layout" => "list" + }, + { + "title" => "Add/Edit", + "layout" => "form", + "new_path" => "/admin/members/#{user.member_profile.to_param}/writing_conferences/new" + } + ] + end + + def list + get_paper_list + end + +end \ No newline at end of file diff --git a/app/helpers/admin/personal_conferences_helper.rb b/app/helpers/admin/personal_conferences_helper.rb new file mode 100644 index 0000000..2a7eb3d --- /dev/null +++ b/app/helpers/admin/personal_conferences_helper.rb @@ -0,0 +1,30 @@ +module Admin::PersonalConferencesHelper + + def get_paper_list + user = current_user.nil? ? OrbitHelper.current_user : current_user + user_profile = user.member_profile + conferences = WritingConference.where(:member_profile_id => user_profile.id) + conferences = conferences.collect do |c| + files = c.writing_conference_files.collect do |wcf| + { + "title" => wcf.title, + "description" => wcf.description, + "link" => wcf.file.url, + "extension" => (wcf.file.url.split(".").last rescue "") + } + end + + { + "id" => c.id.to_s, + "edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/writing_conferences/#{c.to_param}/edit", + "delete_url" => "/#{I18n.locale.to_s}/admin/writing_conferences/#{c.id.to_s}", + "paper_title" => c.paper_title, + "conference_title" => c.conference_title, + "keywords" => c.keywords, + "abstract" => c.abstract, + "files" => files + } + end + conferences + end +end \ No newline at end of file diff --git a/app/views/admin/writing_conferences/_form.html.erb b/app/views/admin/writing_conferences/_form.html.erb index 06818ab..1c85919 100644 --- a/app/views/admin/writing_conferences/_form.html.erb +++ b/app/views/admin/writing_conferences/_form.html.erb @@ -7,7 +7,7 @@ <% content_for :page_specific_javascript do %> <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> - <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> <%= javascript_include_tag "lib/file-type" %> <%= javascript_include_tag "lib/module-area" %> <% end %> @@ -15,7 +15,7 @@