mirror of
https://github.com/jpros/tacticalrmm-web.git
synced 2026-02-23 21:01:11 +00:00
fix filterable dropdown and prepopulating select value
This commit is contained in:
@@ -3,11 +3,11 @@ import { fetchScripts } from "@/api/scripts"
|
||||
import { formatScriptOptions } from "@/utils/format"
|
||||
|
||||
// script dropdown
|
||||
export function useScriptDropdown() {
|
||||
export function useScriptDropdown(setScript = null) {
|
||||
const scriptOptions = ref([])
|
||||
const defaultTimeout = ref(30)
|
||||
const defaultArgs = ref([])
|
||||
const script = ref(null)
|
||||
const script = ref(setScript)
|
||||
|
||||
// specifing flat returns an array of script names versus {value:id, label: hostname}
|
||||
async function getScriptOptions(showCommunityScripts = false, flat = false) {
|
||||
@@ -15,9 +15,9 @@ export function useScriptDropdown() {
|
||||
}
|
||||
|
||||
// watch scriptPk for changes and update the default timeout and args
|
||||
watch(script, (newValue, oldValue) => {
|
||||
if (newValue) {
|
||||
const tmpScript = scriptOptions.value.find(i => i.value === newValue);
|
||||
watch([script, scriptOptions], (newValue, oldValue) => {
|
||||
if (script.value && scriptOptions.value.length > 0) {
|
||||
const tmpScript = scriptOptions.value.find(i => i.value === script.value);
|
||||
defaultTimeout.value = tmpScript.timeout;
|
||||
defaultArgs.value = tmpScript.args;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ export function useScriptDropdown() {
|
||||
defaultArgs,
|
||||
|
||||
//methods
|
||||
getScriptOptions,
|
||||
getScriptOptions
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user