parseCommon: resolve icon references

This commit is contained in:
Jannis R 2019-08-23 16:02:34 +02:00
parent 3eae7ab169
commit 0cc17ee780
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
3 changed files with 8 additions and 8 deletions

View file

@ -24,7 +24,10 @@ const parseCommonData = (profile, opt, res) => {
}
res.icons = []
if (Array.isArray(c.icoL)) res.icons = c.icoL.map(parseIcon)
if (Array.isArray(c.icoL)) {
res.icons = c.icoL.map(parseIcon)
resolveIdxRefs(res, '**.icoX', res.icons, 'icon')
}
res.lines = []
if (Array.isArray(c.prodL)) {

View file

@ -12,12 +12,11 @@ const codesByIcon = Object.assign(Object.create(null), {
// "tagL": [
// "RES_JNY_DTL" // only shown in journey detail
// ]
const parseHint = (profile, h, data) => {
const icons = data.icoL || []
const parseHint = (profile, h, _) => {
// todo: C
const text = h.txtN && h.txtN.trim() || ''
const icon = 'number' === typeof h.icoX && icons[h.icoX] || null
const icon = h.icon || null
const code = h.code || (icon && icon.type && codesByIcon[icon.type]) || null
if (h.type === 'M') {

View file

@ -11,8 +11,7 @@ const typesByIcon = Object.assign(Object.create(null), {
const parseMsgEdge = (profile, data) => (e) => {
const res = omit(e, ['icoX', 'fLocX', 'tLocX'])
const icons = data.icoL || []
res.icon = 'number' === typeof e.icoX && icons[e.icoX] || null
res.icon = e.icon || null
res.fromLoc = 'number' === typeof e.fLocX && data.locations[e.fLocX] || null
res.toLoc = 'number' === typeof e.tLocX && data.locations[e.tLocX] || null
return res
@ -28,7 +27,6 @@ const parseMsgEvent = (profile, data) => (e) => {
}
const parseWarning = (profile, w, data) => {
const icons = data.icoL || []
// todo: act, pub, lead, tckr, prod, comp,
// todo: cat (1, 2), pubChL, rRefL, impactL
// pubChL:
@ -48,7 +46,7 @@ const parseWarning = (profile, w, data) => {
// tDate: '20190225',
// tTime: '120000' }
const icon = 'number' === typeof w.icoX && icons[w.icoX] || null
const icon = w.icon || null
const type = icon && icon.type && typesByIcon[icon.type] || 'warning'
const res = {