From 3e96cfe5147ee990b73661467220c497b165c5d3 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 28 Mar 2013 15:05:52 +0800 Subject: [PATCH] Changes for FAQ to work with not latest but stable code --- app/controllers/admin/pages_controller.rb | 6 ++ vendor/built_in_modules/faq/app/models/qa.rb | 6 +- .../panel/faq/back_end/qas/_form.html.erb | 6 +- .../views/panel/faq/back_end/qas/_qa.html.erb | 2 +- .../faq/back_end/qas/_sort_headers.html.erb | 2 +- .../panel/faq/back_end/qas/show.html.erb | 2 +- .../panel/faq/front_end/qas/show.html.erb | 57 ++++++++++--------- .../faq/config/locales/en.yml | 1 + .../faq/config/locales/zh_tw.yml | 1 + vendor/built_in_modules/faq/init.rb | 4 +- 10 files changed, 49 insertions(+), 38 deletions(-) diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 28b51ca4..dc96a67c 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -55,6 +55,9 @@ helper Admin::PagePartsHelper when 'archive' @categories = ArchiveFileCategory.all @tags = ArchiveTag.all + when 'faq' + @categories = QaCategory.all + @tags = FaqTag.all end else @categories = nil @@ -168,6 +171,9 @@ helper Admin::PagePartsHelper when 'archive' @categories = ArchiveFileCategory.all @tags = ArchiveTag.all + when 'faq' + @categories = QaCategory.all + @tags = FaqTag.all else @categories = [] @tags = [] diff --git a/vendor/built_in_modules/faq/app/models/qa.rb b/vendor/built_in_modules/faq/app/models/qa.rb index 81ce4af9..e457253c 100644 --- a/vendor/built_in_modules/faq/app/models/qa.rb +++ b/vendor/built_in_modules/faq/app/models/qa.rb @@ -7,7 +7,7 @@ class Qa scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } - field :question, localize: true + field :title, localize: true field :answer, localize: true has_and_belongs_to_many :tags, :class_name => "FaqTag" @@ -32,7 +32,7 @@ class Qa 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 ) @@ -66,7 +66,7 @@ class Qa def update_avliable_language 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 else self["available_for_#{locale}".to_sym] = true diff --git a/vendor/built_in_modules/faq/app/views/panel/faq/back_end/qas/_form.html.erb b/vendor/built_in_modules/faq/app/views/panel/faq/back_end/qas/_form.html.erb index 0621c8b9..3e723707 100644 --- a/vendor/built_in_modules/faq/app/views/panel/faq/back_end/qas/_form.html.erb +++ b/vendor/built_in_modules/faq/app/views/panel/faq/back_end/qas/_form.html.erb @@ -70,10 +70,10 @@
">
- <%= f.label :question , t('faq.question') %> - <%= f.fields_for :question_translations do |f| %> + <%= f.label :title , t('faq.question') %> + <%= f.fields_for :title_translations do |f| %> <%= 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 %>
diff --git a/vendor/built_in_modules/faq/app/views/panel/faq/back_end/qas/_qa.html.erb b/vendor/built_in_modules/faq/app/views/panel/faq/back_end/qas/_qa.html.erb index 158b2b8c..bcb1de1b 100644 --- a/vendor/built_in_modules/faq/app/views/panel/faq/back_end/qas/_qa.html.erb +++ b/vendor/built_in_modules/faq/app/views/panel/faq/back_end/qas/_qa.html.erb @@ -21,7 +21,7 @@ <%= qa.qa_category.title rescue nil %> - <%= link_to qa.question, panel_faq_front_end_qa_path(qa) %> + <%= link_to qa.title, panel_faq_front_end_qa_path(qa) %>
+
+ <% if @qa.qa_links.size > 0 %> +
+ + +
+ <% end %> + <% if @qa.qa_files.size > 0 %> +
+ +
+ <% @qa.qa_files.each do | bfile | %> + <%= link_to bfile.title, bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %> + <% end %> +
+
+ <% end %> +
diff --git a/vendor/built_in_modules/faq/config/locales/en.yml b/vendor/built_in_modules/faq/config/locales/en.yml index 9d73317c..5be79e88 100644 --- a/vendor/built_in_modules/faq/config/locales/en.yml +++ b/vendor/built_in_modules/faq/config/locales/en.yml @@ -3,6 +3,7 @@ en: faq: default_widget: question: Question + title: Question answer: Answer to_more: Read More qa_category_with_title: Category diff --git a/vendor/built_in_modules/faq/config/locales/zh_tw.yml b/vendor/built_in_modules/faq/config/locales/zh_tw.yml index 621a33e8..aa932e8d 100644 --- a/vendor/built_in_modules/faq/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/faq/config/locales/zh_tw.yml @@ -3,6 +3,7 @@ zh_tw: faq: default_widget: question: 問題 + title: 問題 answer: 回答 to_more: 閱讀更多 qa_category_with_title: 類別 diff --git a/vendor/built_in_modules/faq/init.rb b/vendor/built_in_modules/faq/init.rb index 0982f4c0..a2e4f783 100644 --- a/vendor/built_in_modules/faq/init.rb +++ b/vendor/built_in_modules/faq/init.rb @@ -22,9 +22,9 @@ module Faq widgets do default_widget do 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 :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' end