Merge branch 'develop' into renovate/npm-next-auth-vulnerability

This commit is contained in:
Gerrie van Wyk 2022-07-08 11:53:35 +02:00 committed by GitHub
commit 60c3cae71e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 34 deletions

View File

@ -18,8 +18,8 @@ import React from 'react';
import { AgGridReact } from '@ag-grid-community/react';
import { AllCommunityModules } from '@ag-grid-community/all-modules';
import { renderHtml } from '@lowdefy/block-utils';
import { type } from '@lowdefy/helpers';
import processColDefs from './processColDefs.js';
class AgGrid extends React.Component {
constructor(props) {
@ -127,20 +127,6 @@ class AgGrid extends React.Component {
if (quickFilterValue && quickFilterValue === '') {
this.gridApi.setQuickFilter(quickFilterValue); // check if empty string matches all
}
const newColDefs = (columnDefs || []).map((col) => {
if (type.isFunction(col.cellRenderer)) {
return {
...col,
cellRenderer: (params) => {
return renderHtml({
html: col.cellRenderer(params),
methods: this.props.methods,
});
},
};
}
return col;
});
return (
<AgGridReact
onFilterChanged={this.onFilterChanged}
@ -150,7 +136,7 @@ class AgGrid extends React.Component {
onCellClicked={this.onCellClicked}
onGridReady={this.onGridReady}
modules={AllCommunityModules}
columnDefs={newColDefs}
columnDefs={processColDefs(columnDefs)}
{...someProperties}
/>
);

View File

@ -18,9 +18,8 @@ import React from 'react';
import { AgGridReact } from '@ag-grid-community/react';
import { AllCommunityModules } from '@ag-grid-community/all-modules';
import { renderHtml } from '@lowdefy/block-utils';
import { type } from '@lowdefy/helpers';
import processColDefs from './processColDefs.js';
class AgGridInput extends React.Component {
constructor(props) {
super(props);
@ -176,20 +175,6 @@ class AgGridInput extends React.Component {
if (quickFilterValue && quickFilterValue === '') {
this.gridApi.setQuickFilter(quickFilterValue); // check if empty string matches all
}
const newColDefs = (columnDefs || []).map((col) => {
if (type.isFunction(col.cellRenderer)) {
return {
...col,
cellRenderer: (params) => {
return renderHtml({
html: col.cellRenderer(params),
methods: this.props.methods,
});
},
};
}
return col;
});
return (
<AgGridReact
onSelectionChanged={this.onSelectionChanged}
@ -201,7 +186,7 @@ class AgGridInput extends React.Component {
onCellValueChanged={this.onCellValueChanged}
postSort={this.postSort}
modules={AllCommunityModules}
columnDefs={newColDefs}
columnDefs={processColDefs(columnDefs)}
{...someProperties}
rowData={this.props.value}
/>

View File

@ -0,0 +1,45 @@
/*
Copyright 2021 Lowdefy, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { renderHtml } from '@lowdefy/block-utils';
import { type } from '@lowdefy/helpers';
function recProcessColDefs(columnDefs) {
return columnDefs.map((col) => {
const newColDef = {};
if (type.isArray(col.children)) {
newColDef.children = recProcessColDefs(col.children);
}
if (type.isFunction(col.cellRenderer)) {
newColDef.cellRenderer = (params) => {
return renderHtml({
html: col.cellRenderer(params),
methods: this.props.methods,
});
};
}
return {
...col,
...newColDef,
};
});
}
function processColDefs(columnDefs = []) {
return recProcessColDefs(columnDefs);
}
export default processColDefs;