|
@@ -45,7 +45,7 @@
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="buttons">
|
|
<div class="buttons">
|
|
|
- <button name="start" type="submit" :disabled="hasConfirmation && !confirmationChecked">
|
|
|
|
|
|
|
+ <button name="start" type="submit" :disabled="!formReady || (hasConfirmation && !confirmationChecked)">
|
|
|
Start
|
|
Start
|
|
|
</button>
|
|
</button>
|
|
|
<button name="cancel" type="button" @click="handleCancel">
|
|
<button name="cancel" type="button" @click="handleCancel">
|
|
@@ -58,7 +58,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { ref, onMounted, nextTick } from 'vue'
|
|
|
|
|
|
|
+import { ref, onMounted, onUnmounted, nextTick } from 'vue'
|
|
|
import { useRouter } from 'vue-router'
|
|
import { useRouter } from 'vue-router'
|
|
|
import { requestReconnectNow } from '../../../js/websocket.js'
|
|
import { requestReconnectNow } from '../../../js/websocket.js'
|
|
|
|
|
|
|
@@ -75,6 +75,7 @@ const hasConfirmation = ref(false)
|
|
|
const formErrors = ref({})
|
|
const formErrors = ref({})
|
|
|
const actionArguments = ref([])
|
|
const actionArguments = ref([])
|
|
|
const popupOnStart = ref('')
|
|
const popupOnStart = ref('')
|
|
|
|
|
+const formReady = ref(false)
|
|
|
|
|
|
|
|
// Computed properties
|
|
// Computed properties
|
|
|
|
|
|
|
@@ -87,23 +88,27 @@ const props = defineProps({
|
|
|
|
|
|
|
|
// Methods
|
|
// Methods
|
|
|
async function setup() {
|
|
async function setup() {
|
|
|
- const ret = await window.client.getActionBinding({
|
|
|
|
|
- bindingId: props.bindingId
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- const action = ret.action
|
|
|
|
|
-
|
|
|
|
|
- title.value = action.title
|
|
|
|
|
- icon.value = action.icon
|
|
|
|
|
- popupOnStart.value = action.popupOnStart || ''
|
|
|
|
|
- actionArguments.value = action.arguments || []
|
|
|
|
|
- argValues.value = {}
|
|
|
|
|
- formErrors.value = {}
|
|
|
|
|
- confirmationChecked.value = false
|
|
|
|
|
- hasConfirmation.value = false
|
|
|
|
|
-
|
|
|
|
|
- // Initialize values from query params or defaults
|
|
|
|
|
- actionArguments.value.forEach(arg => {
|
|
|
|
|
|
|
+ formReady.value = false
|
|
|
|
|
+ document.body.removeAttribute('loaded-argument-form')
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ const ret = await window.client.getActionBinding({
|
|
|
|
|
+ bindingId: props.bindingId
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ const action = ret.action
|
|
|
|
|
+
|
|
|
|
|
+ title.value = action.title
|
|
|
|
|
+ icon.value = action.icon
|
|
|
|
|
+ popupOnStart.value = action.popupOnStart || ''
|
|
|
|
|
+ actionArguments.value = action.arguments || []
|
|
|
|
|
+ argValues.value = {}
|
|
|
|
|
+ formErrors.value = {}
|
|
|
|
|
+ confirmationChecked.value = false
|
|
|
|
|
+ hasConfirmation.value = false
|
|
|
|
|
+
|
|
|
|
|
+ // Initialize values from query params or defaults
|
|
|
|
|
+ actionArguments.value.forEach(arg => {
|
|
|
if (arg.type === 'confirmation') {
|
|
if (arg.type === 'confirmation') {
|
|
|
hasConfirmation.value = true
|
|
hasConfirmation.value = true
|
|
|
const paramValue = getQueryParamValue(arg.name)
|
|
const paramValue = getQueryParamValue(arg.name)
|
|
@@ -130,14 +135,20 @@ async function setup() {
|
|
|
argValues.value[arg.name] = paramValue !== null ? paramValue : arg.defaultValue || ''
|
|
argValues.value[arg.name] = paramValue !== null ? paramValue : arg.defaultValue || ''
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
- // Run initial validation on all fields after DOM is updated
|
|
|
|
|
- await nextTick()
|
|
|
|
|
- for (const arg of actionArguments.value) {
|
|
|
|
|
- if (arg.type && !arg.type.startsWith('regex:') && arg.type !== 'select' && arg.type !== '' && arg.type !== 'confirmation' && arg.type !== 'checkbox') {
|
|
|
|
|
- await validateArgument(arg, argValues.value[arg.name] || '')
|
|
|
|
|
|
|
+ // Run initial validation on all fields after DOM is updated
|
|
|
|
|
+ await nextTick()
|
|
|
|
|
+ for (const arg of actionArguments.value) {
|
|
|
|
|
+ if (arg.type && !arg.type.startsWith('regex:') && arg.type !== 'select' && arg.type !== '' && arg.type !== 'confirmation' && arg.type !== 'checkbox') {
|
|
|
|
|
+ await validateArgument(arg, argValues.value[arg.name] || '')
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ formReady.value = true
|
|
|
|
|
+ document.body.setAttribute('loaded-argument-form', props.bindingId)
|
|
|
|
|
+ } catch (err) {
|
|
|
|
|
+ console.error('Failed to load argument form:', err)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -394,6 +405,10 @@ async function startAction(actionArgs) {
|
|
|
async function handleSubmit(event) {
|
|
async function handleSubmit(event) {
|
|
|
event.preventDefault()
|
|
event.preventDefault()
|
|
|
|
|
|
|
|
|
|
+ if (!formReady.value) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (popupOnStart.value === 'history') {
|
|
if (popupOnStart.value === 'history') {
|
|
|
router.push(`/action/${props.bindingId}`)
|
|
router.push(`/action/${props.bindingId}`)
|
|
|
return
|
|
return
|
|
@@ -470,6 +485,10 @@ defineExpose({
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
setup()
|
|
setup()
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+onUnmounted(() => {
|
|
|
|
|
+ document.body.removeAttribute('loaded-argument-form')
|
|
|
|
|
+})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
<style scoped>
|