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

ROU-11001: Added sanitizeInputValues configuration #431

Merged
merged 6 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace OSFramework.DataGrid.Configuration.Grid {
public rowHeader: Enum.RowHeader;
public rowHeight: number;
public rowsPerPage: number;
public sanitizeInputValues: boolean;
public selectionMode: number;
public serverSidePagination: boolean;
public showAggregateValues: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ namespace OSFramework.DataGrid.Configuration {
*/
keyBinding: string;
/**
* Indicates if the grid should sanitize the input values or not
*/
sanitizeInputValues: boolean;
/**
Indicates if the grid is in server side pagination mode
*/
serverSidePagination: boolean;
Expand Down
4 changes: 4 additions & 0 deletions src/OutSystems/GridAPI/GridManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ namespace OutSystems.GridAPI.GridManager {
let output = false;
if (grid !== undefined) {
if (grid.isReady && data !== '' && data !== '{}') {
// When the configurantion is set to sanitize the input values, we need to sanitize the data before setting it
if (grid.config.sanitizeInputValues) {
data = OSFramework.DataGrid.Helper.Sanitize(data);
}
grid.setData(data);
}
output = true;
Expand Down
3 changes: 2 additions & 1 deletion src/Providers/DataGrid/Wijmo/Columns/ActionColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ namespace Providers.DataGrid.Wijmo.Column {
config.binding,
this.handleActionEvent.bind(this),
undefined,
this.config.externalURL
this.config.externalURL,
this.grid.config.sanitizeInputValues
);

return config;
Expand Down
4 changes: 3 additions & 1 deletion src/Providers/DataGrid/Wijmo/Columns/ImageColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ namespace Providers.DataGrid.Wijmo.Column {
this.config.actionColumnElementType,
config.binding,
this.handleActionEvent.bind(this),
this.config.altText
this.config.altText,
undefined /* externalURL */,
this.grid.config.sanitizeInputValues
);

return config;
Expand Down
12 changes: 10 additions & 2 deletions src/Providers/DataGrid/Wijmo/Helper/CellTemplateFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,27 @@ namespace Providers.DataGrid.Wijmo.Helper.CellTemplateFactory {
binding: string,
callback: (item) => void,
altText?: string,
externalURL?: string
externalURL?: string,
sanitizeInputValues?: boolean
): wijmo.grid.ICellTemplateFunction {
let cellTemplate: wijmo.grid.ICellTemplateFunction;

const hasFixedText = binding.startsWith('$');
const hasExternalURL = externalURL?.toLocaleLowerCase().startsWith('http');

const url = hasExternalURL ? externalURL : '${item.' + externalURL + '}';
const text = hasFixedText ? binding.substring(1) : undefined;
let text = hasFixedText ? binding.substring(1) : undefined;

// Sanitize the text if the configuration is set to do so
if (text !== undefined) {
text = sanitizeInputValues ? OSFramework.DataGrid.Helper.Sanitize(text) : text;
}

let imgAltText = '';
if (altText !== undefined) {
const hasFixedAltText = altText.startsWith('$');
// Sanitize the alternative text if the configuration is set to do so
altText = sanitizeInputValues ? OSFramework.DataGrid.Helper.Sanitize(altText) : altText;
imgAltText = hasFixedAltText ? altText.substring(1) : '${item.' + altText + '}';
}

Expand Down
Loading