cat editor: add 'add product' dialog

This commit is contained in:
Seth Ladygo
2019-05-17 02:20:20 -07:00
parent d1aca308ba
commit ebd003683e
4 changed files with 251 additions and 13 deletions

View File

@ -43,3 +43,36 @@ export function sectionModels(section) {
return models
}
export function sectionTitle(material) {
// "Trailhead (Men)"
if (material) {
return `${material.category} (${material.gender})`
} else {
return '(unknown)'
}
}
// add properties from the material to the model,
// creating it if necessary.
export function extendModelFromMaterial(material, model = {}) {
if (material) {
if (!model['name']) {
// don't overwrite possibly overridden value
model['name'] = material.name
}
model['model'] = material.model
model['family'] = material.family
model['gender'] = material.gender
model['category'] = material.category
// make sure the material id is in the list
let ids = model['ids'] || []
if (!ids.includes(material.id)) {
ids.push(material.id)
model['ids'] = ids
}
}
return model
}