Changes for FAQ to work with not latest but stable code

This commit is contained in:
chris 2013-03-28 15:05:52 +08:00
parent 468555a037
commit 3e96cfe514
10 changed files with 49 additions and 38 deletions

View File

@ -55,6 +55,9 @@ helper Admin::PagePartsHelper
when 'archive' when 'archive'
@categories = ArchiveFileCategory.all @categories = ArchiveFileCategory.all
@tags = ArchiveTag.all @tags = ArchiveTag.all
when 'faq'
@categories = QaCategory.all
@tags = FaqTag.all
end end
else else
@categories = nil @categories = nil
@ -168,6 +171,9 @@ helper Admin::PagePartsHelper
when 'archive' when 'archive'
@categories = ArchiveFileCategory.all @categories = ArchiveFileCategory.all
@tags = ArchiveTag.all @tags = ArchiveTag.all
when 'faq'
@categories = QaCategory.all
@tags = FaqTag.all
else else
@categories = [] @categories = []
@tags = [] @tags = []

View File

@ -7,7 +7,7 @@ class Qa
scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
field :question, localize: true field :title, localize: true
field :answer, localize: true field :answer, localize: true
has_and_belongs_to_many :tags, :class_name => "FaqTag" has_and_belongs_to_many :tags, :class_name => "FaqTag"
@ -32,7 +32,7 @@ class Qa
before_save :update_avliable_language, :clean_values before_save :update_avliable_language, :clean_values
validates :question, :at_least_one => true validates :title, :at_least_one => true
def self.search( category_id = nil ) def self.search( category_id = nil )
@ -66,7 +66,7 @@ class Qa
def update_avliable_language def update_avliable_language
VALID_LOCALES.each do |locale| VALID_LOCALES.each do |locale|
if (question_translations[locale].blank? rescue true) if (title_translations[locale].blank? rescue true)
self["available_for_#{locale}".to_sym] = false self["available_for_#{locale}".to_sym] = false
else else
self["available_for_#{locale}".to_sym] = true self["available_for_#{locale}".to_sym] = true

View File

@ -70,10 +70,10 @@
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>"> <div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<div class="title"> <div class="title">
<%= f.label :question , t('faq.question') %> <%= f.label :title , t('faq.question') %>
<%= f.fields_for :question_translations do |f| %> <%= f.fields_for :title_translations do |f| %>
<%= I18nVariable.from_locale(locale) %> <%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title', :value => (@qa.question_translations[locale] rescue nil) %> <%= f.text_field locale, :class=>'post-title', :value => (@qa.title_translations[locale] rescue nil) %>
<% end %> <% end %>
</div> </div>

View File

@ -21,7 +21,7 @@
</td> </td>
<td><%= qa.qa_category.title rescue nil %></td> <td><%= qa.qa_category.title rescue nil %></td>
<td> <td>
<%= link_to qa.question, panel_faq_front_end_qa_path(qa) %> <%= link_to qa.title, panel_faq_front_end_qa_path(qa) %>
<div class="quick-edit"> <div class="quick-edit">
<ul class="nav nav-pills hide"> <ul class="nav nav-pills hide">
<%if at_least_module_manager || qa.qa_category.cur_user_is_sub_manager_of(:edit)%> <%if at_least_module_manager || qa.qa_category.cur_user_is_sub_manager_of(:edit)%>

View File

@ -1,5 +1,5 @@
<%= render_sort_bar(true, delete_panel_faq_back_end_qas_path(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]), <%= render_sort_bar(true, delete_panel_faq_back_end_qas_path(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]),
['status', ['is_top', 'is_hot', 'is_hidden'], 'span1', :status], ['status', ['is_top', 'is_hot', 'is_hidden'], 'span1', :status],
['category', 'qa_category', 'span2', :category], ['category', 'qa_category', 'span2', :category],
['question', 'question','span3', :question], ['question', 'title','span3', 'faq.question'],
['tags', 'tags', 'span2', :tags]).html_safe %> ['tags', 'tags', 'span2', :tags]).html_safe %>

View File

@ -5,7 +5,7 @@
</li> </li>
<li> <li>
<b><%= t("faq.question") %></b> <b><%= t("faq.question") %></b>
<%= @qa.question %> <%= @qa.title %>
</li> </li>
<li> <li>
<b><%= t("faq.answer") %></b> <b><%= t("faq.answer") %></b>

View File

@ -1,28 +1,31 @@
<ul> <h1 class="h1"><%= @qa.title %></h1>
<li> <div class="info">
<b><%= t(:category) %></b> <div class="info1">
<%= @qa.qa_category.title rescue nil %> <span><%= t(:category) %> : <%= @qa.qa_category.title rescue nil %></span>
</li> </div>
<li> </div>
<b><%= t("faq.question") %></b> <div class="news_paragraph">
<%= @qa.question %>
</li>
<li>
<b><%= t("faq.answer") %></b>
<%= @qa.answer.html_safe rescue '' %> <%= @qa.answer.html_safe rescue '' %>
</li> </div>
<li> <div class="linkAndFile">
<b><%= t(:link) if !@qa.qa_links.blank? %></b> <% if @qa.qa_links.size > 0 %>
<div>
<i class="icons-link"></i>
<div class="showLink">
<% @qa.qa_links.each do | blink | %> <% @qa.qa_links.each do | blink | %>
<%= link_to blink.title, blink.url, :target => '_blank' %> <%= link_to blink.title, blink.url, :target => '_blank' %>
<% end %> <% end %>
</li> </div>
<li> </div>
<b><%= t("faq.file") if !@qa.qa_files.blank? %></b> <% end %>
<% if @qa.qa_files.size > 0 %>
<div>
<i class="icons-paperclip"></i>
<div class="showFile">
<% @qa.qa_files.each do | bfile | %> <% @qa.qa_files.each do | bfile | %>
<%= link_to bfile.title, bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %> <%= link_to bfile.title, bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %>
<% end %> <% end %>
</li> </div>
</ul> </div>
<% end %>
<%= link_back %> </div>

View File

@ -3,6 +3,7 @@ en:
faq: faq:
default_widget: default_widget:
question: Question question: Question
title: Question
answer: Answer answer: Answer
to_more: Read More to_more: Read More
qa_category_with_title: Category qa_category_with_title: Category

View File

@ -3,6 +3,7 @@ zh_tw:
faq: faq:
default_widget: default_widget:
question: 問題 question: 問題
title: 問題
answer: 回答 answer: 回答
to_more: 閱讀更多 to_more: 閱讀更多
qa_category_with_title: 類別 qa_category_with_title: 類別

View File

@ -22,9 +22,9 @@ module Faq
widgets do widgets do
default_widget do default_widget do
query 'Qa.all' query 'Qa.all'
enable ['typeA'] # enable ['typeA']
link_field :qa_category_with_title,{:method => 'panel_faq_front_end_qas_path',:args=>{:category_id => [:qa_category,:id]}} link_field :qa_category_with_title,{:method => 'panel_faq_front_end_qas_path',:args=>{:category_id => [:qa_category,:id]}}
link_field :question,{:method => 'panel_faq_front_end_qa_path',:args=>:self} link_field :title, {:method => 'panel_faq_front_end_qa_path',:args=>:self}
link_to_more 'panel_faq_front_end_qas_path',:title_i18n=> 'faq.default_widget.to_more' link_to_more 'panel_faq_front_end_qas_path',:title_i18n=> 'faq.default_widget.to_more'
end end