This commit is contained in:
BoHung Chiu 2023-07-21 10:10:22 +08:00
parent 3f836c8374
commit 66c6b08d76
13 changed files with 45 additions and 17 deletions

View File

@ -1,8 +1,9 @@
class Admin::PublicationsController < OrbitAdminController class Admin::PublicationsController < OrbitAdminController
before_action :categories, only: [:index, :new, :edit] include Admin::PublicationsHelper
before_action :categories, only: [:index, :new, :edit]
def index def index
@table_fields = [:title, 'publications.chapter', :pub_date, :category] @table_fields = [:title, 'publications_.chapter', :pub_date, :category]
@filter_fields = filter_fields(@categories, @tags) @filter_fields = filter_fields(@categories, @tags)
@publications = Publication.order_by(sort) @publications = Publication.order_by(sort)
.with_categories(filters("category")) .with_categories(filters("category"))

View File

@ -219,7 +219,7 @@ class PublicationsController < ApplicationController
"widget-title" => t("module_name.publication"), "widget-title" => t("module_name.publication"),
"th_keywords" => t('chapter.keywords'), "th_keywords" => t('chapter.keywords'),
"th_tags" => t('tags'), "th_tags" => t('tags'),
"th_title" => t('publications.chapter'), "th_title" => t('publications_.chapter'),
"th_pub_date" => t('publication.pub_date'), "th_pub_date" => t('publication.pub_date'),
"th_chapter_title" => t('chapter.title'), "th_chapter_title" => t('chapter.title'),
"th_author" => t('chapter.author'), "th_author" => t('chapter.author'),

View File

@ -0,0 +1,27 @@
module Admin::PublicationsHelper
def page_for_publication(publication)
pub_page = nil
pages = Page.where(:module=>'publication').select{|page| page.enabled_for.include?(I18n.locale.to_s)}
pages.each do |page|
if page.categories.count ==1
if (page.categories.include?(publication.category.id.to_s) rescue false)
pub_page = page
end
end
break if !pub_page.nil?
end
if pub_page.nil?
pages.each do |page|
if (page.categories.include?(publication.category.id.to_s) rescue false)
pub_page = page
end
break if !pub_page.nil?
end
end
pub_page = pages.first if pub_page.nil?
request.protocol+(request.host_with_port+pub_page.url+'/'+publication.to_param).gsub('//','/') rescue "#"
end
end

View File

@ -3,7 +3,7 @@ class Chapter
include Slug include Slug
include OrbitTag::Taggable include OrbitTag::Taggable
field :title, type: String, localize: true field :title, as: :slug_title, type: String, localize: true
field :author, type: String, localize: true field :author, type: String, localize: true
field :author_description, type: String, localize: true field :author_description, type: String, localize: true
field :author_url, type: String field :author_url, type: String

View File

@ -6,7 +6,7 @@ class Publication
include OrbitCategory::Categorizable include OrbitCategory::Categorizable
include Slug include Slug
field :title, type: String, localize: true field :title, as: :slug_title, type: String, localize: true
field :pub_date, type: DateTime field :pub_date, type: DateTime
field :author, type: String, localize: true field :author, type: String, localize: true
field :author_description, type: String, localize: true field :author_description, type: String, localize: true

View File

@ -14,7 +14,7 @@
<% @publications.each do |node| %> <% @publications.each do |node| %>
<tr> <tr>
<td> <td>
<%= link_to node.title, publication_path(node.id) %> <%= link_to node.title, page_for_publication(node) %>
<div class="quick-edit"> <div class="quick-edit">
<ul class="nav nav-pills"> <ul class="nav nav-pills">
<% if can_edit_or_delete?(node) %> <% if can_edit_or_delete?(node) %>

View File

@ -49,7 +49,7 @@
</div> </div>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div> <div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<span class="btn btn-file"> <span class="btn btn-file">
<span class="fileupload-new"><%= t('publications.select_cover') %></span> <span class="fileupload-new"><%= t('publications_.select_cover') %></span>
<span class="fileupload-exists"><%= t(:change) %></span> <span class="fileupload-exists"><%= t(:change) %></span>
<%= f.file_field :cover %> <%= f.file_field :cover %>
</span> </span>

View File

@ -74,7 +74,7 @@
<% if can_edit_or_delete?(@publication) %> <% if can_edit_or_delete?(@publication) %>
<div class="bottomnav clearfix" style="left: 81px;"> <div class="bottomnav clearfix" style="left: 81px;">
<div class="action pull-right"> <div class="action pull-right">
<%= link_to t("publications.add_chapter"), new_admin_chapter_path(page: params[:page], publication_id: @publication.id), class: "btn btn-primary" %> <%= link_to t("publications_.add_chapter"), new_admin_chapter_path(page: params[:page], publication_id: @publication.id), class: "btn btn-primary" %>
</div> </div>
<%= content_tag :div, paginate(@chapters), class: "pagination pagination-centered" %> <%= content_tag :div, paginate(@chapters), class: "pagination pagination-centered" %>
</div> </div>

View File

@ -35,7 +35,7 @@ en:
search_placeholder: Please Input Keywords search_placeholder: Please Input Keywords
search: Search search: Search
publications: publications_:
publication: Publication publication: Publication
select_cover: Select cover select_cover: Select cover
add_chapter: Add chapter add_chapter: Add chapter

View File

@ -35,7 +35,7 @@ zh_tw:
search_placeholder: 請輸入關鍵字 search_placeholder: 請輸入關鍵字
search: 搜尋 search: 搜尋
publications: publications_:
publication: 出版品 publication: 出版品
select_cover: 選擇封面 select_cover: 選擇封面
add_chapter: 新增章節 add_chapter: 新增章節

View File

@ -26,7 +26,7 @@ module Publications
puts ['error in publications',e] puts ['error in publications',e]
end end
OrbitApp.registration "Publications", :type => "ModuleApp" do OrbitApp.registration "Publications", :type => "ModuleApp" do
module_label "publications.publication" module_label "publications_.publication"
base_url File.expand_path File.dirname(__FILE__) base_url File.expand_path File.dirname(__FILE__)
# widget_methods ['widget'] # widget_methods ['widget']
# widget_settings [{"data_count"=>30}] # widget_settings [{"data_count"=>30}]
@ -44,7 +44,7 @@ module Publications
end end
side_bar do side_bar do
head_label_i18n 'publications.publication', icon_class: "icon-book" head_label_i18n 'publications_.publication', icon_class: "icon-book"
available_for "users" available_for "users"
active_for_controllers (['admin/publications']) active_for_controllers (['admin/publications'])
head_link_path "admin_publications_path" head_link_path "admin_publications_path"

View File

@ -14,7 +14,7 @@
<span class="i-annc__status-wrap" data-list="statuses" data-level="1"> <span class="i-annc__status-wrap" data-list="statuses" data-level="1">
<span class="i-annc__status label status {{status-class}}">{{status}}</span> <span class="i-annc__status label status {{status-class}}">{{status}}</span>
</span> </span>
<a class="i-annc__title" href="{{link_to_show}}">{{title}}</a> <a class="i-annc__title i-publication_title" href="{{link_to_show}}">{{title}}</a>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@ -1,5 +1,5 @@
<div class="i-annc show-chapters-table"> <div class="i-publication show-chapters-table">
<table class="i-annc__table table table-hover table-striped"> <table class="i-publication__table table table-hover table-striped">
<thead> <thead>
<tr> <tr>
<th class="col-md-2"></th> <th class="col-md-2"></th>
@ -12,10 +12,10 @@
<tr> <tr>
<td> <td>
<span data-list="tags" data-level="1"> <span data-list="tags" data-level="1">
<span class="s-annc__tag">{{tag}}</span> <span class="s-publication__tag">{{tag}}</span>
</span> </span>
</td> </td>
<td><a href="{{link_to_show}}">{{title}}</a></td> <td><a href="{{link_to_show}}" class="i-chapter_title">{{title}}</a></td>
<td>{{author}}</td> <td>{{author}}</td>
<td>{{page}}</td> <td>{{page}}</td>
</tr> </tr>