Hi,
I’m trying to build a widget that shows different item lists depending on the button pressed.
I managed to get the basic functionality in place - now struggling with some final tweaks.
Animated GIF:
Issue #1:
It takes 2 clicks to show the first list - this should go with the first click
Issue #2:
Current behaviour:
Button 1 clicked → Item List 1 visible → Button 2 clicked → Item List 1 unvisible → Button 2 second click → Item List 2 visible
Wanted behaviour:
Button 1 clicked → Item List 1 visible → Button 2 clicked → Item List 1 unvisible AND Item List 2 visible
In general, the button shall always be filled when the corresponding item list is visible.
widget code:
uid: repeater_button_test
tags: []
props:
parameters: []
parameterGroups: []
timestamp: Jan 14, 2023, 6:38:05 PM
component: f7-card
config: {}
slots:
default:
- component: f7-segmented
slots:
default:
- component: oh-repeater
config:
for: buttons
fragment: true
in:
- button_number: 1
title: Button 1
- button_number: 2
title: Button 2
- button_number: 3
title: Button 3
- button_number: 4
title: Button 4
slots:
default:
- component: oh-button
config:
outline: true
action: variable
actionVariable: button
actionVariableValue: "=vars.button || vars.button === undefined ? false : (loop.buttons.button_number)"
fill: "=(vars.button == loop.buttons.button_number) ? true : false"
text: =loop.buttons.title
- component: f7-row
config: {}
slots:
default:
- component: oh-repeater
config:
for: groups
fragment: true
in:
- button_pressed: 1
group: gButton1
- button_pressed: 2
group: gButton2
- button_pressed: 3
group: gButton3
- button_pressed: 4
group: gButton4
slots:
default:
- component: f7-col
config:
width: "100"
slots:
default:
- component: f7-card-content
config:
visible: =vars.button == loop.groups.button_pressed
slots:
default:
- component: oh-list
config: {}
slots:
default:
- component: oh-repeater
config:
for: item
fragment: true
groupItem: =loop.groups.group
sourceType: itemsInGroup
slots:
default:
- component: oh-list-item
config:
item: =loop.item.name
title: =loop.item.label
Hope someone has a smart idea how to solve these issues.
Thanks in advance.
maxmaximax
edit 2023-01-15:
Now working as planned with the correction as suggested by @JustinG:
Updated code:
uid: repeater_button_test
tags: []
props:
parameters: []
parameterGroups: []
timestamp: Jan 14, 2023, 8:50:25 PM
component: f7-card
config: {}
slots:
default:
- component: f7-segmented
slots:
default:
- component: oh-repeater
config:
for: buttons
fragment: true
in:
- button_number: 1
title: Button 1
- button_number: 2
title: Button 2
- button_number: 3
title: Button 3
- button_number: 4
title: Button 4
slots:
default:
- component: oh-button
config:
outline: true
action: variable
actionVariable: button
actionVariableValue: "=(vars.button == loop.buttons.button_number) ? false : (loop.buttons.button_number)"
fill: "=(vars.button == loop.buttons.button_number) ? true : false"
text: =loop.buttons.title
- component: f7-row
config: {}
slots:
default:
- component: oh-repeater
config:
for: groups
fragment: true
in:
- button_pressed: 1
group: gButton1
- button_pressed: 2
group: gButton2
- button_pressed: 3
group: gButton3
- button_pressed: 4
group: gButton4
slots:
default:
- component: f7-col
config:
width: "100"
slots:
default:
- component: f7-card-content
config:
visible: =vars.button == loop.groups.button_pressed
slots:
default:
- component: oh-list
config: {}
slots:
default:
- component: oh-repeater
config:
for: item
fragment: true
groupItem: =loop.groups.group
sourceType: itemsInGroup
slots:
default:
- component: oh-list-item
config:
item: =loop.item.name
title: =loop.item.label