|
@@ -24,10 +24,19 @@
|
|
<ui-button
|
|
<ui-button
|
|
v-tooltip.group="t('workflow.blocks.base.element.select')"
|
|
v-tooltip.group="t('workflow.blocks.base.element.select')"
|
|
icon
|
|
icon
|
|
|
|
+ class="mr-2"
|
|
@click="selectElement"
|
|
@click="selectElement"
|
|
>
|
|
>
|
|
<v-remixicon name="riFocus3Line" />
|
|
<v-remixicon name="riFocus3Line" />
|
|
</ui-button>
|
|
</ui-button>
|
|
|
|
+ <ui-button
|
|
|
|
+ v-tooltip.group="t('workflow.blocks.base.element.verify')"
|
|
|
|
+ :disabled="!data.selector"
|
|
|
|
+ icon
|
|
|
|
+ @click="verifySelector"
|
|
|
|
+ >
|
|
|
|
+ <v-remixicon name="riCheckDoubleLine" />
|
|
|
|
+ </ui-button>
|
|
</div>
|
|
</div>
|
|
<edit-autocomplete v-if="!hideSelector" class="mb-1">
|
|
<edit-autocomplete v-if="!hideSelector" class="mb-1">
|
|
<ui-input
|
|
<ui-input
|
|
@@ -96,6 +105,7 @@
|
|
<script setup>
|
|
<script setup>
|
|
import { onMounted } from 'vue';
|
|
import { onMounted } from 'vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
+import { useToast } from 'vue-toastification';
|
|
import elementSelector from '@/newtab/utils/elementSelector';
|
|
import elementSelector from '@/newtab/utils/elementSelector';
|
|
import EditAutocomplete from './EditAutocomplete.vue';
|
|
import EditAutocomplete from './EditAutocomplete.vue';
|
|
|
|
|
|
@@ -125,6 +135,7 @@ const props = defineProps({
|
|
const emit = defineEmits(['update:data', 'change']);
|
|
const emit = defineEmits(['update:data', 'change']);
|
|
|
|
|
|
const { t } = useI18n();
|
|
const { t } = useI18n();
|
|
|
|
+const toast = useToast();
|
|
|
|
|
|
const selectorTypes = ['cssSelector', 'xpath'];
|
|
const selectorTypes = ['cssSelector', 'xpath'];
|
|
|
|
|
|
@@ -135,11 +146,20 @@ function updateData(value) {
|
|
emit('change', payload);
|
|
emit('change', payload);
|
|
}
|
|
}
|
|
function selectElement() {
|
|
function selectElement() {
|
|
- /* eslint-disable-next-line */
|
|
|
|
elementSelector.selectElement().then((selector) => {
|
|
elementSelector.selectElement().then((selector) => {
|
|
updateData({ selector });
|
|
updateData({ selector });
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+function verifySelector() {
|
|
|
|
+ const { selector, multiple, findBy } = props.data;
|
|
|
|
+ elementSelector
|
|
|
|
+ .verifySelector({ selector, multiple, findBy })
|
|
|
|
+ .then((result) => {
|
|
|
|
+ if (!result.notFound) return;
|
|
|
|
+
|
|
|
|
+ toast.error('Element not found');
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
if (!props.data.findBy) {
|
|
if (!props.data.findBy) {
|