Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6972,6 +6972,7 @@ const CONST = {
TEXT: 'text',
DATE: 'date',
LIST: 'dropdown',
FORMULA: 'formula',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Consistent constant naming

Good addition of the FORMULA constant that follows the existing naming convention and uses lowercase 'formula' as the value, which is consistent with the other report field types.

},

NAVIGATION_ACTIONS: {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4806,9 +4806,11 @@ const translations = {
textType: 'Text',
dateType: 'Datum',
dropdownType: 'Liste',
formulaType: 'Formel',
textAlternateText: 'Fügen Sie ein Feld für die freie Texteingabe hinzu.',
dateAlternateText: 'Fügen Sie einen Kalender zur Datumauswahl hinzu.',
dropdownAlternateText: 'Fügen Sie eine Liste von Optionen zur Auswahl hinzu.',
formulaAlternateText: 'Fügen Sie ein Formularfeld hinzu.',
nameInputSubtitle: 'Wählen Sie einen Namen für das Berichtsfeld.',
typeInputSubtitle: 'Wählen Sie aus, welche Art von Berichtsfeld verwendet werden soll.',
initialValueInputSubtitle: 'Geben Sie einen Startwert ein, der im Berichtsfeld angezeigt werden soll.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4782,9 +4782,11 @@ const translations = {
textType: 'Text',
dateType: 'Date',
dropdownType: 'List',
formulaType: 'Formula',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Good placement and consistency

The formulaType translation is correctly placed alongside the other type translations (textType, dateType, dropdownType) maintaining the consistent structure.

textAlternateText: 'Add a field for free text input.',
dateAlternateText: 'Add a calendar for date selection.',
dropdownAlternateText: 'Add a list of options to choose from.',
formulaAlternateText: 'Add a formula field.',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where are we showing this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we aren't showing it, can we remove it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Proper alternative text placement

The formulaAlternateText is correctly placed with the other alternative text translations and provides clear, concise guidance to users.

nameInputSubtitle: 'Choose a name for the report field.',
typeInputSubtitle: 'Choose what type of report field to use.',
initialValueInputSubtitle: 'Enter a starting value to show in the report field.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4789,9 +4789,11 @@ const translations = {
textType: 'Texto',
dateType: 'Fecha',
dropdownType: 'Lista',
formulaType: 'Fórmula',
textAlternateText: 'Añade un campo para introducir texto libre.',
dateAlternateText: 'Añade un calendario para la selección de fechas.',
dropdownAlternateText: 'Añade una lista de opciones para elegir.',
formulaAlternateText: 'Añade un campo con una fórmula.',
nameInputSubtitle: 'Elige un nombre para el campo del informe.',
typeInputSubtitle: 'Elige qué tipo de campo de informe utilizar.',
initialValueInputSubtitle: 'Ingresa un valor inicial para mostrar en el campo del informe.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4819,9 +4819,11 @@ const translations = {
textType: 'Texte',
dateType: 'Date',
dropdownType: 'Liste',
formulaType: 'Formule',
textAlternateText: 'Ajoutez un champ pour la saisie de texte libre.',
dateAlternateText: 'Ajouter un calendrier pour la sélection de la date.',
dropdownAlternateText: "Ajouter une liste d'options à choisir.",
formulaAlternateText: 'Ajouter un champ de formule.',
nameInputSubtitle: 'Choisissez un nom pour le champ du rapport.',
typeInputSubtitle: 'Choisissez le type de champ de rapport à utiliser.',
initialValueInputSubtitle: 'Entrez une valeur de départ à afficher dans le champ du rapport.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4819,9 +4819,11 @@ const translations = {
textType: 'Testo',
dateType: 'Data',
dropdownType: 'Elenco',
formulaType: 'Formula',
textAlternateText: "Aggiungi un campo per l'inserimento di testo libero.",
dateAlternateText: 'Aggiungi un calendario per la selezione delle date.',
dropdownAlternateText: 'Aggiungi un elenco di opzioni tra cui scegliere.',
formulaAlternateText: 'Aggiungi un campo formula.',
nameInputSubtitle: 'Scegli un nome per il campo del rapporto.',
typeInputSubtitle: 'Scegli quale tipo di campo del report utilizzare.',
initialValueInputSubtitle: 'Inserisci un valore iniziale da mostrare nel campo del report.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4779,9 +4779,11 @@ const translations = {
textType: 'テキスト',
dateType: '日付',
dropdownType: 'リスト',
formulaType: 'Formula',
textAlternateText: '自由入力フィールドを追加してください。',
dateAlternateText: '日付選択用のカレンダーを追加します。',
dropdownAlternateText: '選択肢のリストを追加してください。',
formulaAlternateText: '数式フィールドを追加します。',
nameInputSubtitle: 'レポートフィールドの名前を選択してください。',
typeInputSubtitle: '使用するレポートフィールドのタイプを選択してください。',
initialValueInputSubtitle: 'レポートフィールドに表示する開始値を入力してください。',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4814,9 +4814,11 @@ const translations = {
textType: 'Tekst',
dateType: 'Datum',
dropdownType: 'Lijst',
formulaType: 'Formule',
textAlternateText: 'Voeg een veld toe voor vrije tekstinvoer.',
dateAlternateText: 'Voeg een kalender toe voor datumselectie.',
dropdownAlternateText: 'Voeg een lijst met opties toe om uit te kiezen.',
formulaAlternateText: 'Voeg een formuleveld toe.',
nameInputSubtitle: 'Kies een naam voor het rapportveld.',
typeInputSubtitle: 'Kies welk type rapportveld je wilt gebruiken.',
initialValueInputSubtitle: 'Voer een startwaarde in om in het rapportveld te tonen.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4804,9 +4804,11 @@ const translations = {
textType: 'Tekst',
dateType: 'Data',
dropdownType: 'Lista',
formulaType: 'Formuła',
textAlternateText: 'Dodaj pole do swobodnego wprowadzania tekstu.',
dateAlternateText: 'Dodaj kalendarz do wyboru daty.',
dropdownAlternateText: 'Dodaj listę opcji do wyboru.',
formulaAlternateText: 'Dodaj pole formuły.',
nameInputSubtitle: 'Wybierz nazwę dla pola raportu.',
typeInputSubtitle: 'Wybierz, jakiego typu pola raportu chcesz użyć.',
initialValueInputSubtitle: 'Wprowadź wartość początkową do wyświetlenia w polu raportu.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4809,9 +4809,11 @@ const translations = {
textType: 'Texto',
dateType: 'Data',
dropdownType: 'Lista',
formulaType: 'Fórmula',
textAlternateText: 'Adicione um campo para entrada de texto livre.',
dateAlternateText: 'Adicione um calendário para seleção de data.',
dropdownAlternateText: 'Adicione uma lista de opções para escolher.',
formulaAlternateText: 'Adicione um campo de fórmula.',
nameInputSubtitle: 'Escolha um nome para o campo do relatório.',
typeInputSubtitle: 'Escolha qual tipo de campo de relatório usar.',
initialValueInputSubtitle: 'Insira um valor inicial para mostrar no campo do relatório.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4716,9 +4716,11 @@ const translations = {
textType: '文本',
dateType: '日期',
dropdownType: '列表',
formulaType: '公式',
textAlternateText: '添加一个字段用于自由文本输入。',
dateAlternateText: '添加日历以选择日期。',
dropdownAlternateText: '添加一个选项列表供选择。',
formulaAlternateText: '添加一个公式字段。',
nameInputSubtitle: '为报告字段选择一个名称。',
typeInputSubtitle: '选择要使用的报告字段类型。',
initialValueInputSubtitle: '输入一个起始值以显示在报告字段中。',
Expand Down
2 changes: 2 additions & 0 deletions src/libs/WorkspaceReportFieldUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function getReportFieldTypeTranslationKey(reportFieldType: PolicyReportFieldType
[CONST.REPORT_FIELD_TYPES.TEXT]: 'workspace.reportFields.textType',
[CONST.REPORT_FIELD_TYPES.DATE]: 'workspace.reportFields.dateType',
[CONST.REPORT_FIELD_TYPES.LIST]: 'workspace.reportFields.dropdownType',
[CONST.REPORT_FIELD_TYPES.FORMULA]: 'workspace.reportFields.formulaType',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❌ Incomplete Implementation

While the translation keys have been added for the FORMULA type, the getReportFieldInitialValue function (lines 71-85) doesn't handle the new FORMULA type. This could cause issues when working with formula fields since they would fall back to the default case without proper initialization.

Suggested fix:
Add specific handling for FORMULA type in getReportFieldInitialValue:

if (reportField.type === CONST.REPORT_FIELD_TYPES.FORMULA) {
    return reportField.defaultValue ?? '';
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Good addition of FORMULA type support

The addition of FORMULA type to the translation key mapping is consistent with the existing pattern and correctly maps to the newly added translation key.

};

return typeTranslationKeysStrategy[reportFieldType];
Expand All @@ -29,6 +30,7 @@ function getReportFieldAlternativeTextTranslationKey(reportFieldType: PolicyRepo
[CONST.REPORT_FIELD_TYPES.TEXT]: 'workspace.reportFields.textAlternateText',
[CONST.REPORT_FIELD_TYPES.DATE]: 'workspace.reportFields.dateAlternateText',
[CONST.REPORT_FIELD_TYPES.LIST]: 'workspace.reportFields.dropdownAlternateText',
[CONST.REPORT_FIELD_TYPES.FORMULA]: 'workspace.reportFields.formulaAlternateText',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Consistent alternative text mapping

Good addition that maintains consistency with the existing pattern. The alternative text will help users understand what the FORMULA field type does.

};

return typeTranslationKeysStrategy[reportFieldType];
Expand Down
17 changes: 16 additions & 1 deletion src/pages/workspace/reports/CreateReportFieldsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,22 @@ function WorkspaceCreateReportFieldsPage({
label={translate('common.type')}
subtitle={translate('workspace.reportFields.typeInputSubtitle')}
rightLabel={translate('common.required')}
onTypeSelected={(type) => formRef.current?.resetForm({...inputValues, type, initialValue: type === CONST.REPORT_FIELD_TYPES.DATE ? defaultDate : ''})}
onTypeSelected={(type) => {
let initialValue;
if (type === CONST.REPORT_FIELD_TYPES.DATE) {
initialValue = defaultDate;
} else if (type === CONST.REPORT_FIELD_TYPES.FORMULA) {
initialValue = '{report:id}';
} else {
initialValue = '';
}

formRef.current?.resetForm({
...inputValues,
type,
initialValue,
});
}}
/>

{inputValues[INPUT_IDS.TYPE] === CONST.REPORT_FIELD_TYPES.LIST && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function ReportFieldsInitialValuePage({
}

const isTextFieldType = reportField.type === CONST.REPORT_FIELD_TYPES.TEXT;
const isFormulaFieldType = reportField.type === CONST.REPORT_FIELD_TYPES.FORMULA;
const isListFieldType = reportField.type === CONST.REPORT_FIELD_TYPES.LIST;

return (
Expand All @@ -111,7 +112,7 @@ function ReportFieldsInitialValuePage({
</View>
)}

{isTextFieldType && (
{(isTextFieldType || isFormulaFieldType) && (
<FormProvider
addBottomSafeAreaPadding
formID={ONYXKEYS.FORMS.WORKSPACE_REPORT_FIELDS_FORM}
Expand Down