FEATURE-4135 : Table URL columns pretty link

-- Add displayText field into property pane
-- Display urls based on displayText
-- Fix url alignment issue
This commit is contained in:
Paul Li 2021-05-04 15:48:40 -04:00
parent 99c302e018
commit a5a0e0d85d
6 changed files with 37 additions and 2 deletions

View File

@ -85,7 +85,7 @@ function AutoToolTipComponent(props: Props) {
updateToolTip(false); updateToolTip(false);
} }
}, [ref]); }, [ref]);
if (props.columnType === ColumnTypes.URL) { if (props.columnType === ColumnTypes.URL && props.title) {
return <LinkWrapper {...props} />; return <LinkWrapper {...props} />;
} }
return ( return (

View File

@ -94,6 +94,7 @@ export interface CellLayoutProperties {
buttonStyle?: string; buttonStyle?: string;
buttonLabelColor?: string; buttonLabelColor?: string;
buttonLabel?: string; buttonLabel?: string;
displayText?: string;
} }
export interface TableColumnMetaProps { export interface TableColumnMetaProps {
@ -144,6 +145,7 @@ export interface ColumnProperties {
inputFormat?: string; inputFormat?: string;
dropdownOptions?: string; dropdownOptions?: string;
onOptionChange?: string; onOptionChange?: string;
displayText?: string;
} }
export const ConditionFunctions: { export const ConditionFunctions: {

View File

@ -413,6 +413,9 @@ export const CellWrapper = styled.div<{
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
text-align: ${(props) =>
props?.cellProperties?.horizontalAlignment &&
TEXT_ALIGN[props?.cellProperties?.horizontalAlignment]};
} }
.hidden-icon { .hidden-icon {
display: none; display: none;

View File

@ -112,7 +112,15 @@ export const renderCell = (
tableWidth={tableWidth} tableWidth={tableWidth}
title={value.toString()} title={value.toString()}
> >
{value.toString()} {value &&
columnType === ColumnTypes.URL &&
cellProperties.displayText ? (
<a href={value.toString()} rel="noreferrer" target="_blank">
{cellProperties.displayText}
</a>
) : (
value.toString()
)}
</AutoToolTipComponent> </AutoToolTipComponent>
); );
} }

View File

@ -201,6 +201,24 @@ export default [
isBindProperty: false, isBindProperty: false,
isTriggerProperty: false, isTriggerProperty: false,
}, },
{
propertyName: "displayText",
label: "Display Text",
controlType: "INPUT_TEXT",
customJSControl: "COMPUTE_VALUE",
updateHook: updateDerivedColumnsHook,
hidden: (props: TableWidgetProps, propertyPath: string) => {
const baseProperty = getBasePropertyPath(propertyPath);
const columnType = get(
props,
`${baseProperty}.columnType`,
"",
);
return columnType !== "url";
},
isBindProperty: false,
isTriggerProperty: false,
},
{ {
propertyName: "computedValue", propertyName: "computedValue",
label: "Computed Value", label: "Computed Value",

View File

@ -120,6 +120,10 @@ class TableWidget extends BaseWidget<TableWidgetProps, WidgetState> {
textSize: this.getPropertyValue(columnProperties.textSize, rowIndex), textSize: this.getPropertyValue(columnProperties.textSize, rowIndex),
textColor: this.getPropertyValue(columnProperties.textColor, rowIndex), textColor: this.getPropertyValue(columnProperties.textColor, rowIndex),
fontStyle: this.getPropertyValue(columnProperties.fontStyle, rowIndex), //Fix this fontStyle: this.getPropertyValue(columnProperties.fontStyle, rowIndex), //Fix this
displayText: this.getPropertyValue(
columnProperties.displayText,
rowIndex,
),
}; };
return cellProperties; return cellProperties;
}; };