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 88dac9fc64..f9f81e5332 100644
--- a/bundles/org.openhab.ui/web/src/assets/sitemap-lexer.nearley
+++ b/bundles/org.openhab.ui/web/src/assets/sitemap-lexer.nearley
@@ -9,15 +9,16 @@
item: 'item=',
staticIcon: 'staticIcon=',
icon: 'icon=',
- widgetattr: ['url=', 'refresh=', 'service=', 'period=', 'height=', 'minValue=', 'maxValue=', 'step=', 'encoding=', 'yAxisDecimalPattern=', 'inputHint='],
+ widgetattr: ['url=', 'refresh=', 'service=', 'period=', 'height=', 'minValue=', 'maxValue=', 'step=', 'encoding=', 'yAxisDecimalPattern=', 'inputHint=', 'columns='],
widgetboolattr: ['legend='],
widgetfreqattr: 'sendFrequency=',
widgetfrcitmattr: 'forceasitem=',
widgetmapattr: 'mappings=',
+ widgetbuttonattr: 'buttons=',
widgetvisiattr: 'visibility=',
widgetcolorattr: ['labelcolor=', 'valuecolor=', 'iconcolor='],
widgetswitchattr: 'switchSupport',
- nlwidget: ['Switch ', 'Selection ', 'Slider ', 'Setpoint ', 'Input ', 'Video ', 'Chart ', 'Webview ', 'Colorpicker ', 'Mapview ', 'Default '],
+ nlwidget: ['Switch ', 'Selection ', 'Slider ', 'Setpoint ', 'Input ', 'Video ', 'Chart ', 'Webview ', 'Colorpicker ', 'Mapview ', 'Buttongrid ', 'Default '],
lwidget: ['Text ', 'Group ', 'Image ', 'Frame '],
lparen: '(',
rparen: ')',
@@ -118,6 +119,7 @@ WidgetAttr -> %widgetswitchattr
| %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]] %}
+ | WidgetButtonsAttrName WidgetButtonsAttrValue {% (d) => [d[0][0].value, d[1]] %}
| WidgetVisibilityAttrName WidgetVisibilityAttrValue {% (d) => [d[0][0].value, d[1]] %}
| WidgetColorAttrName WidgetColorAttrValue {% (d) => [d[0][0].value, d[1]] %}
WidgetAttrName -> %item | %label | %widgetattr
@@ -135,6 +137,8 @@ WidgetAttrValue -> %number
| %string {% (d) => d[0].value %}
WidgetMappingsAttrName -> %widgetmapattr
WidgetMappingsAttrValue -> %lbracket _ Mappings _ %rbracket {% (d) => d[2] %}
+WidgetButtonsAttrName -> %widgetbuttonattr
+WidgetButtonsAttrValue -> %lbracket _ Buttons _ %rbracket {% (d) => d[2] %}
WidgetVisibilityAttrName -> %widgetvisiattr
WidgetVisibilityAttrValue -> %lbracket _ Visibilities _ %rbracket {% (d) => d[2] %}
WidgetColorAttrName -> %widgetcolorattr
@@ -142,10 +146,17 @@ WidgetColorAttrValue -> %lbracket _ Colors _ %rbracket
Mappings -> Mapping {% (d) => [d[0]] %}
| Mappings _ %comma _ Mapping {% (d) => d[0].concat([d[4]]) %}
-Mapping -> MappingCommand _ %equals _ MappingLabel {% (d) => d[0][0].value + '=' + d[4][0].value %}
- | MappingCommand _ %equals _ MappingLabel _ %equals _ WidgetIconAttrValue {% (d) => d[0][0].value + '=' + d[4][0].value + '=' + d[8].join("") %}
-MappingCommand -> %number | %identifier | %string
-MappingLabel -> %number | %identifier | %string
+Mapping -> Command _ %equals _ Label {% (d) => d[0][0].value + '=' + d[4][0].value %}
+ | Command _ %equals _ Label _ %equals _ WidgetIconAttrValue {% (d) => d[0][0].value + '=' + d[4][0].value + '=' + d[8].join("") %}
+
+Buttons -> Button {% (d) => [d[0]] %}
+ | Buttons _ %comma _ Button {% (d) => d[0].concat([d[4]]) %}
+Button -> %number _ %colon _ %number _ %colon _ ButtonValue {% (d) => { return { 'row': parseInt(d[0].value), 'column': parseInt(d[4].value), 'command': d[8] } } %}
+ButtonValue -> Command _ %equals _ Label {% (d) => d[0][0].value + '=' + d[4][0].value %}
+ | Command _ %equals _ Label _ %equals _ WidgetIconAttrValue {% (d) => d[0][0].value + '=' + d[4][0].value + '=' + d[8].join("") %}
+
+Command -> %number | %identifier | %string
+Label -> %number | %identifier | %string
Visibilities -> Conditions {% (d) => d[0] %}
| Visibilities _ %comma _ Conditions {% (d) => d[0].concat(d[4]) %}
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 096e7502d7..a1abd54205 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
@@ -120,7 +120,26 @@ describe('dslUtil', () => {
]
})
const sitemap = dslUtil.toDsl(component).split('\n')
- expect(sitemap[1]).toEqual(' Selection item=Scene_General mappings=[1=Morning,2=Evening,10="Cinéma",11=TV,3="Bed time",4=Night=moon]')
+ expect(sitemap[1]).toEqual(' Selection item=Scene_General mappings=[1=Morning, 2=Evening, 10="Cinéma", 11=TV, 3="Bed time", 4=Night=moon]')
+ })
+
+ it('renders a Buttongrid widget correctly', () => {
+ const component = createSitemapComponent('test', 'Test')
+ const widget = {
+ }
+ addWidget(component, 'Buttongrid', {
+ item: 'Scene_General',
+ buttons: [
+ { row: 1, column: 1, command: '1=Morning' },
+ { row: 1, column: 2, command: '2=Evening' },
+ { row: 1, column: 3, command: '10=Cinéma' },
+ { row: 2, column: 1, command: '11=TV' },
+ { row: 2, column: 2, command: '3=Bed time' },
+ { row: 2, column: 3, command: '4=Night=moon' }
+ ]
+ })
+ const sitemap = dslUtil.toDsl(component).split('\n')
+ expect(sitemap[1]).toEqual(' Buttongrid item=Scene_General buttons=[1:1:1=Morning, 1:2:2=Evening, 1:3:10="Cinéma", 2:1:11=TV, 2:2:3="Bed time", 2:3:4=Night=moon]')
})
it('renders a widget with mappings and string keys correctly', () => {
@@ -136,7 +155,7 @@ describe('dslUtil', () => {
]
})
const sitemap = dslUtil.toDsl(component).split('\n')
- expect(sitemap[1]).toEqual(' Selection item=Echos mappings=[EchoDot1="Echo 1",EchoDot2="Echo 2","EchoDot1,EchoDot2"=Alle]')
+ expect(sitemap[1]).toEqual(' Selection item=Echos mappings=[EchoDot1="Echo 1", EchoDot2="Echo 2", "EchoDot1,EchoDot2"=Alle]')
})
it('renders a widget with 0 value parameter correctly', () => {
@@ -166,7 +185,7 @@ describe('dslUtil', () => {
]
})
const sitemap = dslUtil.toDsl(component).split('\n')
- expect(sitemap[1]).toEqual(' Text item=Test visibility=[Battery<30,Battery>50,Battery_Level>=20]')
+ expect(sitemap[1]).toEqual(' Text item=Test visibility=[Battery<30, Battery>50, Battery_Level>=20]')
})
it('renders widget with visibility and text condition correctly', () => {
@@ -181,7 +200,7 @@ describe('dslUtil', () => {
]
})
const sitemap = dslUtil.toDsl(component).split('\n')
- expect(sitemap[1]).toEqual(' Switch item=Test visibility=[Day_Time=="Morning Time",Temperature>19]')
+ expect(sitemap[1]).toEqual(' Switch item=Test visibility=[Day_Time=="Morning Time", Temperature>19]')
})
it('renders widget with valuecolor correctly', () => {
@@ -199,7 +218,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', () => {
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 2cf8e1b844..14ec623e25 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
@@ -188,6 +188,47 @@ describe('SitemapCode', () => {
})
})
+ it('parses a Buttongrid component correctly', async () => {
+ expect(wrapper.vm.sitemapDsl).toBeDefined()
+ // simulate updating the sitemap in code
+ const sitemap = [
+ 'sitemap test label="Test" {',
+ ' Buttongrid item=Scene_General buttons=[1:1:1=Morning, 1:2:2="Evening", 1:3:10="Cinéma",',
+ ' 2:1:11=TV, 2:2:3="Bed time", 2:3:4=Night=moon]',
+ '}',
+ ''
+ ].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(1)
+ expect(payload.slots.widgets[0]).toEqual({
+ component: 'Buttongrid',
+ config: {
+ item: 'Scene_General',
+ buttons: [
+ { row: 1, column: 1, command: '1=Morning' },
+ { row: 1, column: 2, command: '2=Evening' },
+ { row: 1, column: 3, command: '10=Cinéma' },
+ { row: 2, column: 1, command: '11=TV' },
+ { row: 2, column: 2, command: '3=Bed time' },
+ { row: 2, column: 3, command: '4=Night=moon' }
+ ]
+ }
+ })
+ })
+
it('parses a mapping code back to a mapping on a component', async () => {
expect(wrapper.vm.sitemapDsl).toBeDefined()
// simulate updating the sitemap in code
diff --git a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/attribute-details.vue b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/attribute-details.vue
index fb25f00512..4de9401ad5 100644
--- a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/attribute-details.vue
+++ b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/attribute-details.vue
@@ -2,8 +2,19 @@
-
+
+
+
+
+
@@ -14,25 +25,77 @@
+
+