From edb2a2dea24d8ae13e32b305456f3dc5325b7213 Mon Sep 17 00:00:00 2001 From: Dmitry Salashnik Date: Tue, 4 Dec 2012 16:41:07 +0200 Subject: [PATCH 1/4] update translation files --- config/locales/cs.yml | 8 ++++---- config/locales/de.yml | 8 ++++---- config/locales/en.yml | 8 ++++---- config/locales/fr.yml | 8 ++++---- config/locales/pl.yml | 8 ++++---- config/locales/pt-BR.yml | 8 ++++---- config/locales/pt.yml | 8 ++++---- config/locales/ru.yml | 8 ++++---- config/locales/zh-TW.yml | 8 ++++---- config/locales/zh.yml | 8 ++++---- 10 files changed, 40 insertions(+), 40 deletions(-) diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 31df261..3ef5dea 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -16,7 +16,7 @@ cs: label_info_for_input_id: (Prosím vyplňte id) label_manage: Spravovat label_faq_setting: Nastavení FAQ - label_updated_time_by: Upraveno uživatelem {{author}} před {{age}} + label_updated_time_by: Upraveno uživatelem %{author} před %{age} field_question: Otázka field_answer: Odpověď @@ -31,11 +31,11 @@ cs: field_faq_note: FAQ poznámka(Zobrazeno před seznamem FAQ) field_note: FAQ poznámka - text_faq_category_destroy_question: Nějaké FAQ ({{value}}) je již přiřazeno do této kategorie. Co chcete udělat? + text_faq_category_destroy_question: Nějaké FAQ (%{value}) je již přiřazeno do této kategorie. Co chcete udělat? text_faq_category_destroy_assignments: Odstranit přiřazení kategorie text_faq_category_reassign_to: Přenastavit FAQ této kategorii - text_faq_added: FAQ {{title}} bylo vytvořeno uživatelem {{author}}. - text_faq_updated: FAQ {{title}} bylo upraveno uživatelem {{author}}. + text_faq_added: FAQ %{title} bylo vytvořeno uživatelem %{author}. + text_faq_updated: FAQ %{title} bylo upraveno uživatelem %{author}. text_faq_pdf_title_not_set: Attention! Please specify PDF title in FAQ Settings first. permission_view_faqs: Zobraz FAQ diff --git a/config/locales/de.yml b/config/locales/de.yml index ecb7ae2..4151d75 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -16,7 +16,7 @@ de: label_info_for_input_id: (Bitte id eingeben) label_manage: Verwalten label_faq_setting: FAQ Einstellungen - label_updated_time_by: Updated by {{author}} {{age}} ago + label_updated_time_by: Updated by %{author} %{age} ago field_question: Frage field_answer: Antwort @@ -31,11 +31,11 @@ de: field_faq_note: FAQ Notiz (Wird vor der FAQ-Listeangezeigt) field_note: FAQ Notiz - text_faq_category_destroy_question: Manche FAQs ({{value}}) sind dieser Kategorie zugeordnet. Was möchten Sie tun? + text_faq_category_destroy_question: Manche FAQs (%{value}) sind dieser Kategorie zugeordnet. Was möchten Sie tun? text_faq_category_destroy_assignments: Entferne die Zuordnungen text_faq_category_reassign_to: FAQ wieder dieser Kategorie zuordnen - text_faq_added: FAQ {{title}} wurde von {{author}} erstellt. - text_faq_updated: FAQ {{title}} wurde von {{author}} verändert. + text_faq_added: FAQ %{title} wurde von %{author} erstellt. + text_faq_updated: FAQ %{title} wurde von %{author} verändert. text_faq_pdf_title_not_set: Achtung! Bitte legen Sie zuerst den Titel der PDF Datei fest. permission_view_faqs: FAQ anzeigen diff --git a/config/locales/en.yml b/config/locales/en.yml index a2fdf6c..1bca338 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -16,7 +16,7 @@ en: label_info_for_input_id: (Please input id) label_manage: Manage label_faq_setting: FAQ setting - label_updated_time_by: Updated by {{author}} {{age}} ago + label_updated_time_by: Updated by %{author} %{age} ago field_question: Question field_answer: Answer @@ -31,11 +31,11 @@ en: field_faq_note: FAQ note(Displayed before the FAQ list) field_note: FAQ note - text_faq_category_destroy_question: Some FAQ ({{value}}) is assigned to this category. What do you want to do ? + text_faq_category_destroy_question: Some FAQ (%{value}) is assigned to this category. What do you want to do ? text_faq_category_destroy_assignments: Remove category assignments text_faq_category_reassign_to: Reassign FAQ to this category - text_faq_added: FAQ {{title}} has been created by {{author}}. - text_faq_updated: FAQ {{title}} has been updated by {{author}}. + text_faq_added: FAQ %{title} has been created by %{author}. + text_faq_updated: FAQ %{title} has been updated by %{author}. text_faq_pdf_title_not_set: Attention! Please specify PDF title in FAQ Settings first. permission_view_faqs: View FAQ diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 6e83389..2ccc8c6 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -16,7 +16,7 @@ fr: label_info_for_input_id: (Merci de saisir l'identifiant) label_manage: Gérer label_faq_setting: Paramètres de la FAQ - label_updated_time_by: Mise-à-jour par {{author}} {{age}} + label_updated_time_by: Mise-à-jour par %{author} %{age} field_question: Question field_answer: Réponse @@ -31,11 +31,11 @@ fr: field_faq_note: Note de la FAQ (affichée avant la liste des FAQ) field_note: Note de la FAQ - text_faq_category_destroy_question: Certaines FAQ ({{value}}) sont assignée à cette catégorie. Que voulez-vous faire ? + text_faq_category_destroy_question: Certaines FAQ (%{value}) sont assignée à cette catégorie. Que voulez-vous faire ? text_faq_category_destroy_assignments: Effacer les assignations de catégorie text_faq_category_reassign_to: Ré-assigner les FAQ de cette catégorie - text_faq_added: FAQ {{title}} créé par {{author}}. - text_faq_updated: FAQ {{title}} mise-à-jour par {{author}}. + text_faq_added: FAQ %{title} créé par %{author}. + text_faq_updated: FAQ %{title} mise-à-jour par %{author}. text_faq_pdf_title_not_set: Attention ! Il faut spécifier le titre du PDF dans les paramètres de la FAQ d'abord. permission_view_faqs: Voir la FAQ diff --git a/config/locales/pl.yml b/config/locales/pl.yml index fb897b3..68b74cd 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -16,7 +16,7 @@ pl: label_info_for_input_id: (Wpisz id) label_manage: Zarządzaj label_faq_setting: Ustawienia FAQ - label_updated_time_by: Zaktualizowane przez {{author}} {{age}} temu + label_updated_time_by: Zaktualizowane przez %{author} %{age} temu field_question: Pytanie field_answer: Odpowiedź @@ -31,11 +31,11 @@ pl: field_faq_note: Opis FAQ (Wyświetlany przed lista pytań) field_note: Notatka do FAQ - text_faq_category_destroy_question: Z tą kategorią powiązane są FAQ ({{value}}). Co chcesz zrobić? + text_faq_category_destroy_question: Z tą kategorią powiązane są FAQ (%{value}). Co chcesz zrobić? text_faq_category_destroy_assignments: Usuń przypisanie do kategorii text_faq_category_reassign_to: Przydziel FAQ do tej kategorii - text_faq_added: FAQ {{title}} zostało stworzone przez {{author}}. - text_faq_updated: FAQ {{title}} zostało zaktualizowane przez {{author}}. + text_faq_added: FAQ %{title} zostało stworzone przez %{author}. + text_faq_updated: FAQ %{title} zostało zaktualizowane przez %{author}. text_faq_pdf_title_not_set: Uwaga! Ustaw tytuł dokumentu w Ustawieniach FAQ. permission_view_faqs: Przeglądanie FAQ diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 50901f2..98c8b24 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -16,7 +16,7 @@ pt-BR: label_info_for_input_id: (Favor forneça id) label_manage: Gerenciar label_faq_setting: FAQ configuração - label_updated_time_by: Atualizado por {{author}} {{age}} + label_updated_time_by: Atualizado por %{author} %{age} field_question: Questão field_answer: Resposta @@ -31,11 +31,11 @@ pt-BR: field_faq_note: FAQ nota(Visualizado antes da FAQ lista) field_note: FAQ nota - text_faq_category_destroy_question: Alguma FAQ ({{value}}) está atribuída a esta categoria. O que você quer fazer ? + text_faq_category_destroy_question: Alguma FAQ (%{value}) está atribuída a esta categoria. O que você quer fazer ? text_faq_category_destroy_assignments: Remover atribuições da categora text_faq_category_reassign_to: Reatribuir FAQ a esta categoria - text_faq_added: FAQ {{title}} foi criada por {{author}}. - text_faq_updated: FAQ {{title}} foi atualizada por {{author}}. + text_faq_added: FAQ %{title} foi criada por %{author}. + text_faq_updated: FAQ %{title} foi atualizada por %{author}. text_faq_pdf_title_not_set: Atenção! Favor especifique título PDF nas configurações FAQ inicialmente. permission_view_faqs: Visualizar FAQ diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 8318d4b..eba37ac 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -16,7 +16,7 @@ pt: label_info_for_input_id: (Favor forneça id) label_manage: Gerenciar label_faq_setting: FAQ configuração - label_updated_time_by: Atualizado por {{author}} {{age}} + label_updated_time_by: Atualizado por %{author} %{age} field_question: Questão field_answer: Resposta @@ -31,11 +31,11 @@ pt: field_faq_note: FAQ nota(Visualizado antes da FAQ lista) field_note: FAQ nota - text_faq_category_destroy_question: Alguma FAQ ({{value}}) está atribuída a esta categoria. O que você quer fazer ? + text_faq_category_destroy_question: Alguma FAQ (%{value}) está atribuída a esta categoria. O que você quer fazer ? text_faq_category_destroy_assignments: Remover atribuições da categora text_faq_category_reassign_to: Reatribuir FAQ a esta categoria - text_faq_added: FAQ {{title}} foi criada por {{author}}. - text_faq_updated: FAQ {{title}} foi atualizada por {{author}}. + text_faq_added: FAQ %{title} foi criada por %{author}. + text_faq_updated: FAQ %{title} foi atualizada por %{author}. text_faq_pdf_title_not_set: Atenção! Favor especifique título PDF nas configurações FAQ inicialmente. permission_view_faqs: Visualizar FAQ diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 8ca0b3f..c9ccb3f 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -16,7 +16,7 @@ ru: label_info_for_input_id: (введите номер) label_manage: Управление label_faq_setting: Настройки ЧаВо - label_updated_time_by: Обновлен {{author}} {{age}} назад + label_updated_time_by: Обновлен %{author} %{age} назад field_question: Вопрос field_answer: Ответ @@ -31,11 +31,11 @@ ru: field_faq_note: Заметка ЧаВо (выводится перед списком вопросов) field_note: FAQ note - text_faq_category_destroy_question: Некоторые ЧаВо ({{value}}) отнесены к этой категории. Что Вы хотите сделать ? + text_faq_category_destroy_question: Некоторые ЧаВо (%{value}) отнесены к этой категории. Что Вы хотите сделать ? text_faq_category_destroy_assignments: Убрать привязку к категории text_faq_category_reassign_to: Перевести вопросы в эту категорию - text_faq_added: ЧаВо {{title}} добавлен {{author}}. - text_faq_updated: ЧаВо {{title}} обновлен {{author}}. + text_faq_added: ЧаВо %{title} добавлен %{author}. + text_faq_updated: ЧаВо %{title} обновлен %{author}. text_faq_pdf_title_not_set: Attention! Please specify PDF title in FAQ Settings first. permission_view_faqs: View FAQ diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index e40b67a..d84856a 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -16,7 +16,7 @@ zh-TW: label_info_for_input_id: (請輸入編號) label_manage: 管理 label_faq_setting: FAQ配置 - label_updated_time_by: 由 {{author}} 在 {{age}} 之前更新 + label_updated_time_by: 由 %{author} 在 %{age} 之前更新 field_question: 問題 field_answer: 解答 @@ -31,11 +31,11 @@ zh-TW: field_faq_note: FAQ說明(顯示在FAQ列表前) field_note: FAQ說明 - text_faq_category_destroy_question: 有一些FAQ({{value}} 個)屬於此類別。您想進行哪種操作? + text_faq_category_destroy_question: 有一些FAQ(%{value} 個)屬於此類別。您想進行哪種操作? text_faq_category_destroy_assignments: 刪除FAQ的所屬類別(FAQ變為無類別) text_faq_category_reassign_to: 為FAQ選擇其它類別 - text_faq_added: FAQ {{title}} 已由 {{author}} 創建。 - text_faq_updated: FAQ {{title}} 已由 {{author}} 更新。 + text_faq_added: FAQ %{title} 已由 %{author} 創建。 + text_faq_updated: FAQ %{title} 已由 %{author} 更新。 text_faq_pdf_title_not_set: 注意!請在FAQ配置中設置PDF文檔的標題 permission_view_faqs: 查看FAQ diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 002682b..59d2912 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -16,7 +16,7 @@ zh: label_info_for_input_id: (请输入编号) label_manage: 管理 label_faq_setting: FAQ配置 - label_updated_time_by: 由 {{author}} 在 {{age}} 之前更新 + label_updated_time_by: 由 %{author} 在 %{age} 之前更新 field_question: 问题 field_answer: 解答 @@ -31,11 +31,11 @@ zh: field_faq_note: FAQ说明(显示在FAQ列表前) field_note: FAQ说明 - text_faq_category_destroy_question: 有一些FAQ({{value}} 个)属于此类别。您想进行哪种操作? + text_faq_category_destroy_question: 有一些FAQ(%{value} 个)属于此类别。您想进行哪种操作? text_faq_category_destroy_assignments: 删除FAQ的所属类别(FAQ变为无类别) text_faq_category_reassign_to: 为FAQ选择其它类别 - text_faq_added: FAQ {{title}} 已由 {{author}} 创建。 - text_faq_updated: FAQ {{title}} 已由 {{author}} 更新。 + text_faq_added: FAQ %{title} 已由 %{author} 创建。 + text_faq_updated: FAQ %{title} 已由 %{author} 更新。 text_faq_pdf_title_not_set: 注意!请在FAQ配置中设置PDF文档的标题 permission_view_faqs: 查看FAQ From dd2a80181c7bc24f2423099458c899bce43f6f61 Mon Sep 17 00:00:00 2001 From: Dmitry Salashnik Date: Thu, 6 Dec 2012 16:51:53 +0200 Subject: [PATCH 2/4] Redmine 2.x support --- README | 6 +++ app/controllers/ezfaq_controller.rb | 26 +++++----- app/controllers/faq_categories_controller.rb | 8 +-- app/helpers/ezfaq_helper.rb | 26 ---------- app/models/faq_mailer.rb | 42 ++++------------ .../ezfaq/_add_faq_category_modal.html.erb | 11 ++++ app/views/ezfaq/_edit.html.erb | 50 ------------------- .../ezfaq/_faq_category_modal_create.js.erb | 6 +++ app/views/ezfaq/_form.html.erb | 41 +++++++++------ app/views/ezfaq/add_faq_category.html.erb | 8 +++ app/views/ezfaq/add_faq_category.js.erb | 2 + app/views/ezfaq/add_faq_category.rhtml | 6 --- app/views/ezfaq/copy.html.erb | 4 +- app/views/ezfaq/edit.html.erb | 16 +++--- app/views/ezfaq/faq_setting.html.erb | 4 +- app/views/ezfaq/index.html.erb | 2 +- app/views/ezfaq/new.html.erb | 16 +++--- app/views/ezfaq/show.html.erb | 13 ++--- app/views/ezfaq/show_history_version.html.erb | 24 +++++---- app/views/faq_categories/destroy.html.erb | 3 +- app/views/faq_categories/edit.html.erb | 2 +- .../{_faq_text_html.rhtml => _faq.html.erb} | 0 .../{_faq_text_plain.rhtml => _faq.text.erb} | 0 app/views/faq_mailer/faq_add.html.erb | 3 ++ ..._add.text.plain.rhtml => faq_add.text.erb} | 2 +- app/views/faq_mailer/faq_add.text.html.rhtml | 3 -- app/views/faq_mailer/faq_update.html.erb | 3 ++ ...e.text.plain.rhtml => faq_update.text.erb} | 2 +- .../faq_mailer/faq_update.text.html.rhtml | 3 -- config/routes.rb | 41 +++++++++++++++ init.rb | 26 ++++++---- lib/attachment_patch.rb | 30 ----------- lib/ezfaq_attachment_patch.rb | 36 +++++++++++++ 33 files changed, 229 insertions(+), 236 deletions(-) delete mode 100644 app/helpers/ezfaq_helper.rb create mode 100644 app/views/ezfaq/_add_faq_category_modal.html.erb delete mode 100644 app/views/ezfaq/_edit.html.erb create mode 100644 app/views/ezfaq/_faq_category_modal_create.js.erb create mode 100644 app/views/ezfaq/add_faq_category.html.erb create mode 100644 app/views/ezfaq/add_faq_category.js.erb delete mode 100644 app/views/ezfaq/add_faq_category.rhtml rename app/views/faq_mailer/{_faq_text_html.rhtml => _faq.html.erb} (100%) rename app/views/faq_mailer/{_faq_text_plain.rhtml => _faq.text.erb} (100%) create mode 100644 app/views/faq_mailer/faq_add.html.erb rename app/views/faq_mailer/{faq_add.text.plain.rhtml => faq_add.text.erb} (55%) delete mode 100644 app/views/faq_mailer/faq_add.text.html.rhtml create mode 100644 app/views/faq_mailer/faq_update.html.erb rename app/views/faq_mailer/{faq_update.text.plain.rhtml => faq_update.text.erb} (56%) delete mode 100644 app/views/faq_mailer/faq_update.text.html.rhtml create mode 100644 config/routes.rb delete mode 100644 lib/attachment_patch.rb create mode 100644 lib/ezfaq_attachment_patch.rb diff --git a/README b/README index 4edf0b1..b0fab74 100644 --- a/README +++ b/README @@ -1,3 +1,9 @@ +2012-12-06 +========== +Added compatibility with Redmine 2.x. +Compatibility with 1.x - not tested and may be corrupted + + 2011-06-01 ========== This is a fork of original ezfaq, a FAQ management plugin for Redmine by Zou Chaoqun. The goal is to fix bugs and merge existing patches for daily use. diff --git a/app/controllers/ezfaq_controller.rb b/app/controllers/ezfaq_controller.rb index eb07d46..0e0ce28 100644 --- a/app/controllers/ezfaq_controller.rb +++ b/app/controllers/ezfaq_controller.rb @@ -15,6 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + class EzfaqController < ApplicationController unloadable @@ -77,7 +78,7 @@ def new attachments = Attachment.attach_files(@faq, params[:attachments]) render_attachment_warning_if_needed(@faq) flash[:notice] = l(:notice_successful_create) - FaqMailer.deliver_faq_add(@project, @faq) + FaqMailer.faq_add(@project, @faq).deliver redirect_to :controller => 'ezfaq', :action => 'show', :id => @project, :faq_id => @faq return end @@ -93,14 +94,14 @@ def preview def edit @faq_categories = FaqCategory.find(:all, :conditions => "project_id = #{@project.id}", :order => "position") - if request.post? + if request.post? || request.put? @faq.attributes = params[:faq] @faq.updater_id = User.current.id if @faq.save attachments = Attachment.attach_files(@faq, params[:attachments]) render_attachment_warning_if_needed(@faq) flash[:notice] = l(:notice_successful_update) - FaqMailer.deliver_faq_update(@project, @faq) + FaqMailer.faq_update(@project, @faq).deliver redirect_to :controller => 'ezfaq', :action => 'show', :id => @project, :faq_id => @faq return end @@ -121,7 +122,7 @@ def copy end @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id] @target_project ||= @project - if request.post? + if request.post? || request.put? @faq.copy(@target_project) flash[:notice] = l(:notice_successful_update) redirect_to :controller => 'ezfaq', :action => 'index', :id => @project @@ -155,18 +156,15 @@ def show_history_version def add_faq_category @category = FaqCategory.new(params[:category]) @category.project_id = @project.id - if request.post? and @category.save + if (request.post? || request.put?) and @category.save respond_to do |format| - format.html do + format.html { flash[:notice] = l(:notice_successful_create) redirect_to :controller => 'faq_categories', :action => 'index', :id => @project - end - format.js do - faq_categories = FaqCategory.find(:all, :conditions => "project_id = #{@project.id}") - render(:update) {|page| page.replace "faq_category_id", - content_tag('select', '' + options_from_collection_for_select(faq_categories, 'id', 'name', @category.id), :id => 'faq_category_id', :name => 'faq[category_id]') - } - end + } + format.js { + render :partial => 'faq_category_modal_create' + } end end end @@ -175,7 +173,7 @@ def faq_setting @faq_setting = FaqSetting.find(:first, :conditions => "project_id = #{@project.id}") if !@faq_setting && request.get? @faq_setting = FaqSetting.new - elsif request.post? + elsif !request.get? if !@faq_setting @faq_setting = FaqSetting.new(params[:faq_setting]) else diff --git a/app/controllers/faq_categories_controller.rb b/app/controllers/faq_categories_controller.rb index ce27302..fe5ba88 100644 --- a/app/controllers/faq_categories_controller.rb +++ b/app/controllers/faq_categories_controller.rb @@ -22,8 +22,8 @@ class FaqCategoriesController < ApplicationController menu_item :ezfaq, :only => [:index, :edit, :destroy] before_filter :find_project, :authorize - verify :method => :post, :only => :destroy - verify :mothod => :post, :only => :change_order +# verify :method => :post, :only => :destroy +# verify :mothod => :post, :only => :change_order def index @categories = FaqCategory.find(:all, :conditions => "project_id = #{@project.id}", :order => "position") @@ -31,7 +31,7 @@ def index def edit @category = FaqCategory.find(:first, :conditions => "project_id = #{@project.id} and id = #{params[:category_id]}") - if request.post? and @category.update_attributes(params[:category]) + if (request.post? || request.put?) and @category.update_attributes(params[:category]) flash[:notice] = l(:notice_successful_update) redirect_to :controller => 'faq_categories', :action => 'index', :id => @project end @@ -40,7 +40,7 @@ def edit end def change_order - if request.post? + if request.post? || request.put? category = FaqCategory.find(:first, :conditions => "project_id = #{@project.id} and id = #{params[:category_id]}") case params[:position] when 'highest'; category.move_to_top diff --git a/app/helpers/ezfaq_helper.rb b/app/helpers/ezfaq_helper.rb deleted file mode 100644 index f721aa2..0000000 --- a/app/helpers/ezfaq_helper.rb +++ /dev/null @@ -1,26 +0,0 @@ -# ezFAQ plugin for redMine -# Copyright (C) 2008-2009 Zou Chaoqun -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -module EzfaqHelper - - def updated_by(updated, author) - time_tag = content_tag('acronym', distance_of_time_in_words(Time.now, updated), :title => format_time(updated)) - author_tag = (author.is_a?(User) && !author.is_a?(AnonymousUser)) ? link_to(h(author), :controller => 'account', :action => 'show', :id => author) : h(author || 'Anonymous') - l(:label_updated_time_by, :author => author_tag, :age => time_tag) - end - -end diff --git a/app/models/faq_mailer.rb b/app/models/faq_mailer.rb index 36009ca..0785d3c 100644 --- a/app/models/faq_mailer.rb +++ b/app/models/faq_mailer.rb @@ -24,25 +24,13 @@ def faq_add(project, faq) mail_addresses = [ faq.author.mail ] mail_addresses << faq.assigned_to.mail if faq.assigned_to - - recipients mail_addresses.compact.uniq - - subject "[#{faq.project.name} - #{l(:label_faq_new)} - #{l(:label_faq)}##{faq.id}] #{faq.question}" - body :faq => faq, - :faq_url => url_for(:controller => 'ezfaq', :action => 'show', :id => project, :faq_id => faq) - - content_type "multipart/alternative" - - part "text/plain" do |p| - p.body = render_message("faq_add.text.plain.rhtml", body) - end - - part "text/html" do |p| - p.body = render_message("faq_add.text.html.rhtml", body) - end + @faq = faq + @faq_url = url_for(:controller => 'ezfaq', :action => 'show', :id => project, :faq_id => faq) + mail :to => mail_addresses.compact.uniq, + :subject => "[#{faq.project.name} - #{l(:label_faq_new)} - #{l(:label_faq)}##{faq.id}] #{faq.question}" end - + def faq_update(project, faq) redmine_headers 'Project' => faq.project.identifier, 'Faq-Id' => faq.id, @@ -51,22 +39,10 @@ def faq_update(project, faq) mail_addresses = [ faq.author.mail, faq.updater.mail ] mail_addresses << faq.assigned_to.mail if faq.assigned_to - recipients mail_addresses.compact.uniq - - subject "[#{faq.project.name} - #{l(:label_faq_updated)} - #{l(:label_faq)}##{faq.id}] #{faq.question}" - body :faq => faq, - :faq_url => url_for(:controller => 'ezfaq', :action => 'show', :id => project, :faq_id => faq) - - content_type "multipart/alternative" - - part "text/plain" do |p| - p.body = render_message("faq_update.text.plain.rhtml", body) - end - - part "text/html" do |p| - p.body = render_message("faq_update.text.html.rhtml", body) - end - + @faq = faq + @faq_url = url_for(:controller => 'ezfaq', :action => 'show', :id => project, :faq_id => faq) + mail :to => mail_addresses.compact.uniq, + :subject => "[#{faq.project.name} - #{l(:label_faq_updated)} - #{l(:label_faq)}##{faq.id}] #{faq.question}" end end diff --git a/app/views/ezfaq/_add_faq_category_modal.html.erb b/app/views/ezfaq/_add_faq_category_modal.html.erb new file mode 100644 index 0000000..90be17e --- /dev/null +++ b/app/views/ezfaq/_add_faq_category_modal.html.erb @@ -0,0 +1,11 @@ +

<%=l(:label_faq_category_new)%>

+ +<% form = labelled_form_for :category, @category, :url => { :action => 'add_faq_category' }, :html => { :class => 'tabular'}, :remote => true do |f| %> +<%= render :partial => 'faq_categories/form', :locals => { :f => f } %> +

+<%= submit_tag l(:button_create) %> +<%= submit_tag l(:button_cancel), :onclick => "hideModal(this);" %> +

+<% end %> + +<%= form if Rails::VERSION::MAJOR >= 3 %> diff --git a/app/views/ezfaq/_edit.html.erb b/app/views/ezfaq/_edit.html.erb deleted file mode 100644 index 7d67ea9..0000000 --- a/app/views/ezfaq/_edit.html.erb +++ /dev/null @@ -1,50 +0,0 @@ - - -

<%= f.text_field :question, :size => 80, :required => true %>

-

<%= f.text_area :answer, - :cols => 60, - :rows => (@faq.answer.blank? ? 10 : [[10, @faq.answer.length / 50].max, 100].min), - :accesskey => accesskey(:edit), - :class => 'wiki-edit' %>

- -
-

<%= f.select :category_id, (@faq_categories.collect {|c| [c.name, c.id]}), :include_blank => true %> -<%= prompt_to_remote(l(:label_faq_category_new), - l(:label_faq_category_new), 'category[name]', - {:controller => 'ezfaq', :action => 'add_faq_category', :id => @project}, - :class => 'small', :tabindex => 199) if authorize_for('ezfaq', 'add_faq_category') %>

-

-<%= f.select :difficulty, (1..10), {}, :required => true, :onchange => "change_stars();"%> -<%= image_tag("stars_#{@faq.difficulty}.png", :plugin => "ezfaq_plugin", :id => "stars_img", :alt => "#{l(:field_difficulty)}#{@faq.difficulty}", :title => "#{l(:field_difficulty)}#{@faq.difficulty}") %> -

-

<%= f.text_field :related_issue_id, :size => 10 %> <%= l(:label_info_for_input_id) %>

-

<%= f.select :related_version_id, @project.versions.sort.collect {|v| [v.name, v.id]}, :include_blank => true %>

-
- -
-

<%= f.select :assigned_to_id, (@project.assignable_users.collect {|m| [m.name, m.id]}), :include_blank => true %>

-

<%= f.text_field :due_date, :size => 10 %><%= calendar_for('faq_due_date') %>

-

<%= f.text_field :related_message_id, :size => 10 %> <%= l(:label_info_for_input_id) %>

-

<%= f.select :is_valid, [[l(:label_valid), true], [l(:label_invalid), false]] %>

-
- -<%= hidden_field_tag 'difficulty_label', l(:field_difficulty) %> -<%= f.hidden_field :version %> - -

-

<%= render :partial => 'attachments/form' %>

- -<%= wikitoolbar_for 'faq_answer' %> diff --git a/app/views/ezfaq/_faq_category_modal_create.js.erb b/app/views/ezfaq/_faq_category_modal_create.js.erb new file mode 100644 index 0000000..c2eaf9e --- /dev/null +++ b/app/views/ezfaq/_faq_category_modal_create.js.erb @@ -0,0 +1,6 @@ +hideModal(); +<% +faq_categories = FaqCategory.find(:all, :conditions => "project_id = #{@project.id}") +select = content_tag('select', content_tag('option') + options_from_collection_for_select(faq_categories, 'id', 'name', @category.id), :id => 'faq_category_id', :name => 'faq[category_id]') +%> +$('#faq_category_id').replaceWith('<%= escape_javascript(select) %>'); diff --git a/app/views/ezfaq/_form.html.erb b/app/views/ezfaq/_form.html.erb index ddfbcf4..df3941d 100644 --- a/app/views/ezfaq/_form.html.erb +++ b/app/views/ezfaq/_form.html.erb @@ -1,13 +1,13 @@