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

oh-repeater: Fix key property does not refresh repeater #1919

Merged
merged 1 commit into from
Jun 13, 2023
Merged
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 @@ -25,7 +25,7 @@ export default {
data () {
return {
ready: false,
source: null
loadedSource: null
}
},
created () {
Expand Down Expand Up @@ -75,18 +75,24 @@ export default {
}

return contexts
},
source () {
if (this.loadedSource !== null) return this.loadedSource
switch (this.config.sourceType) {
case 'range':
const start = this.config.rangeStart || 0
const stop = this.config.rangeStop || 10
const step = this.config.rangeStep || 1
return Array(Math.ceil((stop + 1 - start) / step)).fill(start).map((x, y) => x + y * step)
default:
return this.config.in
}
}
},
methods: {
load () {
if (this.loading) return
let loadPromise
if (this.config.sourceType === 'range') {
const start = this.config.rangeStart || 0
const stop = this.config.rangeStop || 10
const step = this.config.rangeStep || 1
loadPromise = Promise.resolve(Array(Math.ceil((stop + 1 - start) / step)).fill(start).map((x, y) => x + y * step))
} else if (this.config.sourceType === 'itemsWithTags' && this.config.itemTags) {
if (this.config.sourceType === 'itemsWithTags' && this.config.itemTags) {
loadPromise = this.$oh.api.get('/rest/items?metadata=' + this.config.fetchMetadata + '&tags=' + this.config.itemTags).then((d) => Promise.resolve(d.sort(compareItems)))
} else if (this.config.sourceType === 'itemsInGroup') {
loadPromise = this.$oh.api.get('/rest/items/' + this.config.groupItem + '?metadata=' + this.config.fetchMetadata + '&tags=' + this.config.itemTags).then((i) => Promise.resolve(i.members.sort(compareItems)))
Expand All @@ -97,10 +103,11 @@ export default {
} else if (this.config.sourceType === 'rulesWithTags' && this.config.ruleTags) {
loadPromise = this.$oh.api.get('/rest/rules?summary=true' + '&tags=' + this.config.ruleTags).then((r) => Promise.resolve(r.sort(compareRules)))
} else {
loadPromise = Promise.resolve(this.config.in)
this.ready = true
return
}
loadPromise.then((d) => {
this.source = d
this.loadedSource = d
this.ready = true
})
}
Expand Down