Add rss2_id and rich_title to let custom add style to title in admin page(it will show in frontend show index).
Add frontend show page link to admin index page.
This commit is contained in:
parent
468f82fecd
commit
82457c4951
|
@ -14,7 +14,7 @@ class Admin::FaqsController < OrbitAdminController
|
|||
.with_status(filters("status"))
|
||||
|
||||
@qas = search_data(@qas,[:title]).page(params[:page]).per(10)
|
||||
|
||||
@faq_page_url = Page.where(:module=>'faq').first.url rescue '#'
|
||||
render :partial => "index" if request.xhr?
|
||||
end
|
||||
|
||||
|
@ -87,10 +87,23 @@ class Admin::FaqsController < OrbitAdminController
|
|||
|
||||
private
|
||||
def setup_vars
|
||||
if ModuleApp.where(:key => "faq").count > 1
|
||||
module_apps = ModuleApp.where(:key => "faq").to_a
|
||||
categories_count = module_apps.map{|m| m.categories.count}
|
||||
module_apps = module_apps.map.with_index{|m,i| {'id'=>m.id,'count'=>categories_count[i]}}.sort_by{|m| -m['count']}
|
||||
module_apps[1..-1].each do |m|
|
||||
module_app = ModuleApp.find(m['id'])
|
||||
module_app.categories.each{|c| c.update(:module_app_id=>module_apps.first['id'])}
|
||||
module_app.destroy
|
||||
end
|
||||
end
|
||||
@module_app = ModuleApp.where(:key => "faq").first
|
||||
end
|
||||
|
||||
def create_params
|
||||
params.require(:qa).permit!
|
||||
qa_params = params.require(:qa).permit!
|
||||
qa_params['title_translations'] = {}
|
||||
qa_params['rich_title_translations'].each{|locale,value| temp_title = Nokogiri::HTML(value);qa_params['title_translations'][locale] = temp_title.inner_text;}
|
||||
return qa_params
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,13 +11,14 @@ class Qa
|
|||
include Slug
|
||||
|
||||
field :title,as: :slug_title, localize: true
|
||||
field :rich_title, localize: true
|
||||
field :answer, localize: true
|
||||
|
||||
field :create_user_id
|
||||
field :update_user_id
|
||||
field :uid, type: String
|
||||
field :order_position, type: Integer, default: -1
|
||||
|
||||
field :rss2_id, type: String
|
||||
has_many :qa_links, :autosave => true, :dependent => :destroy
|
||||
has_many :qa_files, :autosave => true, :dependent => :destroy
|
||||
|
||||
|
@ -32,7 +33,11 @@ class Qa
|
|||
before_save :clean_values
|
||||
|
||||
# validates :title, :at_least_one => true
|
||||
|
||||
after_initialize do |record|
|
||||
if record.rich_title.blank? && !record.title.blank?
|
||||
record.update(:rich_title_translations => record.title_translations)
|
||||
end
|
||||
end
|
||||
|
||||
def self.search( category_id = nil )
|
||||
|
||||
|
|
|
@ -92,10 +92,10 @@
|
|||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
|
||||
<div class="control-group input-title">
|
||||
<%= f.label :title , t('faq.question'), :class=>"control-label muted" %>
|
||||
<%= f.label :rich_title , t('faq.question'), :class=>"control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :title_translations do |f| %>
|
||||
<%= f.text_field locale, :class=>'post-title', :value => (@qa.title_translations[locale] rescue nil) %>
|
||||
<%= f.fields_for :rich_title_translations do |f| %>
|
||||
<%= f.text_area locale, :class=>'post-title ckeditor input-block-level', :value => (@qa.rich_title_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -17,7 +17,11 @@
|
|||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" target="_blank"><%= qa.title %></a>
|
||||
<% if @faq_page_url != '#'%>
|
||||
<a href='<%="/#{I18n.locale}#{@faq_page_url}/#{qa.title[0..6]}-#{qa.uid}"%>' target="_blank"><%= qa.title %></a>
|
||||
<% else %>
|
||||
<a href="#" target="_blank"><%= qa.title %></a>
|
||||
<% end %>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills">
|
||||
<% if can_edit_or_delete?(qa) %>
|
||||
|
|
Loading…
Reference in New Issue