add journal show

This commit is contained in:
Archer Lin 2018-10-04 17:44:54 +08:00
parent 40a6273fe5
commit 54011e5ca5
8 changed files with 47 additions and 16 deletions

View File

@ -5,9 +5,8 @@ class Admin::ChaptersController < OrbitAdminController
end end
def index 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) @chapters = Chapter.order_by(sort).page(params[:page]).per(10)
render partial: "index" if request.xhr? render partial: "index" if request.xhr?
end end

View File

@ -33,8 +33,8 @@ class Admin::JournalsController < OrbitAdminController
def show def show
@journal = Journal.find(params[:id]) @journal = Journal.find(params[:id])
@chapters = @journal.chapters.page(params[:page]).per(10) @chapters = @journal.chapters.order_by(sort).page(params[:page]).per(10)
@table_fields = [:title, :author, :page] @table_fields = [:title, :author, :page, :sort_number]
end end
def destroy def destroy

View File

@ -30,7 +30,9 @@ class JournalsController < ApplicationController
pub_date: node.pub_date.strftime('%Y-%m-%d'), pub_date: node.pub_date.strftime('%Y-%m-%d'),
cover: (OrbitHelper.is_mobile_view ? node.cover.mobile.url : node.cover.url), cover: (OrbitHelper.is_mobile_view ? node.cover.mobile.url : node.cover.url),
chapters: node.chapters.count, 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 end
{ {
@ -51,10 +53,12 @@ class JournalsController < ApplicationController
def show def show
params = OrbitHelper.params params = OrbitHelper.params
if params[:list] == 'journal' if params[:mode] == 'many'
show_journal show_list
else elsif params[:mode] == 'chapter'
show_chapter show_chapter
else
show_journal
end end
end end
@ -64,7 +68,7 @@ class JournalsController < ApplicationController
private private
def show_journal def show_list
params = OrbitHelper.params params = OrbitHelper.params
journal = Journal.find_by(uid: params[:uid]) journal = Journal.find_by(uid: params[:uid])
chapters = Chapter.where(journal_id: journal.id).page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) 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: node.author,
author_description: node.author_description, author_description: node.author_description,
page: node.page, page: node.page,
text: node.text, link_to_show: OrbitHelper.url_to_show("#{node.to_param}?mode=chapter"),
link_to_show: OrbitHelper.url_to_show("#{node.to_param}?list=chapter"),
file: (node.file.present? ? node.file.url : ''), file: (node.file.present? ? node.file.url : ''),
file_class: (node.file.present? ? '' : 'hidden') file_class: (node.file.present? ? '' : 'hidden')
} }
@ -110,7 +113,27 @@ class JournalsController < ApplicationController
"text" => chapter.text, "text" => chapter.text,
"text_title" => t('chapter.text'), "text_title" => t('chapter.text'),
"extras" => { "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 end

View File

@ -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} %> <%= render partial: 'form', locals: {f: f} %>
<% end %> <% end %>

View File

@ -55,7 +55,10 @@
</td> </td>
<td> <td>
<%= chapter.page %> <%= chapter.page %>
</td>
<td> <td>
<%= chapter.sort_number %>
</td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>
@ -73,14 +76,14 @@
<div id="sort-chapters-modal" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true"> <div id="sort-chapters-modal" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Order Images</h3> <h3>Order Jurnals</h3>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<ul class="order-list"> <ul class="order-list">
<% @journal.chapters.asc(:sort_number).each do |chapter| %> <% @journal.chapters.asc(:sort_number).each do |chapter| %>
<li class="order-list-chapter" data-chapter-id="<%= chapter.id.to_s %>"> <li class="order-list-chapter" data-chapter-id="<%= chapter.id.to_s %>">
<i class="icons-list-2"></i> <i class="icons-list-2"></i>
<h4><%= chapter.title %> <h4><%= chapter.title %>:<%= chapter.page%><h4>
</li> </li>
<% end %> <% end %>
</ul> </ul>

View File

@ -1,6 +1,8 @@
<% data = action_data %> <% data = action_data %>
<% if data['extras']['mode'] == 'many' %> <% if data['extras']['mode'] == 'many' %>
<%= render_view %> <%= render_view %>
<% else %> <% elsif data['extras']['mode'] == 'chapter' %>
<%= render_view('show_detail') %> <%= render_view('show_detail') %>
<% else %>
<%= render_view('show_journal') %>
<% end %> <% end %>

View File

@ -10,6 +10,7 @@ en:
author: Chief editor author: Chief editor
chapter: Chapter list chapter: Chapter list
chapters: Chapter count chapters: Chapter count
pub_information: Publishing information
chapter: chapter:
title: Title title: Title
@ -17,6 +18,7 @@ en:
author_description: Author description author_description: Author description
text: Inner text text: Inner text
page: Page page: Page
sort_number: Sort number
journals: journals:
journal: Journal journal: Journal

View File

@ -10,6 +10,7 @@ zh_tw:
author: 主編/作者 author: 主編/作者
chapter: 章節列表 chapter: 章節列表
chapters: 章節數 chapters: 章節數
pub_information: 出版資訊
chapter: chapter:
title: 標題 title: 標題
@ -19,6 +20,7 @@ zh_tw:
page: 頁次 page: 頁次
file: 期刊檔案 file: 期刊檔案
action: 動作 action: 動作
sort_number: 排序
journals: journals:
journal: 通訊期刊 journal: 通訊期刊