Sitemap editor: Fix issues with AND, buttongrid and numeric commands (#2609)

Fixes https://github.com/openhab/openhab-webui/issues/2605
Also fixes issue with Buttongrid and non-numeric commands

---------

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
pull/2610/head
Mark Herwege 2024-06-13 16:01:19 +02:00 committed by GitHub
parent eb0a24720d
commit e80b221940
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 7 deletions

View File

@ -162,15 +162,15 @@ Mapping -> Command _ %colon _ Command _ %equals _ Label
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] %}
| Command _ %equals _ Label _ %equals _ WidgetIconAttrValue {% (d) => d[0][0].value + '=' + d[4] + '=' + d[8].join("") %}
ButtonValue -> Command _ %equals _ Label {% (d) => d[0] + '=' + d[4] %}
| Command _ %equals _ Label _ %equals _ WidgetIconAttrValue {% (d) => d[0] + '=' + d[4] + '=' + d[8].join("") %}
Command -> %number | %identifier {% (d) => d[0].value %}
| %string {% (d) => '"' + d[0].value + '"' %}
Label -> %number | %identifier {% (d) => d[0].value %}
| %string {% (d) => '"' + d[0].value + '"' %}
Visibilities -> Conditions {% (d) => d[0] %}
Visibilities -> Conditions {% (d) => [d[0]] %}
| Visibilities _ %comma _ Conditions {% (d) => d[0].concat(d[4]) %}
Colors -> Color {% (d) => [d[0]] %}
@ -184,7 +184,7 @@ IconRules -> IconRule
IconRule -> Conditions _ %equals _ WidgetIconAttrValue {% (d) => d[0] + '=' + d[4].join("") %}
| WidgetIconAttrValue {% (d) => d[0].join("") %}
Conditions -> Condition
Conditions -> Condition {% (d) => d[0] %}
| Conditions _ %and _ Condition {% (d) => d[0] + ' AND ' + d[4] %}
Condition -> ConditionCommand _ ConditionComparator _ ConditionValue {% (d) => d[0][0].value + d[2][0].value + d[4][0].value %}
| ConditionComparator _ ConditionValue {% (d) => d[0][0].value + d[2][0].value %}

View File

@ -3,7 +3,7 @@
<f7-card-content v-if="attributes.length">
<f7-list inline-labels sortable sortable-opposite sortable-enabled @sortable:sort="onSort">
<f7-list-item v-for="(attr, idx) in attributes" :key="attr.key">
<f7-input v-if="!fields" inputStyle="width: 100%" type="text" :placeholder="placeholder" :value="attr.value" @change="updateAttribute($event, idx, attr)" />
<f7-input v-if="!fields" style="flex: 1" inputStyle="width: 100%" type="text" :placeholder="placeholder" :value="attr.value" @change="updateAttribute($event, idx, attr)" />
<f7-input v-for="(field, fieldidx) in fieldDefs" :key="JSON.stringify(field)"
:style="fieldStyle(field, fieldidx)"
:inputStyle="inputFieldStyle(field, fieldidx)"
@ -13,7 +13,7 @@
:placeholder="fieldProp(field, 'placeholder')"
:value="attr.value[Object.keys(field)[0]]"
validate @change="updateAttribute($event, idx, attr, Object.keys(field)[0])" />
<f7-button style="padding-left: 5px; padding-right: 0" text="" icon-material="clear" small @click="removeAttribute(idx)" />
<f7-button style="padding-left: 5px; padding-right: 0; flex-shrink: 0" text="" icon-material="clear" small @click="removeAttribute(idx)" />
</f7-list-item>
</f7-list>
</f7-card-content>
@ -60,7 +60,11 @@ export default {
fieldStyle (field, fieldidx) {
let style = {}
if (this.fieldProp(field, 'width') !== undefined) {
style.width = this.fieldProp(field, 'width')
style.flexGrow = '0'
style.flexShrink = '0'
style.flexBasis = this.fieldProp(field, 'width')
} else {
style.flex = 1
}
if (fieldidx > 0) {
style.paddingLeft = '5px'