diff --git a/bundles/org.openhab.ui/web/src/assets/sitemap-lexer.nearley b/bundles/org.openhab.ui/web/src/assets/sitemap-lexer.nearley
index 096933660c..405595839f 100644
--- a/bundles/org.openhab.ui/web/src/assets/sitemap-lexer.nearley
+++ b/bundles/org.openhab.ui/web/src/assets/sitemap-lexer.nearley
@@ -7,6 +7,7 @@
name: 'name=',
label: 'label=',
item: 'item=',
+ staticIcon: 'staticIcon=',
icon: 'icon=',
widgetattr: ['url=', 'refresh=', 'service=', 'period=', 'height=', 'minValue=', 'maxValue=', 'step=', 'encoding=', 'yAxisDecimalPattern=', 'inputHint='],
widgetboolattr: ['legend='],
@@ -71,6 +72,15 @@
}
}
+ // if icon exists remove staticIcon, if not set icon to staticIcon and make saticIcon=true
+ if (widget.config.icon) {
+ delete widget.config.staticIcon
+ }
+ if (widget.config.staticIcon) {
+ widget.config.icon = widget.config.staticIcon
+ widget.config.staticIcon = true
+ }
+
// reject widgets with missing parameters
if (requiresItem.includes(widget.component) && !widget.config.item) return reject
if ((widget.component === 'Video' || widget.component === 'Webview') && !widget.config.url) return reject
@@ -103,6 +113,7 @@ WidgetAttr -> %widgetswitchattr
| %widgetboolattr _ WidgetBooleanAttrValue {% (d) => [d[0].value, d[2]] %}
| %widgetfreqattr _ WidgetAttrValue {% (d) => ['frequency', d[2]] %}
| %icon _ WidgetIconAttrValue {% (d) => [d[0].value, d[2].join("")] %}
+ | %staticIcon_ WidgetIconAttrValue {% (d) => [d[0].value, d[2].join("")] %}
| WidgetAttrName _ WidgetAttrValue {% (d) => [d[0][0].value, d[2]] %}
| WidgetMappingsAttrName WidgetMappingsAttrValue {% (d) => [d[0][0].value, d[1]] %}
| WidgetVisibilityAttrName WidgetVisibilityAttrValue {% (d) => [d[0][0].value, d[1]] %}
diff --git a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/__tests__/dslUtil_jest.spec.js b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/__tests__/dslUtil_jest.spec.js
index 669e50bedd..3b64deeb82 100644
--- a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/__tests__/dslUtil_jest.spec.js
+++ b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/__tests__/dslUtil_jest.spec.js
@@ -50,6 +50,43 @@ describe('dslUtil', () => {
])
})
+ it('renders a widget with icon correctly', () => {
+ const component = createSitemapComponent('test', 'Test')
+ const widget = {
+ }
+ addWidget(component, 'Switch', {
+ item: 'TestItem',
+ label: 'Test Switch',
+ icon: 'lightbulb'
+ })
+ const sitemap = dslUtil.toDsl(component).split('\n')
+ expect(sitemap).toEqual([
+ 'sitemap test label="Test" {',
+ ' Switch item=TestItem label="Test Switch" icon=lightbulb',
+ '}',
+ ''
+ ])
+ })
+
+ it('renders a widget with static icon correctly', () => {
+ const component = createSitemapComponent('test', 'Test')
+ const widget = {
+ }
+ addWidget(component, 'Switch', {
+ item: 'TestItem',
+ label: 'Test Switch',
+ icon: 'lightbulb',
+ staticIcon: true
+ })
+ const sitemap = dslUtil.toDsl(component).split('\n')
+ expect(sitemap).toEqual([
+ 'sitemap test label="Test" {',
+ ' Switch item=TestItem label="Test Switch" staticIcon=lightbulb',
+ '}',
+ ''
+ ])
+ })
+
it('renders a sitemap with a frame container widget correctly', () => {
const component = createSitemapComponent('test', 'Test')
const frame = addWidget(component, 'Frame', {})
diff --git a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/__tests__/sitemap-code_jest.spec.js b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/__tests__/sitemap-code_jest.spec.js
index 0c69ae7040..e2ad0d6081 100644
--- a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/__tests__/sitemap-code_jest.spec.js
+++ b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/__tests__/sitemap-code_jest.spec.js
@@ -102,6 +102,56 @@ describe('SitemapCode', () => {
})
})
+ it('parses a staticIcon definition', async () => {
+ expect(wrapper.vm.sitemapDsl).toBeDefined()
+ // simulate updating the sitemap in code
+ const sitemap = [
+ 'sitemap test label="Test" {',
+ ' Switch item=Item_Icon icon=lightbulb',
+ ' Switch item=Item_Icon staticIcon=lightbulb_static',
+ ' Switch item=Item_Icon icon=lightbulb staticIcon=lightbulb_static',
+ '}',
+ ''
+ ].join('\n')
+ wrapper.vm.updateSitemap(sitemap)
+ expect(wrapper.vm.sitemapDsl).toMatch(/^sitemap test label="Test"/)
+ expect(wrapper.vm.parsedSitemap.error).toBeFalsy()
+
+ await wrapper.vm.$nextTick()
+
+ // check whether an 'updated' event was emitted and its payload
+ // (should contain the parsing result for the new sitemap definition)
+ const events = wrapper.emitted().updated
+ expect(events).toBeTruthy()
+ expect(events.length).toBe(1)
+ const payload = events[0][0]
+ expect(payload.slots).toBeDefined()
+ expect(payload.slots.widgets).toBeDefined()
+ expect(payload.slots.widgets.length).toBe(3)
+ expect(payload.slots.widgets[0]).toEqual({
+ component: 'Switch',
+ config: {
+ item: 'Item_Icon',
+ icon: 'lightbulb'
+ }
+ })
+ expect(payload.slots.widgets[1]).toEqual({
+ component: 'Switch',
+ config: {
+ item: 'Item_Icon',
+ icon: 'lightbulb_static',
+ staticIcon: true
+ }
+ })
+ expect(payload.slots.widgets[2]).toEqual({
+ component: 'Switch',
+ config: {
+ item: 'Item_Icon',
+ icon: 'lightbulb'
+ }
+ })
+ })
+
it('parses a segmented icon name with hyphens', async () => {
expect(wrapper.vm.sitemapDsl).toBeDefined()
// simulate updating the sitemap in code
diff --git a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/dslUtil.js b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/dslUtil.js
index 604cb3ba6e..fab8ce49a4 100644
--- a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/dslUtil.js
+++ b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/dslUtil.js
@@ -11,6 +11,12 @@ function writeWidget (widget, indent) {
dsl += ' sendFrequency=' + widget.config[key]
} else if (key === 'forceAsItem') {
dsl += ' forceasitem=' + widget.config[key]
+ } else if (['icon', 'staticIcon'].includes(key)) {
+ if (widget.config.staticIcon) {
+ dsl += ' staticIcon=' + widget.config[key]
+ } else {
+ dsl += ' icon=' + widget.config[key]
+ }
} else {
dsl += ` ${key}=`
if (key === 'item' || key === 'period' || key === 'legend' || Number.isFinite(widget.config[key])) {
diff --git a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue
index ee292fa9b8..134e831c23 100644
--- a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue
+++ b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue
@@ -13,6 +13,9 @@