add journal show
This commit is contained in:
parent
40a6273fe5
commit
54011e5ca5
|
@ -5,9 +5,8 @@ class Admin::ChaptersController < OrbitAdminController
|
|||
end
|
||||
|
||||
def index
|
||||
@table_fields = [:title, :author, :page, :author_description]
|
||||
@table_fields = [:title, :author, :page, :sort_number]
|
||||
@chapters = Chapter.order_by(sort).page(params[:page]).per(10)
|
||||
|
||||
render partial: "index" if request.xhr?
|
||||
end
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ class Admin::JournalsController < OrbitAdminController
|
|||
|
||||
def show
|
||||
@journal = Journal.find(params[:id])
|
||||
@chapters = @journal.chapters.page(params[:page]).per(10)
|
||||
@table_fields = [:title, :author, :page]
|
||||
@chapters = @journal.chapters.order_by(sort).page(params[:page]).per(10)
|
||||
@table_fields = [:title, :author, :page, :sort_number]
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
|
|
@ -30,7 +30,9 @@ class JournalsController < ApplicationController
|
|||
pub_date: node.pub_date.strftime('%Y-%m-%d'),
|
||||
cover: (OrbitHelper.is_mobile_view ? node.cover.mobile.url : node.cover.url),
|
||||
chapters: node.chapters.count,
|
||||
link_to_show: OrbitHelper.url_to_show("#{node.to_param}?list=journal"),
|
||||
link_to_show: OrbitHelper.url_to_show("#{node.to_param}?mode=journal"),
|
||||
link_to_list: OrbitHelper.url_to_show("#{node.to_param}?mode=many"),
|
||||
|
||||
}
|
||||
end
|
||||
{
|
||||
|
@ -51,10 +53,12 @@ class JournalsController < ApplicationController
|
|||
|
||||
def show
|
||||
params = OrbitHelper.params
|
||||
if params[:list] == 'journal'
|
||||
show_journal
|
||||
else
|
||||
if params[:mode] == 'many'
|
||||
show_list
|
||||
elsif params[:mode] == 'chapter'
|
||||
show_chapter
|
||||
else
|
||||
show_journal
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -64,7 +68,7 @@ class JournalsController < ApplicationController
|
|||
|
||||
private
|
||||
|
||||
def show_journal
|
||||
def show_list
|
||||
params = OrbitHelper.params
|
||||
journal = Journal.find_by(uid: params[:uid])
|
||||
chapters = Chapter.where(journal_id: journal.id).page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
||||
|
@ -76,8 +80,7 @@ class JournalsController < ApplicationController
|
|||
author: node.author,
|
||||
author_description: node.author_description,
|
||||
page: node.page,
|
||||
text: node.text,
|
||||
link_to_show: OrbitHelper.url_to_show("#{node.to_param}?list=chapter"),
|
||||
link_to_show: OrbitHelper.url_to_show("#{node.to_param}?mode=chapter"),
|
||||
file: (node.file.present? ? node.file.url : ''),
|
||||
file_class: (node.file.present? ? '' : 'hidden')
|
||||
}
|
||||
|
@ -110,7 +113,27 @@ class JournalsController < ApplicationController
|
|||
"text" => chapter.text,
|
||||
"text_title" => t('chapter.text'),
|
||||
"extras" => {
|
||||
"mode" => "one"
|
||||
"mode" => "chapter"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def show_journal
|
||||
params = OrbitHelper.params
|
||||
journal = Journal.find_by(uid: params[:uid])
|
||||
{
|
||||
"title" => journal.title,
|
||||
"title_title" => t('journal.title'),
|
||||
"author" => journal.author,
|
||||
"author_title" => t('journal.author'),
|
||||
"cover" => journal.cover.url,
|
||||
"cover_title" => t('journal.cover'),
|
||||
"pub_date" => journal.pub_date,
|
||||
"pub_date_title" => t('journal.pub_date'),
|
||||
"pub_information" => journal.pub_information,
|
||||
"pub_information_title" => t('journal.pub_information'),
|
||||
"extras" => {
|
||||
"mode" => "journal"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<%= form_for @chapter, url: admin_chapter_path(@chapter), html: {class: "form-horizontal main-forms"} do |f| %>
|
||||
<%= form_for @chapter, url: {action: :update}, html: {class: "form-horizontal main-forms"} do |f| %>
|
||||
<%= render partial: 'form', locals: {f: f} %>
|
||||
<% end %>
|
||||
|
|
|
@ -55,7 +55,10 @@
|
|||
</td>
|
||||
<td>
|
||||
<%= chapter.page %>
|
||||
</td>
|
||||
<td>
|
||||
<%= chapter.sort_number %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
@ -73,14 +76,14 @@
|
|||
<div id="sort-chapters-modal" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3>Order Images</h3>
|
||||
<h3>Order Jurnals</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ul class="order-list">
|
||||
<% @journal.chapters.asc(:sort_number).each do |chapter| %>
|
||||
<li class="order-list-chapter" data-chapter-id="<%= chapter.id.to_s %>">
|
||||
<i class="icons-list-2"></i>
|
||||
<h4><%= chapter.title %>
|
||||
<h4><%= chapter.title %>:<%= chapter.page%><h4>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<% data = action_data %>
|
||||
<% if data['extras']['mode'] == 'many' %>
|
||||
<%= render_view %>
|
||||
<% else %>
|
||||
<% elsif data['extras']['mode'] == 'chapter' %>
|
||||
<%= render_view('show_detail') %>
|
||||
<% else %>
|
||||
<%= render_view('show_journal') %>
|
||||
<% end %>
|
||||
|
|
|
@ -10,6 +10,7 @@ en:
|
|||
author: Chief editor
|
||||
chapter: Chapter list
|
||||
chapters: Chapter count
|
||||
pub_information: Publishing information
|
||||
|
||||
chapter:
|
||||
title: Title
|
||||
|
@ -17,6 +18,7 @@ en:
|
|||
author_description: Author description
|
||||
text: Inner text
|
||||
page: Page
|
||||
sort_number: Sort number
|
||||
|
||||
journals:
|
||||
journal: Journal
|
||||
|
|
|
@ -10,6 +10,7 @@ zh_tw:
|
|||
author: 主編/作者
|
||||
chapter: 章節列表
|
||||
chapters: 章節數
|
||||
pub_information: 出版資訊
|
||||
|
||||
chapter:
|
||||
title: 標題
|
||||
|
@ -19,6 +20,7 @@ zh_tw:
|
|||
page: 頁次
|
||||
file: 期刊檔案
|
||||
action: 動作
|
||||
sort_number: 排序
|
||||
|
||||
journals:
|
||||
journal: 通訊期刊
|
||||
|
|
Loading…
Reference in New Issue