How to use tubular-common - 10 common examples

To help you get started, we’ve selected a few tubular-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github unosquare / tubular-react / test / utils / columns.ts View on Github external
Sortable: true
});

// Column samples
const validColumnsSample = [
  regularOrderIdCol,
  new ColumnModel('CustomerName', {
    Aggregate: AggregateFunctions.COUNT,
    Filterable: true,
    Searchable: true
  }),
  new ColumnModel('ShippedDate', {
    DataType: ColumnDataType.DATE_TIME,
    Filterable: true
  }),
  new ColumnModel('ShipperCity'),
  new ColumnModel('Amount', { DataType: ColumnDataType.NUMERIC })
];

export { validColumnsSample };
github unosquare / tubular-react / test / utils / columns.ts View on Github external
import {
  AggregateFunctions,
  ColumnDataType,
  ColumnModel,
  ColumnSortDirection
} from 'tubular-common';

const regularOrderIdCol = new ColumnModel('OrderID', {
  DataType: ColumnDataType.NUMERIC,
  Filterable: true,
  IsKey: true,
  SortDirection: ColumnSortDirection.ASCENDING,
  SortOrder: 1,
  Sortable: true
});

// Column samples
const validColumnsSample = [
  regularOrderIdCol,
  new ColumnModel('CustomerName', {
    Aggregate: AggregateFunctions.COUNT,
    Filterable: true,
    Searchable: true
  }),
  new ColumnModel('ShippedDate', {
github unosquare / tubular-react / test / utils / columns.ts View on Github external
});

// Column samples
const validColumnsSample = [
  regularOrderIdCol,
  new ColumnModel('CustomerName', {
    Aggregate: AggregateFunctions.COUNT,
    Filterable: true,
    Searchable: true
  }),
  new ColumnModel('ShippedDate', {
    DataType: ColumnDataType.DATE_TIME,
    Filterable: true
  }),
  new ColumnModel('ShipperCity'),
  new ColumnModel('Amount', { DataType: ColumnDataType.NUMERIC })
];

export { validColumnsSample };
github unosquare / tubular-react / test / utils / columns.ts View on Github external
IsKey: true,
  SortDirection: ColumnSortDirection.ASCENDING,
  SortOrder: 1,
  Sortable: true
});

// Column samples
const validColumnsSample = [
  regularOrderIdCol,
  new ColumnModel('CustomerName', {
    Aggregate: AggregateFunctions.COUNT,
    Filterable: true,
    Searchable: true
  }),
  new ColumnModel('ShippedDate', {
    DataType: ColumnDataType.DATE_TIME,
    Filterable: true
  }),
  new ColumnModel('ShipperCity'),
  new ColumnModel('Amount', { DataType: ColumnDataType.NUMERIC })
];

export { validColumnsSample };
github unosquare / tubular-react / test / utils / columns.ts View on Github external
import {
  AggregateFunctions,
  ColumnDataType,
  ColumnModel,
  ColumnSortDirection
} from 'tubular-common';

const regularOrderIdCol = new ColumnModel('OrderID', {
  DataType: ColumnDataType.NUMERIC,
  Filterable: true,
  IsKey: true,
  SortDirection: ColumnSortDirection.ASCENDING,
  SortOrder: 1,
  Sortable: true
});

// Column samples
const validColumnsSample = [
  regularOrderIdCol,
  new ColumnModel('CustomerName', {
    Aggregate: AggregateFunctions.COUNT,
    Filterable: true,
    Searchable: true
  }),
  new ColumnModel('ShippedDate', {
    DataType: ColumnDataType.DATE_TIME,
    Filterable: true
  }),
github unosquare / tubular-nodejs / src / connectors / jsondata.js View on Github external
switch (column.aggregate) {
            case AggregateFunctions.Sum:
                value = _.sumBy(subset, column.name);
                break;
            case AggregateFunctions.Average:
                value = _.meanBy(subset, column.name);
                break;
            case AggregateFunctions.Max:
                // .maxBy returns the object containing the max value
                value = _.maxBy(subset, column.name)[column.name];
                break;
            case AggregateFunctions.Min:
                // .minBy returns the object containing the min value
                value = _.minBy(subset, column.name)[column.name];
                break;
            case AggregateFunctions.Count:
                value = subset.length;
                break;
            case AggregateFunctions.DistinctCount:
                value = _.uniqWith(subset, (a, b) => {
                    return a[column.name] == b[column.name];
                }).length;
                break;
            default:
                throw 'Unsupported aggregate function';
        }

        return { [column.name]: value };
    });
github unosquare / tubular-nodejs / src / connectors / jsondata.js View on Github external
const results = _.map(aggregateColumns, column => {
        let value;
        switch (column.aggregate) {
            case AggregateFunctions.Sum:
                value = _.sumBy(subset, column.name);
                break;
            case AggregateFunctions.Average:
                value = _.meanBy(subset, column.name);
                break;
            case AggregateFunctions.Max:
                // .maxBy returns the object containing the max value
                value = _.maxBy(subset, column.name)[column.name];
                break;
            case AggregateFunctions.Min:
                // .minBy returns the object containing the min value
                value = _.minBy(subset, column.name)[column.name];
                break;
            case AggregateFunctions.Count:
                value = subset.length;
                break;
github unosquare / tubular-nodejs / src / connectors / knex.js View on Github external
return Promise.all(_.map(aggregateColumns, column => {
        // Do not disrupt the original query chain
        let copyOfSubset = subset.clone();

        // in order to work with aggregates
        copyOfSubset.clearSelect();

        switch (column.aggregate) {
            case AggregateFunctions.Sum:
                copyOfSubset = copyOfSubset.sum(`${column.name} as tbResult`);
                break;
            case AggregateFunctions.Average:
                copyOfSubset = copyOfSubset.avg(`${column.name} as tbResult`);
                break;
            case AggregateFunctions.Max:
                copyOfSubset = copyOfSubset.max(`${column.name} as tbResult`);
                break;
            case AggregateFunctions.Min:
                copyOfSubset = copyOfSubset.min(`${column.name} as tbResult`);
                break;
            case AggregateFunctions.Count:
                copyOfSubset = copyOfSubset.count(`${column.name} as tbResult`);
                break;
            case AggregateFunctions.DistinctCount:
                copyOfSubset = copyOfSubset.countDistinct(`${column.name} as tbResult`);
github unosquare / tubular-nodejs / src / connectors / jsondata.js View on Github external
subset = subset.filter(row => !row[filterableColumn.name].toLowerCase().endsWith(filterableColumn.filter.text));
                break;
            // TODO: check for types
            case CompareOperators.Gt:
                subset = subset.filter(row => row[filterableColumn.name] > filterableColumn.filter.text);
                break;
            case CompareOperators.Gte:
                subset = subset.filter(row => row[filterableColumn.name] >= filterableColumn.filter.text);
                break;
            case CompareOperators.Lt:
                subset = subset.filter(row => row[filterableColumn.name] < filterableColumn.filter.text);
                break;
            case CompareOperators.Lte:
                subset = subset.filter(row => row[filterableColumn.name] <= filterableColumn.filter.text);
                break;
            case CompareOperators.Between:
                subset = subset.filter(row => row[filterableColumn.name] > filterableColumn.filter.text && row[filterableColumn.name] < filterableColumn.filter.argument[0]);
                break;
            default:
                throw 'Unsupported Compare Operator';
        }
    });
github unosquare / tubular-nodejs / src / connectors / jsondata.js View on Github external
case CompareOperators.NotEquals:
                subset = subset.filter(row => row[filterableColumn.name] != filterableColumn.filter.text);
                break;
            case CompareOperators.Contains:
                subset = subset.filter(row => row[filterableColumn.name].indexOf(filterableColumn.filter.text) >= 0);
                break;
            case CompareOperators.NotContains:
                subset = subset.filter(row => row[filterableColumn.name].indexOf(filterableColumn.filter.text) < 0);
                break;
            case CompareOperators.StartsWith:
                subset = subset.filter(row => row[filterableColumn.name].toLowerCase().startsWith(filterableColumn.filter.text));
                break;
            case CompareOperators.NotStartsWith:
                subset = subset.filter(row => !row[filterableColumn.name].toLowerCase().startsWith(filterableColumn.filter.text));
                break;
            case CompareOperators.EndsWith:
                subset = subset.filter(row => row[filterableColumn.name].toLowerCase().endsWith(filterableColumn.filter.text));
                break;
            case CompareOperators.NotEndsWith:
                subset = subset.filter(row => !row[filterableColumn.name].toLowerCase().endsWith(filterableColumn.filter.text));
                break;
            // TODO: check for types
            case CompareOperators.Gt:
                subset = subset.filter(row => row[filterableColumn.name] > filterableColumn.filter.text);
                break;
            case CompareOperators.Gte:
                subset = subset.filter(row => row[filterableColumn.name] >= filterableColumn.filter.text);
                break;
            case CompareOperators.Lt:
                subset = subset.filter(row => row[filterableColumn.name] < filterableColumn.filter.text);
                break;
            case CompareOperators.Lte: