Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FAQ card to support answerV2 instead of answer #1142

Merged
merged 2 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cards/faq-accordion/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ class faq_accordionCardComponent extends BaseCard['faq-accordion'] {
*/
dataForRender(profile) {
const linkTarget = AnswersExperience.runtimeConfig.get('linkTarget') || '_top';
let profileAnswer = '';
if (profile.answerV2 && profile.answerV2.html) {
profileAnswer = profile.answerV2.html;
} else if (profile.answerV2 && profile.answerV2.json) {
console.warn('JSON is not supported, please switch to HTML.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think we should say use the word 'convert' rather than 'switch' because the feature on the backend uses the word 'convert' as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated in most recent commit

}

return {
title: profile.question || profile.name, // The header text of the card
// subtitle: '', // The sub-header text of the card
details: profile.answer ? ANSWERS.formatRichText(profile.answer, "answer", linkTarget) : null, // The text in the body of the card
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be a good idea to add a 3rd if statement which maintains this functionality of calling ANSWERS.formatRichText if profile.answers exists. That way if someone upgrades to this version of the hitchhiker-theme, it won't break any existing sites which use the faq-accordion card

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that makes sense! i've added that check into the logic in the most recent commit

details: profileAnswer ? profileAnswer : null, // The text in the body
// of the card
// If the card's details are longer than a certain character count, you can truncate the
// text. A toggle will be supplied that can show or hide the truncated text.
// showMoreDetails: {
Expand Down
9 changes: 8 additions & 1 deletion cards/multilang-faq-accordion/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ class multilang_faq_accordionCardComponent extends BaseCard['multilang-faq-accor
*/
dataForRender(profile) {
const linkTarget = AnswersExperience.runtimeConfig.get('linkTarget') || '_top';
let profileAnswer = '';
if (profile.answerV2 && profile.answerV2.html) {
profileAnswer = profile.answerV2.html;
} else if (profile.answerV2 && profile.answerV2.json) {
console.warn('JSON is not supported, please switch to HTML.')
}

return {
title: profile.question || profile.name, // The header text of the card
// subtitle: '', // The sub-header text of the card
details: profile.answer ? ANSWERS.formatRichText(profile.answer, "answer", linkTarget) : null, // The text in the body of the card
details: profileAnswer ? profileAnswer : null, // The text in the body
// of the card
// If the card's details are longer than a certain character count, you can truncate the
// text. A toggle will be supplied that can show or hide the truncated text.
// showMoreDetails: {
Expand Down
Loading