diff --git a/bundles/org.openhab.ui/web/src/assets/item-types.js b/bundles/org.openhab.ui/web/src/assets/item-types.js index 049533f2d..3c644b0df 100644 --- a/bundles/org.openhab.ui/web/src/assets/item-types.js +++ b/bundles/org.openhab.ui/web/src/assets/item-types.js @@ -3,10 +3,12 @@ const SharedTypes = ['Call', 'Color', 'Contact', 'DateTime', 'Dimmer', 'Image', export const ItemTypes = SharedTypes.concat(['Group']) export const GroupTypes = ['None'].concat(SharedTypes) -export const ArithmeticFunctions = [{ +export const CommonFunctions = [{ name: '', value: 'None' -}, { +}] + +export const ArithmeticFunctions = [{ name: 'AVG', value: 'AVG' }, { @@ -18,12 +20,12 @@ export const ArithmeticFunctions = [{ }, { name: 'SUM', value: 'SUM' +}, { + name: 'COUNT', + value: 'COUNT' }] export const LogicalOnOffFunctions = [{ - name: '', - value: 'None' -}, { name: 'AND_ON_OFF', value: 'All ON then ON else OFF' }, { @@ -50,9 +52,6 @@ export const LogicalOnOffFunctions = [{ }] export const LogicalOpenClosedFunctions = [{ - name: '', - value: 'None' -}, { name: 'AND_OPEN_CLOSED', value: 'All OPEN then OPEN else CLOSED' }, { @@ -79,9 +78,6 @@ export const LogicalOpenClosedFunctions = [{ }] export const LogicalPlayPauseFunctions = [{ - name: '', - value: 'None' -}, { name: 'AND_PLAY_PAUSE', value: 'All PLAY then PLAY else PAUSE' }, { @@ -96,9 +92,6 @@ export const LogicalPlayPauseFunctions = [{ }] export const DateTimeFunctions = [{ - name: '', - value: 'None' -}, { name: 'EARLIEST', value: 'EARLIEST' }, { diff --git a/bundles/org.openhab.ui/web/src/components/item/group-form.vue b/bundles/org.openhab.ui/web/src/components/item/group-form.vue index 75da05261..119cfe74f 100644 --- a/bundles/org.openhab.ui/web/src/components/item/group-form.vue +++ b/bundles/org.openhab.ui/web/src/components/item/group-form.vue @@ -18,19 +18,15 @@ - - + + :value="stateDescriptionPattern" @input="stateDescriptionPattern = $event.target.value" :clear-button:="editable" /> + + @@ -129,7 +130,7 @@ export default { }, groupFunctionKey: { get () { - return this.item.functionKey + return this.item.functionKey.startsWith('COUNT') ? 'COUNT' : this.item.functionKey }, set (newFunctionKey) { if (!newFunctionKey) { @@ -148,22 +149,35 @@ export default { this.$set(this.item, 'function', func) } }, - aggregationFunctions () { - switch (this.groupType) { - case 'Dimmer': - case 'Rollershutter': - case 'Number': - return types.ArithmeticFunctions - case 'Contact': - return types.LogicalOpenClosedFunctions - case 'Player': - return types.LogicalPlayPauseFunctions - case 'DateTime': - return types.DateTimeFunctions - case 'Switch': - return types.LogicalOnOffFunctions + groupFunctionParam: { + get () { + return this.item.function?.params?.length ? this.item.function.params[0] : null + }, + set (newFunctionParam) { + this.$set(this.item.function, 'params', [newFunctionParam]) } - return null + }, + aggregationFunctions () { + if (this.groupType === 'None') return null + + const specificAggregationFunctions = (groupType) => { + switch (this.groupType) { + case 'Dimmer': + case 'Rollershutter': + case 'Number': + return types.ArithmeticFunctions + case 'Contact': + return types.LogicalOpenClosedFunctions + case 'Player': + return types.LogicalPlayPauseFunctions + case 'DateTime': + return types.DateTimeFunctions + case 'Switch': + return types.LogicalOnOffFunctions + } + return [] + } + return [...types.CommonFunctions, ...specificAggregationFunctions(this.groupType)] } }, beforeMount () {