forked from platypush/platypush
[Extensions UI] Support for initializing an extension from URL.
This commit is contained in:
parent
137855b4fc
commit
922297bf58
1 changed files with 16 additions and 2 deletions
|
@ -93,19 +93,24 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onInput(input, setFilter = true) {
|
onInput(input, setFilter = true, setUrlArgs = true) {
|
||||||
if (setFilter) {
|
if (setFilter) {
|
||||||
this.filter = input
|
this.filter = input
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = input?.toLowerCase()?.trim()
|
const name = input?.toLowerCase()?.trim()
|
||||||
if (name?.length && name !== this.selectedExtension && this.extensions[name]) {
|
if (name?.length && this.extensions[name]) {
|
||||||
this.selectedExtension = name
|
this.selectedExtension = name
|
||||||
|
if (setUrlArgs)
|
||||||
|
this.setUrlArgs({extension: name})
|
||||||
|
|
||||||
const el = this.$el.querySelector(`.extensions-container .item[data-name="${name}"]`)
|
const el = this.$el.querySelector(`.extensions-container .item[data-name="${name}"]`)
|
||||||
if (el)
|
if (el)
|
||||||
el.scrollIntoView({behavior: 'smooth'})
|
el.scrollIntoView({behavior: 'smooth'})
|
||||||
} else {
|
} else {
|
||||||
this.selectedExtension = null
|
this.selectedExtension = null
|
||||||
|
if (setUrlArgs)
|
||||||
|
this.setUrlArgs({})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -129,11 +134,20 @@ export default {
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.loadExtensionFromUrl()
|
||||||
|
this.$watch('$route.hash', () => this.loadExtensionFromUrl())
|
||||||
},
|
},
|
||||||
|
|
||||||
async loadConfigFile() {
|
async loadConfigFile() {
|
||||||
this.configFile = await this.request('config.get_config_file')
|
this.configFile = await this.request('config.get_config_file')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
loadExtensionFromUrl() {
|
||||||
|
const extension = this.getUrlArgs().extension
|
||||||
|
if (extension)
|
||||||
|
this.$nextTick(() => this.onInput(extension, false, false))
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
Loading…
Reference in a new issue