Skip to content

Commit

Permalink
Remove path from InfoText of Generator (#399)
Browse files Browse the repository at this point in the history
* Remove path from InfoText of Generator

* Change input name and types to InfoText and Text for Generator
  • Loading branch information
samuel-duhaime authored Mar 14, 2024
1 parent c910781 commit 70abe90
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion packages/evolution-generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Widgets are the building blocks of your survey. They define the structure and in
| [inputRange](#range) | Input range name for InputRange (optional) | string? |
| comments | Additional comments for the question (optional) | string? |
> <span id="input">**Note:**</span> The `inputType` field specifies the type of input for the question and can be one of the following: Checkbox, Custom, NextButton, Number, Radio, Range, String, Text, or TextArea.
> <span id="input">**Note:**</span> The `inputType` field specifies the type of input for the question and can be one of the following: Custom, Radio, Select, String, Number, InfoText, Range, Checkbox, NextButton, or Text
> <span id="cond">**Note:**</span> The `conditional` field allows you to define conditional logic for displaying the widget based on other responses. For example, you can specify a condition like `nbPersonnesSeptPlusConditional` to show the widget only if the number of people is 7 or more.
Expand Down
8 changes: 4 additions & 4 deletions packages/evolution-generator/src/common/defaultInputBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export const inputNumberBase: inputTypes.InputStringBase = {
numericKeyboard: true
};

// Text default params
export const inputTextBase: inputTypes.InputTextBase = {
// InfoText default params
export const infoTextBase: inputTypes.InfoTextBase = {
type: 'text',
containsHtml: true
};
Expand Down Expand Up @@ -96,8 +96,8 @@ export const buttonNextBase: inputTypes.InputButtonBase = {
action: surveyHelper.validateButtonActionWithCompleteSection
};

// TextArea default params
export const textAreaBase: inputTypes.TextAreaBase = {
// Text textarea default params
export const textBase: inputTypes.TextBase = {
type: 'question',
inputType: 'text',
datatype: 'text',
Expand Down
25 changes: 12 additions & 13 deletions packages/evolution-generator/src/scripts/generate_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ def generate_widget_statement(row):
widget = generate_string_widget(question_name, section, path, help_popup, conditional, validation)
elif input_type == 'Number':
widget = generate_number_widget(question_name, section, path, help_popup, conditional, validation)
elif input_type == 'Text':
widget = generate_text_widget(question_name, section, path, conditional)
elif input_type == 'InfoText':
widget = generate_info_text_widget(question_name, section, path, conditional)
elif input_type == 'Range':
widget = generate_range_widget(question_name, section, path, input_range, conditional, validation)
elif input_type == 'Checkbox':
widget = generate_checkbox_widget(question_name, section, path, choices, help_popup, conditional, validation)
elif input_type == 'NextButton':
widget = generate_next_button_widget(question_name, section, path)
elif input_type == 'TextArea':
widget = generate_text_area_widget(question_name, section, path, conditional, validation)
elif input_type == 'Text':
widget = generate_text_widget(question_name, section, path, conditional, validation)
else:
widget = f"// {question_name}"

Expand Down Expand Up @@ -232,11 +232,10 @@ def generate_number_widget(question_name, section, path, help_popup, conditional
f"{generate_validation(validation)}\n" \
f"}};"

# Generate Text widget
def generate_text_widget(question_name, section, path, conditional):
return f"{generate_constExport(question_name, 'InputText')}\n" \
f"{generate_defaultInputBase('inputTextBase')},\n" \
f"{generate_path(path)},\n" \
# Generate InfoText widget
def generate_info_text_widget(question_name, section, path, conditional):
return f"{generate_constExport(question_name, 'InfoText')}\n" \
f"{generate_defaultInputBase('infoTextBase')},\n" \
f"{generate_text(section, path)},\n" \
f"{generate_conditional(conditional)}\n" \
f"}};"
Expand Down Expand Up @@ -272,10 +271,10 @@ def generate_next_button_widget(question_name, section, path):
f"{generate_label(section, path)}\n" \
f"}};"

# Generate TextArea widget
def generate_text_area_widget(question_name, section, path, conditional, validation):
return f"{generate_constExport(question_name, 'TextArea')}\n" \
f"{generate_defaultInputBase('textAreaBase')},\n" \
# Generate Text textarea widget
def generate_text_widget(question_name, section, path, conditional, validation):
return f"{generate_constExport(question_name, 'Text')}\n" \
f"{generate_defaultInputBase('textBase')},\n" \
f"{generate_path(path)},\n" \
f"{generate_label(section, path)},\n" \
f"{generate_conditional(conditional)},\n" \
Expand Down
23 changes: 12 additions & 11 deletions packages/evolution-generator/src/types/inputTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ type Multiple = boolean;
type Columns = 1 | 2;
type Path = string;
type Placeholder = string;
type Align = 'left' | 'right' | 'center';
type Title = { fr: string; en: string };
type Text = (t: TFunction) => string;
export type InputFilter = (value) => string | number;
type LabelFunction = (t: TFunction, interview?, path?) => string;
type LabelNotFunction = { en: string | ((interview?, path?) => string); fr: string | ((interview?, path?) => string) };
type Label = LabelFunction | LabelNotFunction;
type TextKey = LabelFunction | LabelNotFunction;
export type Labels = {
fr: string;
en: string;
Expand Down Expand Up @@ -108,14 +109,14 @@ export type InputString = InputStringBase & {
textTransform?: 'uppercase' | 'lowercase' | 'capitalize';
};

/* InputText widgetConfig Type */
export type InputTextBase = {
/* Text widgetConfig Type */
export type InfoTextBase = {
type: 'text';
align?: Align;
containsHtml: ContainsHtml;
};
export type InputText = InputTextBase & {
path: Path;
text: Text;
export type InfoText = InfoTextBase & {
text: TextKey;
conditional: Conditional;
};

Expand Down Expand Up @@ -199,7 +200,7 @@ export type InputButtonBase = {
color: 'green';
hideWhenRefreshing: boolean;
icon: any; // icon: IconDefinition;
align: 'left' | 'right' | 'center';
align: Align;
action: () => void;
};
export type InputButton = InputButtonBase & {
Expand All @@ -216,15 +217,15 @@ export type InputButton = InputButtonBase & {
saveCallback?: () => void;
};

/* InputText textArea widgetConfig Type */
export type TextAreaBase = {
/* InputText widgetConfig Type */
export type TextBase = {
type: 'question';
inputType: 'text';
datatype: 'text';
containsHtml?: ContainsHtml;
twoColumns: false;
};
export type TextArea = TextAreaBase & {
export type Text = TextBase & {
path: Path;
label: Label;
conditional: Conditional;
Expand Down Expand Up @@ -255,7 +256,7 @@ export type InputMapFindPlaceBase = {
defaultCenter: { lat: number; lon: number };
refreshGeocodingLabel: Label;
showSearchPlaceButton: (interview?, path?) => boolean;
afterRefreshButtonText: Text;
afterRefreshButtonText: TextKey;
validations?: Validations;
};
export type InputMapFindPlace = InputMapFindPlaceBase & {
Expand Down

0 comments on commit 70abe90

Please sign in to comment.