defaultRoute -> defaultResource

This commit is contained in:
Lachlan Kermode
2018-12-07 13:02:50 +00:00
parent 8a5bce0842
commit 41e2ba8299
8 changed files with 46 additions and 36 deletions

View File

@@ -0,0 +1,37 @@
import R from 'ramda'
import { defaultBlueprint, defaultResource } from '../lib/blueprinters'
/**
* byColumn - generate a Blueprint from a data sheet by column. Each column
* name is a resheet, and all values in that column are the resheet items.
*
* @param {type} data - list of lists representing sheet data.
* @return {type} Blueprint
* generated.
*/
function columns (tabName, sheetName, sheetId, data) {
// Define Blueprint props
const bp = R.clone(defaultBlueprint)
bp.sheet = {
name: sheetName,
id: sheetId
}
bp.name = tabName
// column names define resources
const labels = data[0]
labels.forEach(label => {
bp.resources[label] = R.clone(defaultResource)
})
// remaining rows as data
data.forEach((row, idx) => {
if (idx === 0) return
labels.forEach((label, idx) => {
bp.resources[label].data.push(row[idx])
})
})
return bp
}
export default columns