cat editor: add 'add product' dialog
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user