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

Pipe Calc Summary #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions src/constants/piping.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ const FORMAT_CURRENCY = `${formatPlaceholder}currency`;
const FORMAT_NUMBER = `${formatPlaceholder}number`;
const FORMAT_DATE = `${formatPlaceholder}date`;
const FORMAT_UNIT = `${formatPlaceholder}unit`;
const FORMAT_PERCENTAGE = `${formatPlaceholder}percentage`;
const FORMAT_CHECKBOX = `concatenate_list`;

// Transformation arguments
const DATE_TRANSFORMATION = "date_to_format";
const NUMBER_TRANSFORMATION = "number";
const CHECKBOX_TRANSFORMATION = "list_to_concatenate";
const PERCENTAGE_TRANSFORMATION = "value";

module.exports = {
formatPlaceholder,
Expand All @@ -20,4 +22,6 @@ module.exports = {
NUMBER_TRANSFORMATION,
CHECKBOX_TRANSFORMATION,
FORMAT_UNIT,
FORMAT_PERCENTAGE,
PERCENTAGE_TRANSFORMATION,
};
10 changes: 10 additions & 0 deletions src/utils/convertPipes/PlaceholderObjectBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const {
NUMBER_TRANSFORMATION,
DATE_TRANSFORMATION,
CHECKBOX_TRANSFORMATION,
FORMAT_PERCENTAGE,
PERCENTAGE_TRANSFORMATION,
// FORMAT_UNIT,
} = require("../../constants/piping");
const { removeDash } = require("../HTMLUtils");
Expand All @@ -24,6 +26,7 @@ const TRANSFORM_MAP = {
Date: { format: FORMAT_DATE, transformKey: DATE_TRANSFORMATION },
DateRange: { format: FORMAT_DATE, transformKey: DATE_TRANSFORMATION },
Checkbox: { format: FORMAT_CHECKBOX, transformKey: CHECKBOX_TRANSFORMATION },
Percentage: { format: FORMAT_PERCENTAGE, transformKey: PERCENTAGE_TRANSFORMATION },
// Unit: { format: FORMAT_UNIT, transformKey: NUMBER_TRANSFORMATION },
};

Expand All @@ -46,6 +49,13 @@ const placeholderObjectBuilder = (
};
}

if (source === "variable") {
valueSource = {
source: "calculatedSummary",
identifier,
};
}

if ([AnswerType] in TRANSFORM_MAP) {
if (["Date", "DateRange"].includes(AnswerType)) {
argumentList = {
Expand Down