forked from saurabh/personal-journal
some changes for desktop
This commit is contained in:
parent
53031c1831
commit
8c59b6929f
|
@ -47,6 +47,9 @@ class Admin::JournalPapersController < OrbitMemberController
|
|||
@journal_paper = JournalPaper.new(journal_paper_attributes)
|
||||
respond_to do |format|
|
||||
if @journal_paper.save
|
||||
if params[:desktop] == "true"
|
||||
format.json { render json: get_paper_list }
|
||||
end
|
||||
format.html { redirect_to params['referer_url'] }
|
||||
format.json { render action: 'show', status: :created, location: @journal_paper }
|
||||
else
|
||||
|
@ -59,6 +62,9 @@ class Admin::JournalPapersController < OrbitMemberController
|
|||
def update
|
||||
respond_to do |format|
|
||||
if @journal_paper.update_attributes(journal_paper_attributes)
|
||||
if params[:desktop] == "true"
|
||||
format.json { render json: get_paper_list }
|
||||
end
|
||||
format.html { redirect_to params['referer_url'] }
|
||||
# format.js { render 'toggle_enable' }
|
||||
format.json { head :no_content }
|
||||
|
@ -71,11 +77,11 @@ class Admin::JournalPapersController < OrbitMemberController
|
|||
|
||||
def destroy
|
||||
@journal_paper.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(admin_journal_papers_url) }
|
||||
# format.xml { head :ok }
|
||||
format.js
|
||||
format.json {render json: {"success" => true}}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class Desktop::JournalPapersController < DesktopAdminController
|
||||
include Admin::JournalPapersHelper
|
||||
def menu
|
||||
user = OrbitHelper.current_user
|
||||
[
|
||||
|
@ -19,32 +20,6 @@ class Desktop::JournalPapersController < DesktopAdminController
|
|||
]
|
||||
end
|
||||
|
||||
def get_paper_list
|
||||
user = OrbitHelper.current_user
|
||||
user_profile = user.member_profile
|
||||
journals = JournalPaper.where(:member_profile_id => user_profile.id)
|
||||
journals = journals.collect do |j|
|
||||
files = j.journal_paper_files.collect do |jpf|
|
||||
{
|
||||
"title" => jpf.title,
|
||||
"description" => jpf.description,
|
||||
"link" => jpf.journal_file.url,
|
||||
"extension" => (jpf.journal_file.url.split(".").last rescue "")
|
||||
}
|
||||
end
|
||||
|
||||
{
|
||||
"id" => j.id.to_s,
|
||||
"edit_url" => "/#{I18n.locale.to_s}/admin/journal_papers/#{j.to_param}/edit",
|
||||
"delete_url" => "/#{I18n.locale.to_s}/admin/journal_papers/#{j.id.to_s}",
|
||||
"paper_title" => j.paper_title,
|
||||
"journal_title" => j.journal_title,
|
||||
"keywords" => j.keywords,
|
||||
"abstract" => j.abstract,
|
||||
"files" => files
|
||||
}
|
||||
end
|
||||
journals
|
||||
end
|
||||
|
||||
end
|
|
@ -6,4 +6,31 @@ module Admin::JournalPapersHelper
|
|||
journal_paper_page = pages.first if journal_paper_page.nil?
|
||||
request.protocol+(request.host_with_port+journal_paper_page.url+'/'+journal_paper_object.to_param).gsub('//','/') rescue "/"
|
||||
end
|
||||
def get_paper_list
|
||||
user = current_user.nil? ? OrbitHelper.current_user : current_user
|
||||
user_profile = user.member_profile
|
||||
journals = JournalPaper.where(:member_profile_id => user_profile.id)
|
||||
journals = journals.collect do |j|
|
||||
files = j.journal_paper_files.collect do |jpf|
|
||||
{
|
||||
"title" => jpf.title,
|
||||
"description" => jpf.description,
|
||||
"link" => jpf.journal_file.url,
|
||||
"extension" => (jpf.journal_file.url.split(".").last rescue "")
|
||||
}
|
||||
end
|
||||
|
||||
{
|
||||
"id" => j.id.to_s,
|
||||
"edit_url" => "/#{I18n.locale.to_s}/admin/journal_papers/#{j.to_param}/edit",
|
||||
"delete_url" => "/#{I18n.locale.to_s}/admin/journal_papers/#{j.id.to_s}",
|
||||
"paper_title" => j.paper_title,
|
||||
"journal_title" => j.journal_title,
|
||||
"keywords" => j.keywords,
|
||||
"abstract" => j.abstract,
|
||||
"files" => files
|
||||
}
|
||||
end
|
||||
journals
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue