KB answer-to-answer link slug wrong locale bugfix
This commit is contained in:
parent
110d60dd30
commit
19c222e7f3
2 changed files with 10 additions and 2 deletions
|
@ -203,8 +203,8 @@ module KnowledgeBaseHelper
|
||||||
case node['data-target-type']
|
case node['data-target-type']
|
||||||
when 'knowledge-base-answer'
|
when 'knowledge-base-answer'
|
||||||
if (translation = KnowledgeBase::Answer::Translation.find_by(id: node['data-target-id']))
|
if (translation = KnowledgeBase::Answer::Translation.find_by(id: node['data-target-id']))
|
||||||
path = help_answer_path(translation.answer.category.translation,
|
path = help_answer_path(translation.answer.category.translation_preferred(translation.kb_locale),
|
||||||
translation.answer.translation,
|
translation,
|
||||||
locale: translation.kb_locale.system_locale.locale)
|
locale: translation.kb_locale.system_locale.locale)
|
||||||
|
|
||||||
node['href'] = custom_path_if_needed path
|
node['href'] = custom_path_if_needed path
|
||||||
|
|
|
@ -32,6 +32,14 @@ module HasTranslations
|
||||||
translations.find_by(kb_locale_id: kb_locale_or_id)
|
translations.find_by(kb_locale_id: kb_locale_or_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def translation_preferred(kb_locale_or_id)
|
||||||
|
translation_to(kb_locale_or_id) || translation_primary || translations.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def translation_primary
|
||||||
|
translations.joins(:kb_locale).find_by(knowledge_base_locales: { primary: true })
|
||||||
|
end
|
||||||
|
|
||||||
class_methods do
|
class_methods do
|
||||||
def translation_class_name
|
def translation_class_name
|
||||||
"#{name}::Translation"
|
"#{name}::Translation"
|
||||||
|
|
Loading…
Reference in a new issue