Skip to content

Commit

Permalink
fix: add customJS control for currency, notation and thousand separat…
Browse files Browse the repository at this point in the history
…or (#33877)

Fixes #33858

/ok-to-test tags="@tag.Table"<!-- This is an auto-generated comment:
Cypress test results -->
> [!IMPORTANT]
> 🟣 🟣 🟣 Your tests are running.
> Tests running at:
<https://github.com/appsmithorg/appsmith/actions/runs/9318008514>
> Commit: 1ea0a63
> Workflow: `PR Automation test suite`
> Tags: `@tag.Table`

<!-- end of auto-generated comment: Cypress test results  -->

---------

Co-authored-by: Pawan Kumar <pawankumar@Pawans-MacBook-Pro-2.local>
  • Loading branch information
jsartisan and Pawan Kumar authored May 31, 2024
1 parent d4645bd commit eb0c13d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,18 +395,24 @@ export default {
enableSearch: true,
dropdownHeight: "156px",
controlType: "DROP_DOWN",
customJSControl: "TABLE_COMPUTE_VALUE",
searchPlaceholderText: "Search by code or name",
options: CurrencyDropdownOptions,
virtual: true,
isJSConvertible: true,
isBindProperty: true,
isTriggerProperty: false,
validation: {
type: ValidationTypes.TEXT,
type: ValidationTypes.ARRAY_OF_TYPE_OR_TYPE,
params: {
default: "USD",
required: true,
allowedValues: CurrencyDropdownOptions.map((option) => option.value),
type: ValidationTypes.TEXT,
params: {
default: "USD",
required: true,
allowedValues: CurrencyDropdownOptions.map(
(option) => option.value,
),
},
},
},
hidden: (props: TableWidgetProps, propertyPath: string) => {
Expand Down Expand Up @@ -459,11 +465,17 @@ export default {
helpText: "formats the currency with a thousand separator",
label: "Thousand separator",
controlType: "SWITCH",
customJSControl: "TABLE_COMPUTE_VALUE",
dependencies: ["primaryColumns", "columnType"],
isJSConvertible: true,
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.BOOLEAN },
validation: {
type: ValidationTypes.ARRAY_OF_TYPE_OR_TYPE,
params: {
type: ValidationTypes.BOOLEAN,
},
},
hidden: (props: TableWidgetProps, propertyPath: string) => {
const baseProperty = getBasePropertyPath(propertyPath);
const columnType = get(props, `${baseProperty}.columnType`, "");
Expand All @@ -475,6 +487,7 @@ export default {
helpText: "Displays the currency in standard or compact notation",
label: "Notation",
controlType: "DROP_DOWN",
customJSControl: "TABLE_COMPUTE_VALUE",
options: [
{
label: "Standard",
Expand All @@ -490,8 +503,14 @@ export default {
isBindProperty: true,
isTriggerProperty: false,
validation: {
type: ValidationTypes.TEXT,
params: { default: "standard", allowedValues: ["standard", "compact"] },
type: ValidationTypes.ARRAY_OF_TYPE_OR_TYPE,
params: {
type: ValidationTypes.TEXT,
params: {
default: "standard",
allowedValues: ["standard", "compact"],
},
},
},
hidden: (props: TableWidgetProps, propertyPath: string) => {
const baseProperty = getBasePropertyPath(propertyPath);
Expand Down
7 changes: 5 additions & 2 deletions app/client/src/widgets/TableWidgetV2/widget/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,11 @@ export const getCellProperties = (
true,
),
decimals: columnProperties.decimals,
thousandSeparator: !!columnProperties.thousandSeparator,
notation: columnProperties.notation,
thousandSeparator: getBooleanPropertyValue(
columnProperties.thousandSeparator,
rowIndex,
),
notation: getPropertyValue(columnProperties.notation, rowIndex, true),
} as CellLayoutProperties;
}
return {} as CellLayoutProperties;
Expand Down

0 comments on commit eb0c13d

Please sign in to comment.