Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (fields.length > 0) {
fields.forEach(field=> {
const column = attributes.find(attr => attr.name === field);
if (column) { columns.push(column); }
});
} else {
columns = [...sortedAttributes];
}
if (orderBy.length > 0) {
sorts = orderBy.map(o => { return { orderBy: o.field, order: o.direction } });
} else {
// adding the default sort
sorts = [{
orderBy: levelColumn.name,
order: ConseilSortDirection.DESC
}];
query = addOrdering(query, sorts[0].orderBy, sorts[0].order);
}
// initFilters
filters = predicates.map(predicate => {
const selectedAttribute = attributes.find(attr => attr.name === predicate.field);
const isLowCardinality = selectedAttribute.cardinality !== undefined && selectedAttribute.cardinality < CARDINALITY_NUMBER;
if (isLowCardinality) {
cardinalityPromises.push(
dispatch(initCardinalityValues(platform, entity, network, selectedAttribute.name, serverInfo))
);
}
const operatorType = getOperatorType(selectedAttribute.dataType);
let operator = predicate.operation;
if (predicate.inverse) {
handleRequestSort = async (orderBy: string) => {
const { selectedSort, selectedEntity, onSetSort, onSubmitQuery } = this.props;
let order = ConseilSortDirection.DESC;
if (selectedSort.orderBy === orderBy && selectedSort.order === 'desc') {
order = ConseilSortDirection.ASC;
}
const sorts: Sort[] = [{ orderBy, order }];
await onSetSort(selectedEntity, sorts);
onSubmitQuery();
};