2014-11-18 11:03:18 +00:00
|
|
|
class Desktop::JournalPapersController < DesktopAdminController
|
2014-11-18 12:55:07 +00:00
|
|
|
def menu
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"title" => "List",
|
|
|
|
"layout" => "list",
|
2014-11-19 10:26:33 +00:00
|
|
|
"data" => get_paper_list
|
2014-11-18 12:55:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"title" => "Add/Edit",
|
|
|
|
"layout" => "form",
|
2014-11-19 11:24:56 +00:00
|
|
|
"data" => {"form" => form_data,"form_url" => "/something/"} }
|
2014-11-18 12:55:07 +00:00
|
|
|
]
|
2014-11-18 11:03:18 +00:00
|
|
|
end
|
2014-11-19 10:26:33 +00:00
|
|
|
|
2014-11-19 11:24:56 +00:00
|
|
|
def form_data
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"type" => "text",
|
|
|
|
"id" => "text",
|
|
|
|
"label" => {
|
|
|
|
"en" => "Title English",
|
|
|
|
"zh_tw" => "Title Chinese"
|
|
|
|
},
|
|
|
|
"placeholder" => {
|
|
|
|
"en" => "Title English",
|
|
|
|
"zh_tw" => "Title Chinese"
|
|
|
|
},
|
|
|
|
"name" => "journal_papers[title]",
|
|
|
|
"multilanguage" => true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type" => "checkbox",
|
|
|
|
"label" => "Check Box",
|
|
|
|
"name" => "journal_papers[checkbox]",
|
|
|
|
"option" => [{
|
|
|
|
"id" => "A",
|
|
|
|
"label" => {
|
|
|
|
"en" => "Check Box English",
|
|
|
|
"zh_tw" => "Check Box Chinese"
|
|
|
|
},
|
|
|
|
"value" => {
|
|
|
|
"en" => "A_en",
|
|
|
|
"zh_tw" => "A_zh_tw"
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
"id" => "B",
|
|
|
|
"label" => {
|
|
|
|
"en" => "Check Box English",
|
|
|
|
"zh_tw" => "Check Box Chinese"
|
|
|
|
},
|
|
|
|
"value" => {
|
|
|
|
"en" => "B_en",
|
|
|
|
"zh_tw" => "B_zh_tw"
|
|
|
|
}
|
|
|
|
}],
|
|
|
|
"multilanguage" => true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type" => "radio",
|
|
|
|
"label" => "Radio",
|
|
|
|
"name" => "journal_papers[radio]",
|
|
|
|
"option" => [{
|
|
|
|
"id" => "C",
|
|
|
|
"label" => {
|
|
|
|
"en" => "Radio1 English",
|
|
|
|
"zh_tw" => "Radio1 Chinese"
|
|
|
|
},
|
|
|
|
"value" => {
|
|
|
|
"en" => "A_en",
|
|
|
|
"zh_tw" => "A_zh_tw"
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
"id" => "D",
|
|
|
|
"label" => {
|
|
|
|
"en" => "Radio2 English",
|
|
|
|
"zh_tw" => "Radio2 Chinese"
|
|
|
|
},
|
|
|
|
"value" => {
|
|
|
|
"en" => "B_en",
|
|
|
|
"zh_tw" => "B_zh_tw"
|
|
|
|
}
|
|
|
|
}],
|
|
|
|
"multilanguage" => true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type" => "select",
|
|
|
|
"id" => "select",
|
|
|
|
"label" => "Select",
|
|
|
|
"name" => "journal_papers[select]",
|
|
|
|
"option" => [{
|
|
|
|
"text" => {
|
|
|
|
"en" => "Option1 English",
|
|
|
|
"zh_tw" => "Option1 Chinese"
|
|
|
|
},
|
|
|
|
"value" => {
|
|
|
|
"en" => "A_en",
|
|
|
|
"zh_tw" => "A_zh_tw"
|
|
|
|
},
|
|
|
|
"selected" => true
|
|
|
|
},{
|
|
|
|
"text" => {
|
|
|
|
"en" => "Option2 English",
|
|
|
|
"zh_tw" => "Option2 Chinese"
|
|
|
|
},
|
|
|
|
"value" => {
|
|
|
|
"en" => "B_en",
|
|
|
|
"zh_tw" => "B_zh_tw"
|
|
|
|
}
|
|
|
|
},{
|
|
|
|
"text" => {
|
|
|
|
"en" => "Option3 English",
|
|
|
|
"zh_tw" => "Option3 Chinese"
|
|
|
|
},
|
|
|
|
"value" => {
|
|
|
|
"en" => "C_en",
|
|
|
|
"zh_tw" => "C_zh_tw"
|
|
|
|
}
|
|
|
|
}],
|
|
|
|
"multilanguage" => true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type" => "textarea",
|
|
|
|
"id" => "textarea",
|
|
|
|
"label" => {
|
|
|
|
"en" => "Textarea English",
|
|
|
|
"zh_tw" => "Textarea Chinese"
|
|
|
|
},
|
|
|
|
"name" => "journal_papers[textarea]",
|
|
|
|
"multilanguage" => true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type" => "file",
|
|
|
|
"id" => "file",
|
|
|
|
"label" => {
|
|
|
|
"en" => "File English",
|
|
|
|
"zh_tw" => "File Chinese"
|
|
|
|
},
|
|
|
|
"name" => "journal_papers[file]",
|
|
|
|
"multilanguage" => true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2014-11-19 10:26:33 +00:00
|
|
|
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
|
|
|
|
{
|
2014-11-19 11:55:24 +00:00
|
|
|
"id" => j.id.to_s,
|
2014-11-19 10:26:33 +00:00
|
|
|
"paper_title" => j.paper_title,
|
|
|
|
"journal_title" => j.journal_title,
|
|
|
|
"keywords" => j.keywords,
|
|
|
|
"abstract" => j.abstract,
|
|
|
|
"files" => files
|
|
|
|
}
|
|
|
|
end
|
|
|
|
journals
|
|
|
|
end
|
|
|
|
|
2014-11-18 11:03:18 +00:00
|
|
|
end
|