From 84bcbc33fb97681a426af7f0caa2a9d0b69db934 Mon Sep 17 00:00:00 2001
From: Fondryext <160865254+Fondryext@users.noreply.github.com>
Date: Wed, 14 Aug 2024 15:27:27 -0400
Subject: [PATCH] Add a document vertical standard card
To help with development of the document vertical, this change
adds a default document vertical card and styling for users to
build off of.
J=WAT-4183
TEST=manual
I made these changes in a test site, and confirmed that dcoument
results displayed correctly
---
cards/document-vertical-standard/component.js | 55 +++++++++++
cards/document-vertical-standard/template.hbs | 99 +++++++++++++++++++
static/package-lock.json | 4 +-
static/package.json | 2 +-
static/scss/answers/_default.scss | 1 +
.../cards/document-vertical-standard.scss | 92 +++++++++++++++++
6 files changed, 250 insertions(+), 3 deletions(-)
create mode 100644 cards/document-vertical-standard/component.js
create mode 100644 cards/document-vertical-standard/template.hbs
create mode 100644 static/scss/answers/cards/document-vertical-standard.scss
diff --git a/cards/document-vertical-standard/component.js b/cards/document-vertical-standard/component.js
new file mode 100644
index 000000000..f696d93e4
--- /dev/null
+++ b/cards/document-vertical-standard/component.js
@@ -0,0 +1,55 @@
+{{> cards/card_component componentName='document-vertical-standard' }}
+
+class document_vertical_standardCardComponent extends BaseCard['document-vertical-standard'] {
+ constructor(config = {}, systemConfig = {}) {
+ super(config, systemConfig);
+ }
+
+ /**
+ * This returns an object that will be called `card`
+ * in the template. Put all mapping logic here.
+ *
+ * @param profile profile of the entity in the card
+ */
+ dataForRender(profile) {
+ const linkTarget = AnswersExperience.runtimeConfig.get('linkTarget') || '_top';
+
+ return {
+ title: profile.name, // The header text of the card
+ // subtitle: '', // The sub-header text of the card
+ url: profile.landingPageUrl, // If the card title is a clickable link, set URL here
+ target: linkTarget, // If the title's URL should open in a new tab, etc.
+ // image: '', // The URL of the image to display on the card
+ // subtitle: '', // The sub-header text of the card
+ details: profile.d_segment.text, // The text in the body of the card
+ pageNumber: profile.d_segment.pageNumber, // If the result is from a file with page numbers, the page it was on
+ score: profile.d_segment.score, // The score this segment received
+ // 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: {
+ showMoreLimit: 500, // Character count limit
+ showMoreText: 'Show more', // Label when toggle will show truncated text
+ showLessText: 'Show less' // Label when toggle will hide truncated text
+ },
+ feedback: false, // Shows thumbs up/down buttons to provide feedback on the result card
+ feedbackTextOnSubmission: 'Thanks!', // Text to display after a thumbs up/down is clicked
+ positiveFeedbackSrText: 'This answered my question', // Screen reader only text for thumbs-up
+ negativeFeedbackSrText: 'This did not answer my question' // Screen reader only text for thumbs-down
+ };
+ }
+
+ /**
+ * The template to render
+ * @returns {string}
+ * @override
+ */
+ static defaultTemplateName (config) {
+ return 'cards/document-vertical-standard';
+ }
+}
+
+ANSWERS.registerTemplate(
+ 'cards/document-vertical-standard',
+ {{{stringifyPartial (read 'cards/document-vertical-standard/template') }}}
+);
+ANSWERS.registerComponentType(document_vertical_standardCardComponent);
diff --git a/cards/document-vertical-standard/template.hbs b/cards/document-vertical-standard/template.hbs
new file mode 100644
index 000000000..5baa2811d
--- /dev/null
+++ b/cards/document-vertical-standard/template.hbs
@@ -0,0 +1,99 @@
+
+ {{/if}}
+{{/inline}}
+
+{{! Displays the details for the card. If showMoreDetails has been configured,
+ this partial handles the show more toggle, show less toggle, truncated details,
+ and full details. If showMoreDetails has not been configured, it will display the
+ the regular card details.
+}}
+{{#*inline 'details'}}
+ {{#if card.details}}
+