Sitemap code generation: Quote colors (#1887)
The sitemap syntax requires colors in icon, label and valuecolors to be strings and have quotes around the values. This is currently not respected, therefore the generated code could not be used without correction when copied into a sitemap file. This fixes that bug. Signed-off-by: Mark Herwege <mark.herwege@telenet.be>pull/1892/head
parent
3d8348aca9
commit
54ed5fee15
|
@ -162,7 +162,7 @@ describe('dslUtil', () => {
|
|||
]
|
||||
})
|
||||
const sitemap = dslUtil.toDsl(component).split('\n')
|
||||
expect(sitemap[1]).toEqual(' Text item=Temperature valuecolor=[Last_Update==Uninitialized=gray,>=25=orange,==15=green,0=white,blue]')
|
||||
expect(sitemap[1]).toEqual(' Text item=Temperature valuecolor=[Last_Update==Uninitialized="gray",>=25="orange",==15="green",0="white","blue"]')
|
||||
})
|
||||
|
||||
it('renders widget with valuecolor and text condition correctly', () => {
|
||||
|
@ -176,6 +176,6 @@ describe('dslUtil', () => {
|
|||
]
|
||||
})
|
||||
const sitemap = dslUtil.toDsl(component).split('\n')
|
||||
expect(sitemap[1]).toEqual(' Text item=Temperature valuecolor=[Heat_Warning=="It is hot"=gray]')
|
||||
expect(sitemap[1]).toEqual(' Text item=Temperature valuecolor=[Heat_Warning=="It is hot"="gray"]')
|
||||
})
|
||||
})
|
||||
|
|
|
@ -42,7 +42,7 @@ function writeWidget (widget, indent) {
|
|||
dsl += widget.config[key].filter(Boolean).map(color => {
|
||||
let index = color.lastIndexOf('=') + 1
|
||||
let colorvalue = color.substring(index)
|
||||
if (/^[^"'].*\W.*[^"']$/.test(colorvalue)) {
|
||||
if (!/^(".*")|('.*')$/.test(colorvalue)) {
|
||||
colorvalue = '"' + colorvalue + '"'
|
||||
}
|
||||
colorvalue = (index > 0 ? '=' + colorvalue : colorvalue)
|
||||
|
|
Loading…
Reference in New Issue