dtable-sdk
Advanced tools
Comparing version 0.0.132-beta2 to 0.0.132-beta3
@@ -12,6 +12,2 @@ "use strict"; | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
@@ -37,432 +33,419 @@ | ||
var StatUtils = /*#__PURE__*/function () { | ||
function StatUtils() { | ||
_classCallCheck(this, StatUtils); | ||
} | ||
var StatUtils = function StatUtils() { | ||
var _this = this; | ||
_createClass(StatUtils, null, [{ | ||
key: "isValidRow", | ||
value: function isValidRow(row, formulaRow, linkRow, column, includeEmpty) { | ||
var columnType = column.type, | ||
columnKey = column.key; | ||
if (includeEmpty) return true; | ||
var cellValue; | ||
_classCallCheck(this, StatUtils); | ||
if (columnType === _dtableStore.CellType.FORMULA || columnType === _dtableStore.CellType.LINK_FORMULA) { | ||
cellValue = formulaRow ? formulaRow[columnKey] : null; | ||
} else if (columnType === _dtableStore.CellType.GEOLOCATION) { | ||
var value = row[columnKey]; | ||
var geo_format = column.data.geo_format; | ||
return isEmptyGeolocationCell(value, geo_format); | ||
} else if (columnType === _dtableStore.CellType.LINK) { | ||
cellValue = linkRow ? linkRow[columnKey] : null; | ||
} else { | ||
cellValue = row[columnKey]; | ||
} | ||
_defineProperty(this, "init", function () { | ||
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
_this.config = config; | ||
}); | ||
return cellValue || cellValue === 0; | ||
_defineProperty(this, "getStatisticRows", function (table, view, value) { | ||
var _ref = _this.config || {}, | ||
_ref$username = _ref.username, | ||
username = _ref$username === void 0 ? null : _ref$username, | ||
_ref$userId = _ref.userId, | ||
userId = _ref$userId === void 0 ? null : _ref$userId; | ||
console.log('config: ', _this.config); | ||
if (_dtableStore.Views.isFilterView(view, table.columns)) { | ||
return _dtableStore.TableUtils.getRowsByIds(table, _dtableStore.Views.getRowIds(view, table, value, username, userId)); | ||
} | ||
}, { | ||
key: "getLinkDisplayString", | ||
value: function getLinkDisplayString(rowIds, linkedTable) { | ||
var displayColumnKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '0000'; | ||
return (0, _dtableStore.getLinkDisplayString)(rowIds, linkedTable, displayColumnKey); | ||
return table.rows; | ||
}); | ||
_defineProperty(this, "isValidRow", function (row, formulaRow, linkRow, column, includeEmpty) { | ||
var columnType = column.type, | ||
columnKey = column.key; | ||
if (includeEmpty) return true; | ||
var cellValue; | ||
if (columnType === _dtableStore.CellType.FORMULA || columnType === _dtableStore.CellType.LINK_FORMULA) { | ||
cellValue = formulaRow ? formulaRow[columnKey] : null; | ||
} else if (columnType === _dtableStore.CellType.GEOLOCATION) { | ||
var value = row[columnKey]; | ||
var geo_format = column.data.geo_format; | ||
return isEmptyGeolocationCell(value, geo_format); | ||
} else if (columnType === _dtableStore.CellType.LINK) { | ||
cellValue = linkRow ? linkRow[columnKey] : null; | ||
} else { | ||
cellValue = row[columnKey]; | ||
} | ||
}, { | ||
key: "getNumberDisplayString", | ||
value: function getNumberDisplayString(value, columnData) { | ||
return (0, _dtableStore.getNumberDisplayString)(value, columnData); | ||
} | ||
}, { | ||
key: "getTableFormulaResults", | ||
value: function getTableFormulaResults(table, rows, value) { | ||
return _dtableStore.Views.getTableFormulaResults(table, rows, value); | ||
} | ||
}, { | ||
key: "getTableLinkRows", | ||
value: function getTableLinkRows(rows, table, value) { | ||
return _dtableStore.RowUtils.getTableLinkRows(rows, table, value); | ||
} | ||
}, { | ||
key: "getCellValueDisplayString", | ||
value: function getCellValueDisplayString(row, type, key, _ref) { | ||
var _ref$tables = _ref.tables, | ||
tables = _ref$tables === void 0 ? [] : _ref$tables, | ||
_ref$formulaRows = _ref.formulaRows, | ||
formulaRows = _ref$formulaRows === void 0 ? {} : _ref$formulaRows, | ||
data = _ref.data, | ||
_ref$collaborators = _ref.collaborators, | ||
collaborators = _ref$collaborators === void 0 ? [] : _ref$collaborators; | ||
return (0, _dtableStore.getCellValueDisplayString)(row, type, key, { | ||
tables: tables, | ||
formulaRows: formulaRows, | ||
data: data, | ||
collaborators: collaborators | ||
}); | ||
} | ||
}, { | ||
key: "getGroupLabel", | ||
value: function getGroupLabel(cellValue, formulaRow, linkRow, column, dateGranularity, geoGranularity, value) { | ||
var type = column.type, | ||
key = column.key, | ||
data = column.data; | ||
switch (type) { | ||
case _dtableStore.CellType.TEXT: | ||
{ | ||
return cellValue || null; | ||
} | ||
return cellValue || cellValue === 0; | ||
}); | ||
case _dtableStore.CellType.NUMBER: | ||
{ | ||
if (!cellValue && cellValue !== 0) { | ||
return null; | ||
} | ||
_defineProperty(this, "getLinkDisplayString", function (rowIds, linkedTable) { | ||
var displayColumnKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '0000'; | ||
return (0, _dtableStore.getLinkDisplayString)(rowIds, linkedTable, displayColumnKey); | ||
}); | ||
var number = (0, _dtableStore.getPrecisionNumber)(cellValue, data); | ||
var valueNumber = parseFloat(number); | ||
return (0, _dtableStore.isNumber)(valueNumber) ? (0, _dtableStore.getNumberDisplayString)(valueNumber, column.data) : valueNumber; | ||
} | ||
_defineProperty(this, "getNumberDisplayString", function (value, columnData) { | ||
return (0, _dtableStore.getNumberDisplayString)(value, columnData); | ||
}); | ||
case _dtableStore.CellType.SINGLE_SELECT: | ||
{ | ||
var isInvalidValue = data && data.options.findIndex(function (opt) { | ||
return opt.id === cellValue; | ||
}) < 0; | ||
_defineProperty(this, "getTableFormulaResults", function (table, rows, value) { | ||
return _dtableStore.Views.getTableFormulaResults(table, rows, value); | ||
}); | ||
if (isInvalidValue) { | ||
return null; | ||
} | ||
_defineProperty(this, "getTableLinkRows", function (rows, table, value) { | ||
return _dtableStore.RowUtils.getTableLinkRows(rows, table, value); | ||
}); | ||
return cellValue; | ||
} | ||
_defineProperty(this, "getCellValueDisplayString", function (row, type, key, _ref2) { | ||
var _ref2$tables = _ref2.tables, | ||
tables = _ref2$tables === void 0 ? [] : _ref2$tables, | ||
_ref2$formulaRows = _ref2.formulaRows, | ||
formulaRows = _ref2$formulaRows === void 0 ? {} : _ref2$formulaRows, | ||
data = _ref2.data, | ||
_ref2$collaborators = _ref2.collaborators, | ||
collaborators = _ref2$collaborators === void 0 ? [] : _ref2$collaborators; | ||
return (0, _dtableStore.getCellValueDisplayString)(row, type, key, { | ||
tables: tables, | ||
formulaRows: formulaRows, | ||
data: data, | ||
collaborators: collaborators | ||
}); | ||
}); | ||
case _dtableStore.CellType.DATE: | ||
case _dtableStore.CellType.CTIME: | ||
case _dtableStore.CellType.MTIME: | ||
{ | ||
if (!dateGranularity) { | ||
return (0, _dtableStore.getDateDisplayString)(cellValue); | ||
} | ||
_defineProperty(this, "getGroupLabel", function (cellValue, formulaRow, linkRow, column, dateGranularity, geoGranularity, value) { | ||
var type = column.type, | ||
key = column.key, | ||
data = column.data; | ||
return _dtableStore.DateUtils.getDateByGranularity(cellValue, dateGranularity); | ||
switch (type) { | ||
case _dtableStore.CellType.TEXT: | ||
{ | ||
return cellValue || null; | ||
} | ||
case _dtableStore.CellType.NUMBER: | ||
{ | ||
if (!cellValue && cellValue !== 0) { | ||
return null; | ||
} | ||
case _dtableStore.CellType.MULTIPLE_SELECT: | ||
{ | ||
var options = data && data.options; | ||
var number = (0, _dtableStore.getPrecisionNumber)(cellValue, data); | ||
var valueNumber = parseFloat(number); | ||
return (0, _dtableStore.isNumber)(valueNumber) ? (0, _dtableStore.getNumberDisplayString)(valueNumber, column.data) : valueNumber; | ||
} | ||
if (!Array.isArray(cellValue)) { | ||
return []; | ||
} | ||
case _dtableStore.CellType.SINGLE_SELECT: | ||
{ | ||
var isInvalidValue = data && data.options.findIndex(function (opt) { | ||
return opt.id === cellValue; | ||
}) < 0; | ||
return cellValue.filter(function (id) { | ||
return options.findIndex(function (o) { | ||
return o.id === id; | ||
}) > -1; | ||
}); | ||
if (isInvalidValue) { | ||
return null; | ||
} | ||
case _dtableStore.CellType.COLLABORATOR: | ||
{ | ||
return getValidCollaborators(value.collaborators, cellValue); | ||
} | ||
return cellValue; | ||
} | ||
case _dtableStore.CellType.CREATOR: | ||
case _dtableStore.CellType.LAST_MODIFIER: | ||
{ | ||
return cellValue ? cellValue : null; | ||
case _dtableStore.CellType.DATE: | ||
case _dtableStore.CellType.CTIME: | ||
case _dtableStore.CellType.MTIME: | ||
{ | ||
if (!dateGranularity) { | ||
return (0, _dtableStore.getDateDisplayString)(cellValue); | ||
} | ||
case _dtableStore.CellType.LINK_FORMULA: | ||
case _dtableStore.CellType.FORMULA: | ||
{ | ||
if (!formulaRow) return ''; | ||
var formulaCellValue = formulaRow[key]; | ||
return _dtableStore.DateUtils.getDateByGranularity(cellValue, dateGranularity); | ||
} | ||
var _ref2 = data || {}, | ||
result_type = _ref2.result_type; | ||
case _dtableStore.CellType.MULTIPLE_SELECT: | ||
{ | ||
var options = data && data.options; | ||
if (result_type === _dtableStore.FORMULA_RESULT_TYPE.ARRAY) { | ||
return (0, _dtableStore.getFormulaDisplayString)(formulaCellValue, data, { | ||
tables: value.tables | ||
}) || null; | ||
} | ||
if (!Array.isArray(cellValue)) { | ||
return []; | ||
} | ||
if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) { | ||
return (0, _dtableStore.getPrecisionNumber)(formulaCellValue, data); | ||
} | ||
return cellValue.filter(function (id) { | ||
return options.findIndex(function (o) { | ||
return o.id === id; | ||
}) > -1; | ||
}); | ||
} | ||
return formulaCellValue ? formulaCellValue + '' : null; | ||
} | ||
case _dtableStore.CellType.COLLABORATOR: | ||
{ | ||
return getValidCollaborators(value.collaborators, cellValue); | ||
} | ||
case _dtableStore.CellType.GEOLOCATION: | ||
{ | ||
var _ref3 = data || {}, | ||
geo_format = _ref3.geo_format; | ||
case _dtableStore.CellType.CREATOR: | ||
case _dtableStore.CellType.LAST_MODIFIER: | ||
{ | ||
return cellValue ? cellValue : null; | ||
} | ||
if (geo_format === 'country_region' || geo_format === 'lng_lat' || !geoGranularity) { | ||
return (0, _dtableStore.getGeolocationDisplayString)(cellValue, data); | ||
} | ||
case _dtableStore.CellType.LINK_FORMULA: | ||
case _dtableStore.CellType.FORMULA: | ||
{ | ||
if (!formulaRow) return ''; | ||
var formulaCellValue = formulaRow[key]; | ||
return cellValue ? cellValue[geoGranularity] : null; | ||
var _ref3 = data || {}, | ||
result_type = _ref3.result_type; | ||
if (result_type === _dtableStore.FORMULA_RESULT_TYPE.ARRAY) { | ||
return (0, _dtableStore.getFormulaDisplayString)(formulaCellValue, data, { | ||
tables: value.tables | ||
}) || null; | ||
} | ||
case _dtableStore.CellType.LINK: | ||
{ | ||
if (!linkRow) return null; | ||
var linkCellValue = linkRow[key] || cellValue; | ||
return linkCellValue || []; | ||
if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) { | ||
return (0, _dtableStore.getPrecisionNumber)(formulaCellValue, data); | ||
} | ||
case _dtableStore.CellType.RATE: | ||
{ | ||
if (!cellValue) return null; | ||
return cellValue + ''; | ||
return formulaCellValue ? formulaCellValue + '' : null; | ||
} | ||
case _dtableStore.CellType.GEOLOCATION: | ||
{ | ||
var _ref4 = data || {}, | ||
geo_format = _ref4.geo_format; | ||
if (geo_format === 'country_region' || geo_format === 'lng_lat' || !geoGranularity) { | ||
return (0, _dtableStore.getGeolocationDisplayString)(cellValue, data); | ||
} | ||
default: | ||
{ | ||
return null; | ||
} | ||
} | ||
return cellValue ? cellValue[geoGranularity] : null; | ||
} | ||
case _dtableStore.CellType.LINK: | ||
{ | ||
if (!linkRow) return null; | ||
var linkCellValue = linkRow[key] || cellValue; | ||
return linkCellValue || []; | ||
} | ||
case _dtableStore.CellType.RATE: | ||
{ | ||
if (!cellValue) return null; | ||
return cellValue + ''; | ||
} | ||
default: | ||
{ | ||
return null; | ||
} | ||
} | ||
}, { | ||
key: "getTotal", | ||
value: function getTotal(summary_column_key, summary_column_type, summary_type, summary_method) { | ||
var rows = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : []; | ||
var formula_rows = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {}; | ||
var rowsLength = rows.length; | ||
var total; | ||
}); | ||
if (summary_type === STATISTICS_COUNT_TYPE.COUNT) { | ||
total = rowsLength; | ||
} else if (summary_type === STATISTICS_COUNT_TYPE.ADVANCED) { | ||
switch (summary_method) { | ||
case "Sum": | ||
case "Mean": | ||
{ | ||
var sum = 0; | ||
var validNumbersCount = 0; | ||
rows.forEach(function (r) { | ||
var num; | ||
_defineProperty(this, "getTotal", function (summary_column_key, summary_column_type, summary_type, summary_method) { | ||
var rows = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : []; | ||
var formula_rows = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {}; | ||
var rowsLength = rows.length; | ||
var total; | ||
if (_dtableStore.FORMULA_COLUMN_TYPES.includes(summary_column_type)) { | ||
var formulaRow = formula_rows[r._id] || {}; | ||
num = formulaRow[summary_column_key]; | ||
num = Array.isArray(num) ? num[0] : num; | ||
} else { | ||
num = r[summary_column_key]; | ||
} | ||
if (summary_type === STATISTICS_COUNT_TYPE.COUNT) { | ||
total = rowsLength; | ||
} else if (summary_type === STATISTICS_COUNT_TYPE.ADVANCED) { | ||
switch (summary_method) { | ||
case "Sum": | ||
case "Mean": | ||
{ | ||
var sum = 0; | ||
var validNumbersCount = 0; | ||
rows.forEach(function (r) { | ||
var num; | ||
if ((0, _dtableStore.isNumber)(num)) { | ||
validNumbersCount++; | ||
sum += num; | ||
} | ||
}); | ||
if (_dtableStore.FORMULA_COLUMN_TYPES.includes(summary_column_type)) { | ||
var formulaRow = formula_rows[r._id] || {}; | ||
num = formulaRow[summary_column_key]; | ||
num = Array.isArray(num) ? num[0] : num; | ||
} else { | ||
num = r[summary_column_key]; | ||
} | ||
if (summary_method === "Sum") { | ||
total = Number.parseFloat(sum.toFixed(8)); | ||
} else if (summary_method === "Mean") { | ||
total = validNumbersCount === 0 ? 0 : Number.parseFloat((sum / validNumbersCount).toFixed(8)); | ||
if ((0, _dtableStore.isNumber)(num)) { | ||
validNumbersCount++; | ||
sum += num; | ||
} | ||
}); | ||
break; | ||
if (summary_method === "Sum") { | ||
total = Number.parseFloat(sum.toFixed(8)); | ||
} else if (summary_method === "Mean") { | ||
total = validNumbersCount === 0 ? 0 : Number.parseFloat((sum / validNumbersCount).toFixed(8)); | ||
} | ||
case "Max": | ||
case "Min": | ||
{ | ||
if (rowsLength > 0) { | ||
var result = rows.reduce(function (current, next) { | ||
var currentValue, nextValue; | ||
break; | ||
} | ||
if (_dtableStore.FORMULA_COLUMN_TYPES.includes(summary_column_type)) { | ||
var currentFormulaRow = formula_rows[current._id]; | ||
var nextFormulaRow = formula_rows[next._id]; | ||
currentValue = currentFormulaRow && currentFormulaRow[summary_column_key]; | ||
nextValue = nextFormulaRow && nextFormulaRow[summary_column_key]; | ||
currentValue = Array.isArray(currentValue) ? currentValue[0] : currentValue; | ||
nextValue = Array.isArray(nextValue) ? nextValue[0] : nextValue; | ||
} else { | ||
currentValue = current[summary_column_key]; | ||
nextValue = next[summary_column_key]; | ||
} | ||
case "Max": | ||
case "Min": | ||
{ | ||
if (rowsLength > 0) { | ||
var result = rows.reduce(function (current, next) { | ||
var currentValue, nextValue; | ||
if (!nextValue && nextValue !== 0) { | ||
return current; | ||
} | ||
if (_dtableStore.FORMULA_COLUMN_TYPES.includes(summary_column_type)) { | ||
var currentFormulaRow = formula_rows[current._id]; | ||
var nextFormulaRow = formula_rows[next._id]; | ||
currentValue = currentFormulaRow && currentFormulaRow[summary_column_key]; | ||
nextValue = nextFormulaRow && nextFormulaRow[summary_column_key]; | ||
currentValue = Array.isArray(currentValue) ? currentValue[0] : currentValue; | ||
nextValue = Array.isArray(nextValue) ? nextValue[0] : nextValue; | ||
} else { | ||
currentValue = current[summary_column_key]; | ||
nextValue = next[summary_column_key]; | ||
} | ||
var isNextGreater = currentValue < nextValue; | ||
if (!nextValue && nextValue !== 0) { | ||
return current; | ||
} | ||
if (summary_method === "Min") { | ||
return isNextGreater ? current : next; | ||
} else { | ||
return isNextGreater ? next : current; | ||
} | ||
}); | ||
var isNextGreater = currentValue < nextValue; | ||
if (_dtableStore.FORMULA_COLUMN_TYPES.includes(summary_column_type)) { | ||
var formulaRow = formula_rows[result._id]; | ||
total = formulaRow && formulaRow[summary_column_key]; | ||
total = Array.isArray(total) ? total[0] : total; | ||
if (summary_method === "Min") { | ||
return isNextGreater ? current : next; | ||
} else { | ||
total = result[summary_column_key]; | ||
return isNextGreater ? next : current; | ||
} | ||
}); | ||
if (_dtableStore.FORMULA_COLUMN_TYPES.includes(summary_column_type)) { | ||
var formulaRow = formula_rows[result._id]; | ||
total = formulaRow && formulaRow[summary_column_key]; | ||
total = Array.isArray(total) ? total[0] : total; | ||
} else { | ||
total = result[summary_column_key]; | ||
} | ||
break; | ||
} | ||
default: | ||
{ | ||
break; | ||
} | ||
} | ||
break; | ||
} | ||
default: | ||
{ | ||
break; | ||
} | ||
} | ||
return total || 0; | ||
} | ||
}, { | ||
key: "sortStatistics", | ||
value: function sortStatistics(statistics, column, sort_key) { | ||
var column_type = column.type, | ||
data = column.data; | ||
var sortType = 'up'; | ||
var option_id_index_map = {}; | ||
if (column_type === _dtableStore.CellType.SINGLE_SELECT) { | ||
var _ref4 = data || {}, | ||
options = _ref4.options; | ||
return total || 0; | ||
}); | ||
Array.isArray(options) && options.forEach(function (option, index) { | ||
option_id_index_map[option.id] = index; | ||
}); | ||
} | ||
_defineProperty(this, "sortStatistics", function (statistics, column, sort_key) { | ||
var column_type = column.type, | ||
data = column.data; | ||
var sortType = 'up'; | ||
var option_id_index_map = {}; | ||
statistics.sort(function (currResult, nextResult) { | ||
var current = currResult[sort_key]; | ||
var next = nextResult[sort_key]; | ||
if (column_type === _dtableStore.CellType.SINGLE_SELECT) { | ||
var _ref5 = data || {}, | ||
options = _ref5.options; | ||
if (!current && current !== 0) { | ||
return -1; | ||
} | ||
Array.isArray(options) && options.forEach(function (option, index) { | ||
option_id_index_map[option.id] = index; | ||
}); | ||
} | ||
if (!next && next !== 0) { | ||
return 1; | ||
} | ||
statistics.sort(function (currResult, nextResult) { | ||
var current = currResult[sort_key]; | ||
var next = nextResult[sort_key]; | ||
if (SUPPORT_SORT_COLUMNS.includes(column_type)) { | ||
switch (column_type) { | ||
case _dtableStore.CellType.NUMBER: | ||
{ | ||
if (current) { | ||
current = current - 0; | ||
} | ||
if (!current && current !== 0) { | ||
return -1; | ||
} | ||
if (next) { | ||
next = next - 0; | ||
} | ||
if (!next && next !== 0) { | ||
return 1; | ||
} | ||
return (0, _dtableStore.sortNumber)(current, next, sortType); | ||
if (SUPPORT_SORT_COLUMNS.includes(column_type)) { | ||
switch (column_type) { | ||
case _dtableStore.CellType.NUMBER: | ||
{ | ||
if (current) { | ||
current = current - 0; | ||
} | ||
case _dtableStore.CellType.DATE: | ||
case _dtableStore.CellType.CTIME: | ||
case _dtableStore.CellType.MTIME: | ||
{ | ||
return (0, _dtableStore.sortDate)(current, next, sortType); | ||
if (next) { | ||
next = next - 0; | ||
} | ||
case _dtableStore.CellType.SINGLE_SELECT: | ||
case _dtableStore.CellType.MULTIPLE_SELECT: | ||
{ | ||
return (0, _dtableStore.sortSingleSelect)(current, next, { | ||
sort_type: sortType, | ||
option_id_index_map: option_id_index_map | ||
}); | ||
} | ||
return (0, _dtableStore.sortNumber)(current, next, sortType); | ||
} | ||
case _dtableStore.CellType.FORMULA: | ||
case _dtableStore.CellType.LINK_FORMULA: | ||
{ | ||
var _ref5 = data || {}, | ||
result_type = _ref5.result_type; | ||
case _dtableStore.CellType.DATE: | ||
case _dtableStore.CellType.CTIME: | ||
case _dtableStore.CellType.MTIME: | ||
{ | ||
return (0, _dtableStore.sortDate)(current, next, sortType); | ||
} | ||
if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) { | ||
if (current) { | ||
current = current - 0; | ||
} | ||
case _dtableStore.CellType.SINGLE_SELECT: | ||
case _dtableStore.CellType.MULTIPLE_SELECT: | ||
{ | ||
return (0, _dtableStore.sortSingleSelect)(current, next, { | ||
sort_type: sortType, | ||
option_id_index_map: option_id_index_map | ||
}); | ||
} | ||
if (next) { | ||
next = next - 0; | ||
} | ||
case _dtableStore.CellType.FORMULA: | ||
case _dtableStore.CellType.LINK_FORMULA: | ||
{ | ||
var _ref6 = data || {}, | ||
result_type = _ref6.result_type; | ||
return (0, _dtableStore.sortNumber)(current, next, sortType); | ||
if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) { | ||
if (current) { | ||
current = current - 0; | ||
} | ||
return (0, _dtableStore.sortText)(result_type, current, next, sortType); | ||
} | ||
if (next) { | ||
next = next - 0; | ||
} | ||
default: | ||
{ | ||
return (0, _dtableStore.sortText)(current, next, sortType); | ||
return (0, _dtableStore.sortNumber)(current, next, sortType); | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
}, { | ||
key: "sortStatisticData", | ||
value: function sortStatisticData(statistics, sort_type) { | ||
statistics.sort(function (currResult, nextResult) { | ||
var current = currResult.value; | ||
var next = nextResult.value; | ||
if (!current && current !== 0) { | ||
return -1; | ||
} | ||
return (0, _dtableStore.sortText)(result_type, current, next, sortType); | ||
} | ||
if (!next && next !== 0) { | ||
return 1; | ||
default: | ||
{ | ||
return (0, _dtableStore.sortText)(current, next, sortType); | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
if (sort_type === 'ascending') { | ||
return current > next ? 1 : -1; | ||
} else { | ||
return current > next ? -1 : 1; | ||
} | ||
}); | ||
} | ||
}, { | ||
key: "isArrayCellValue", | ||
value: function isArrayCellValue(columnType) { | ||
return [_dtableStore.CellType.MULTIPLE_SELECT, _dtableStore.CellType.COLLABORATOR, _dtableStore.CellType.LINK].includes(columnType); | ||
} | ||
}]); | ||
_defineProperty(this, "sortStatisticData", function (statistics, sort_type) { | ||
statistics.sort(function (currResult, nextResult) { | ||
var current = currResult.value; | ||
var next = nextResult.value; | ||
return StatUtils; | ||
}(); | ||
if (!current && current !== 0) { | ||
return -1; | ||
} | ||
_defineProperty(StatUtils, "init", function () { | ||
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
StatUtils.config = config; | ||
}); | ||
if (!next && next !== 0) { | ||
return 1; | ||
} | ||
_defineProperty(StatUtils, "getStatisticRows", function (table, view, value) { | ||
var _ref6 = StatUtils.config || {}, | ||
_ref6$username = _ref6.username, | ||
username = _ref6$username === void 0 ? null : _ref6$username, | ||
_ref6$userId = _ref6.userId, | ||
userId = _ref6$userId === void 0 ? null : _ref6$userId; | ||
if (sort_type === 'ascending') { | ||
return current > next ? 1 : -1; | ||
} else { | ||
return current > next ? -1 : 1; | ||
} | ||
}); | ||
}); | ||
console.log('config: ', StatUtils.config); | ||
_defineProperty(this, "isArrayCellValue", function (columnType) { | ||
return [_dtableStore.CellType.MULTIPLE_SELECT, _dtableStore.CellType.COLLABORATOR, _dtableStore.CellType.LINK].includes(columnType); | ||
}); | ||
if (_dtableStore.Views.isFilterView(view, table.columns)) { | ||
return _dtableStore.TableUtils.getRowsByIds(table, _dtableStore.Views.getRowIds(view, table, value, username, userId)); | ||
} | ||
this.config = {}; | ||
}; | ||
return table.rows; | ||
}); | ||
var getValidCollaborators = function getValidCollaborators(collaborators, emails) { | ||
@@ -494,3 +477,4 @@ if (!Array.isArray(emails)) { | ||
var _default = StatUtils; | ||
var _default = new StatUtils(); | ||
exports["default"] = _default; |
{ | ||
"name": "dtable-sdk", | ||
"version": "0.0.132beta2", | ||
"version": "0.0.132beta3", | ||
"description": "dtable sdk", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
65765
1382