Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thing and triggerchannel pickers #2129

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,25 @@ export default {
searchbar: true,
searchbarPlaceholder: this.$t('dialogs.search.things'),
virtualList: true,
virtualListHeight: (this.$theme.aurora) ? 32 : undefined
virtualListHeight: (this.$theme.aurora) ? 32 : undefined,

renderItem: (item, index) => {
let after = (index > 0) ? this.things[index - 1].location
? this.things[index - 1].location + '<i class="icon f7-icons color-gray" style="width: 16px; height: 16px; font-size: 16px;">placemark</i>'
: '' : ''
return `
<li class="media-item">
<label class="item-${item.radio ? 'radio' : 'checkbox'} item-content">
<input type="${item.radio ? 'radio' : 'checkbox'}" name="${item.inputName}" value="${item.value}" ${item.selected ? 'checked' : ''}>
<i class="icon icon-${item.radio ? 'radio' : 'checkbox'}"></i>
<div class="item-inner">
<div class="text">${item.text}</div>
<div class="item-footer">${after}</div>
</div>
</label>
</li>
`
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,40 @@ export default {
view: this.$f7.view.main,
openIn: 'popup',
searchbar: true,
searchbarPlaceholder: 'Search channels'
searchbarPlaceholder: 'Search channels',
renderItem: (item, index) => {
let html, value, thing, channel, description
if (index > 0 && !item.isLabel) {
value = item.value.substring(0, item.value.lastIndexOf(':'))
thing = (index > 0) ? this.things.find((th) => th.UID === value) : ''
channel = (thing && thing.triggerChannels.length > 0)
? thing.triggerChannels.find((ch) => ch.uid === item.value) : undefined
}

if (item.isLabel) {
html = `
<li class="item-divider">
${item.groupLabel}
</li>
`
} else {
description = (channel !== undefined) ? channel.description : ''
html = `
<li class="media-item">
<label class="item-radio item-content">
<input type="radio" name="${item.inputName}" value="${item.value}" ${item.selected ? 'checked' : ''}>
<i class="icon icon-radio"></i>
<div class="item-inner">
<div class="text">${item.text}</div>
<div class="item-footer">${description}</div>
</div>
</label>
</li>
`
}

return html
}
}
}
},
Expand Down