EditElementExists.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div>
  3. <ui-select
  4. :model-value="data.findBy || 'cssSelector'"
  5. :placeholder="t('workflow.blocks.base.findElement.placeholder')"
  6. class="w-full mb-1"
  7. @change="updateData({ findBy: $event })"
  8. >
  9. <option v-for="type in selectorTypes" :key="type" :value="type">
  10. {{ t(`workflow.blocks.base.findElement.options.${type}`) }}
  11. </option>
  12. </ui-select>
  13. <ui-autocomplete
  14. :items="autocomplete"
  15. :trigger-char="['{{', '}}']"
  16. block
  17. hide-empty
  18. class="mb-1"
  19. >
  20. <ui-input
  21. :model-value="data.selector"
  22. :label="t('workflow.blocks.element-exists.selector')"
  23. autocomplete="off"
  24. placeholder=".element"
  25. class="w-full"
  26. @change="updateData({ selector: $event })"
  27. />
  28. </ui-autocomplete>
  29. <ui-input
  30. :model-value="data.tryCount"
  31. :title="t('workflow.blocks.element-exists.tryFor.title')"
  32. :label="t('workflow.blocks.element-exists.tryFor.label')"
  33. class="w-full mb-1"
  34. type="number"
  35. min="1"
  36. @change="updateData({ tryCount: +$event })"
  37. />
  38. <ui-input
  39. :model-value="data.timeout"
  40. :label="t('workflow.blocks.element-exists.timeout.label')"
  41. :title="t('workflow.blocks.element-exists.timeout.title')"
  42. class="w-full"
  43. type="number"
  44. min="200"
  45. @change="updateData({ timeout: +$event })"
  46. />
  47. <label class="flex items-center mt-4">
  48. <ui-switch
  49. :model-value="data.throwError"
  50. class="mr-2"
  51. @change="updateData({ throwError: $event })"
  52. />
  53. <span>{{ t('workflow.blocks.element-exists.throwError') }}</span>
  54. </label>
  55. </div>
  56. </template>
  57. <script setup>
  58. import { onMounted } from 'vue';
  59. import { useI18n } from 'vue-i18n';
  60. const props = defineProps({
  61. data: {
  62. type: Object,
  63. default: () => ({}),
  64. },
  65. autocomplete: {
  66. type: Array,
  67. default: () => [],
  68. },
  69. });
  70. const emit = defineEmits(['update:data']);
  71. const { t } = useI18n();
  72. const selectorTypes = ['cssSelector', 'xpath'];
  73. function updateData(value) {
  74. emit('update:data', { ...props.data, ...value });
  75. }
  76. onMounted(() => {
  77. if (!props.data.findBy) {
  78. updateData({ findBy: 'cssSelector' });
  79. }
  80. });
  81. </script>