Skip to content

Commit

Permalink
Merge pull request #417 from alercebroker/fix/lightcurve_card_mounted
Browse files Browse the repository at this point in the history
fix: now it obtains oid from url params when store is empty
  • Loading branch information
pgallardor authored Dec 7, 2023
2 parents 08074de + fd60c6e commit a2d2c1a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions components/cardLightCurve.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export default class CardLightCurve extends Vue {
}
mounted() {
const _oid = this.objectId || this.$route.params.oid
this._loadHtmx(_oid)
this.$el.addEventListener('htmx:responseError', (event) => {
this.error = event.detail.error
this.isLoading = false
Expand All @@ -76,18 +78,23 @@ export default class CardLightCurve extends Vue {
})
}
_loadHtmx(objectId) {
const url = `${this.$config.ztfApiv2Url}/lightcurve/htmx/lightcurve?oid=${objectId}`
const myDiv = document.getElementById('lightcurve-container')
if (myDiv) {
myDiv.innerHTML = `<div hx-get=${url} hx-trigger="updateLightcurve from:body" hx-swap="outerHTML"></div>`
htmx.process(myDiv)
document.body.dispatchEvent(new Event('updateLightcurve'))
}
}
@Watch('objectId', { immediate: true })
onIdChange(newId) {
console.log('Watching oid', newId)
this.error = ''
this.isLoading = true
if (newId) {
const url = `${this.$config.ztfApiv2Url}/lightcurve/htmx/lightcurve?oid=${newId}`
const myDiv = document.getElementById('lightcurve-container')
if (myDiv) {
myDiv.innerHTML = `<div hx-get=${url} hx-trigger="updateLightcurve from:body" hx-swap="outerHTML"></div>`
htmx.process(myDiv)
document.body.dispatchEvent(new Event('updateLightcurve'))
}
this._loadHtmx(newId)
}
}
Expand Down

0 comments on commit a2d2c1a

Please sign in to comment.