rename 'routes' in blueprints to 'resources'

routes was a confusing semantics that was not in order with the rest of the architecture
This commit is contained in:
Lachlan Kermode
2018-12-07 12:32:32 +00:00
parent 565a36083f
commit 8a5bce0842
10 changed files with 45 additions and 39 deletions

View File

@@ -9,7 +9,7 @@ import { defaultBlueprint, defaultRoute } from '../lib/blueprinters'
* @return {type} Blueprint
* generated.
*/
export default function byColumn (tabName, sheetName, sheetId, data) {
function byColumn (tabName, sheetName, sheetId, data) {
// Define Blueprint props
const bp = R.clone(defaultBlueprint)
bp.sheet = {
@@ -18,18 +18,22 @@ export default function byColumn (tabName, sheetName, sheetId, data) {
}
bp.name = tabName
// column names define routes
// column names define resources
const labels = data[0]
labels.forEach(label => {
bp.routes[label] = R.clone(defaultRoute)
bp.resources[label] = R.clone(defaultRoute)
})
// remaining rows as data
data.forEach((row, idx) => {
if (idx === 0) return
labels.forEach((label, idx) => {
bp.routes[label].data.push(row[idx])
bp.resources[label].data.push(row[idx])
})
})
return bp
}
byColumn.resourceName = 'columns'
export default byColumn

View File

@@ -28,11 +28,11 @@ export default function byGroup (
}
bp.name = tabName
// Column names define routes
// Column names define resources
const itemLabels = data[0]
const fmt = fmtObj(itemLabels)
bp.routes[label] = R.clone(defaultRoute)
bp.routes[label].data = []
bp.resources[label] = R.clone(defaultRoute)
bp.resources[label].data = []
const dataGroups = {}
@@ -46,7 +46,7 @@ export default function byGroup (
}
})
Object.keys(dataGroups).forEach(groupKey => {
bp.routes[label].data.push({
bp.resources[label].data.push({
group: groupKey,
group_label: dataGroups[groupKey][0].group_label,
data: dataGroups[groupKey]

View File

@@ -28,15 +28,15 @@ export default function byId (
}
bp.name = tabName
// Column names define routes
// Column names define resources
const itemLabels = data[0]
const fmt = fmtObj(itemLabels)
bp.routes[label] = R.clone(defaultRoute)
bp.routes[label].data = []
bp.resources[label] = R.clone(defaultRoute)
bp.resources[label].data = []
data.forEach((row, idx) => {
if (idx === 0) return
bp.routes[label].data[fmt(row).id] = fmt(row)
bp.resources[label].data[fmt(row).id] = fmt(row)
})
return bp
}

View File

@@ -27,15 +27,15 @@ export default function byRow (
}
bp.name = tabName
// Column names define routes
// Column names define resources
const itemLabels = data[0]
const fmt = fmtObj(itemLabels)
bp.routes[label] = R.clone(defaultRoute)
bp.routes[label].data = []
bp.resources[label] = R.clone(defaultRoute)
bp.resources[label].data = []
data.forEach((row, idx) => {
if (idx === 0) return
bp.routes[label].data.push(fmt(row))
bp.resources[label].data.push(fmt(row))
})
return bp
}

View File

@@ -27,9 +27,9 @@ export default function byTree (
}
bp.name = tabName
// Column names define routes
bp.routes[label] = R.clone(defaultRoute)
bp.routes[label].data = {}
// Column names define resources
bp.resources[label] = R.clone(defaultRoute)
bp.resources[label].data = {}
const tree = {
key: 'tags',
@@ -62,6 +62,6 @@ export default function byTree (
}
})
bp.routes[label].data = tree
bp.resources[label].data = tree
return bp
}