UNPKG

@integec/grid-tools

Version:
224 lines (200 loc) 5.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createData = exports.headers = exports.randomRow = void 0; var _range2 = _interopRequireDefault(require("ramda/src/range")); var _map2 = _interopRequireDefault(require("ramda/src/map")); var _fromPairs2 = _interopRequireDefault(require("ramda/src/fromPairs")); var _compose2 = _interopRequireDefault(require("ramda/src/compose")); var _chance = _interopRequireDefault(require("chance")); var _moment = _interopRequireDefault(require("moment")); var _cols = require("../cols"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } var chance = new _chance["default"](); //* test helpers var randomRow = (0, _compose2["default"])(_fromPairs2["default"], (0, _map2["default"])(function (_ref) { var ident = _ref.ident, type = _ref.type, dataFormat = _ref.dataFormat; if (ident === 'commitStatusOvr') return [ident, chance.pickone(['UNA', 'ECO', 'EMER', 'MUST'])]; if (ident === 'unitId') return [ident, chance.pickone(['u1', 'u2', 'u3', 'u4'])]; if (ident === 'he') return [ident, chance.integer({ min: 1, max: 24 })]; switch (type) { case 'str': case 'sel': return [ident, chance.word() + ' ' + chance.word() + ' ' + chance.word()]; case 'num': return [ident, chance.floating({ fixed: 2, min: 0, max: 50000 })]; case 'bool': return [ident, chance.bool()]; case 'date-time': return [ident, (0, _moment["default"])(chance.date()).format(dataFormat)]; } })); /** * The following are example of what choices and dataFormatter should be * They are not normally created this way * the toSelectionColProps function in utils.js * should be used to create these 2 objects. * They are coded this way here to demostrate what their strcutrues should be */ // TODO add documentation /** choices */ exports.randomRow = randomRow; var unitChoices = [{ value: 'u1', text: 'Unit 4' }, { value: 'u2', text: 'Unit 1' }, { value: 'u3', text: 'Unit 2' }, { value: 'u4', text: 'Unit 3' }]; var unitMap = { u1: 'Unit4', u2: 'Unit1', u3: 'Unit2', u4: 'Unit3' // TODO add documentation /** data-formatter */ }; var unitDataFormatter = function unitDataFormatter(_ref2) { var value = _ref2.value; return unitMap[value] || value; }; /* prettier-ignore */ var headers = [(0, _cols.dateCol)({ ident: 'transDate', display: 'Trans-Date', width: 140, isKey: true }), (0, _cols.strCol)({ ident: 'unitId', display: 'Unit', width: 180, isKey: true, dataFormatter: unitDataFormatter, choices: unitChoices, acceptRawText: true, setInvalidMessage: function setInvalidMessage(_ref3) { var value = _ref3.value; return !unitMap[value] && value !== 'prakash' && 'Please Enter Valid Data.'; } }), (0, _cols.intCol)({ ident: 'he', display: 'HE', width: 40, isKey: true, numFormat: "0" }), (0, _cols.strCol)({ ident: 'fixedGen', display: 'Fixed Gen', ellipsis: true }), (0, _cols.numCol)({ ident: 'emerMinOvr', display: 'Emer Min', width: 120, alignment: 'right', displayFormat: null, ellipsis: true }), (0, _cols.numCol)({ ident: 'ecoMinOvr', display: 'Eco Min' }), (0, _cols.numCol)({ ident: 'ecoMaxOvr', display: 'Eco Max' }), (0, _cols.numCol)({ ident: 'emerMaxOvr', display: 'Emer Max' }), (0, _cols.strCol)({ ident: 'commitStatusOvr', display: 'Commit Status' }), (0, _cols.numCol)({ ident: 'regMwOvr', display: 'Reg Mw' }), (0, _cols.numCol)({ ident: 'regMinOvr', display: 'Reg Min' }), (0, _cols.numCol)({ ident: 'regMaxOvr', display: 'Reg Max' }), (0, _cols.strCol)({ ident: 'regAStatusOvr', display: 'Reg A Status', ellipsis: true }), (0, _cols.strCol)({ ident: 'spilling', display: 'Spilling', ellipsis: true }), (0, _cols.pctCol)({ ident: 'reducedRampRatePct', display: 'Reduce Ramp Percent', width: 220 }), (0, _cols.dollarCol)({ ident: 'regAPrice', display: 'Reg A Price', width: 120 }), (0, _cols.dollarCol)({ ident: 'regACost', display: 'Reg A Cost', width: 120 }), (0, _cols.dollarCol)({ ident: 'regAPerfPrice', display: 'Reg A Perf Price', width: 120 }), (0, _cols.dollarCol)({ ident: 'regAPerfCost', display: 'Reg A Perf Cost', width: 120 }), (0, _cols.strCol)({ ident: 'regDStatus', display: 'Reg D status', ellipsis: true }), (0, _cols.dollarCol)({ ident: 'regDPrice', display: 'Reg D Price', width: 120 }), (0, _cols.dollarCol)({ ident: 'regDCost', display: 'Reg D Cost', width: 120 }), (0, _cols.dollarCol)({ ident: 'regDPerfPrice', display: 'Reg D Perf Price', width: 120 }), (0, _cols.dollarCol)({ ident: 'regDPerfCost', display: 'Reg D Perf Cost', width: 120 }), (0, _cols.numCol)({ ident: 'spinMwOvr', display: 'Spin Mw' }), (0, _cols.numCol)({ ident: 'spinMaxOvr', display: 'Spin Max' }), (0, _cols.strCol)({ ident: 'spinStatusOvr', display: 'Spin Status', ellipsis: true }), (0, _cols.dollarCol)({ ident: 'spinPrice', display: 'Spin Price', width: 120 })]; exports.headers = headers; var createRow = function createRow(_) { return randomRow(headers); }; var createData = (0, _compose2["default"])((0, _map2["default"])(createRow), (0, _range2["default"])(0)); exports.createData = createData; //# sourceMappingURL=data.js.map