Skip to content

Commit

Permalink
feat: add clear form value option
Browse files Browse the repository at this point in the history
  • Loading branch information
Kholid060 committed Nov 12, 2021
1 parent 722e7c2 commit 9e7b4fd
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 48 deletions.
1 change: 1 addition & 0 deletions src/assets/css/drawflow.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
width: 100%;
height: 100%;
user-select: none;
perspective: 0;
}

.drawflow .drawflow-node {
Expand Down
2 changes: 1 addition & 1 deletion src/components/newtab/app/AppSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const tabs = [
path: '/',
},
{
name: 'Worfklows',
name: 'Workflows',
icon: 'riFlowChart',
path: '/workflows',
},
Expand Down
12 changes: 6 additions & 6 deletions src/components/newtab/workflow/edit/EditForms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
>
Selected
</ui-checkbox>
<ui-textarea
v-if="state.type === 'text-field' || state.type === 'select'"
v-model="state.value"
placeholder="Value"
class="w-full"
/>
<template v-if="state.type === 'text-field' || state.type === 'select'">
<ui-textarea v-model="state.value" placeholder="Value" class="w-full" />
<ui-checkbox v-model="state.clearValue" class="mb-1 ml-1">
Clear form value
</ui-checkbox>
</template>
<ui-input
v-if="state.type === 'text-field'"
v-model="state.delay"
Expand Down
68 changes: 35 additions & 33 deletions src/components/newtab/workflow/edit/EditInteractionBase.vue
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
<template>
<slot name="prepend" />
<ui-textarea
:model-value="data.description"
autoresize
placeholder="Description"
class="w-full mb-2"
@change="updateData({ description: $event })"
/>
<ui-input
v-if="!hideSelector"
:model-value="data.selector"
placeholder="Element selector"
class="mb-1 w-full"
@change="updateData({ selector: $event })"
/>
<template v-if="!hideSelector">
<ui-checkbox
v-if="!data.disableMultiple && !hideMultiple"
class="mr-6"
:model-value="data.multiple"
@change="updateData({ multiple: $event })"
>
Multiple
</ui-checkbox>
<ui-checkbox
:model-value="data.markEl"
title="An element will not be selected after marked"
@change="updateData({ markEl: $event })"
>
Mark element
</ui-checkbox>
</template>
<slot></slot>
<div>
<slot name="prepend" />
<ui-textarea
:model-value="data.description"
autoresize
placeholder="Description"
class="w-full mb-2"
@change="updateData({ description: $event })"
/>
<ui-input
v-if="!hideSelector"
:model-value="data.selector"
placeholder="Element selector"
class="mb-1 w-full"
@change="updateData({ selector: $event })"
/>
<template v-if="!hideSelector">
<ui-checkbox
v-if="!data.disableMultiple && !hideMultiple"
class="mr-6"
:model-value="data.multiple"
@change="updateData({ multiple: $event })"
>
Multiple
</ui-checkbox>
<ui-checkbox
:model-value="data.markEl"
title="An element will not be selected if have been selected before"
@change="updateData({ markEl: $event })"
>
Mark element
</ui-checkbox>
</template>
<slot></slot>
</div>
</template>
<script setup>
const props = defineProps({
Expand Down
6 changes: 1 addition & 5 deletions src/content/blocks-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,6 @@ export function forms(block) {
const { data } = block;
const elements = handleElement(block, true);

if (block.data.value.trim().length === 0) {
resolve('');
return;
}

if (data.multiple) {
const promises = Array.from(elements).map((element) => {
return new Promise((eventResolve) => {
Expand All @@ -179,6 +174,7 @@ export function forms(block) {
if (isElementUnique(elements, block))
handleFormElement(elements, data, resolve);
} else {
alert('else?');
resolve('');
}
});
Expand Down
4 changes: 3 additions & 1 deletion src/utils/handle-form-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function inputText({ data, element, index = 0, callback }) {
const currentChar = data.value[index];

if (noDelay) {
element.value = data.value;
element.value += data.value;
} else {
element.value += currentChar;
}
Expand All @@ -58,6 +58,8 @@ export default function (element, data, callback) {
const textFields = ['INPUT', 'TEXTAREA'];

if (data.type === 'text-field' && textFields.includes(element.tagName)) {
if (data.clearValue) element.value = '';

inputText({ data, element, callback });
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/helper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function replaceMustache(str, replacer) {
/* eslint-disable-next-line */
return str.replace(/{{\s*[\w\.@]+\s*}}/g, replacer);
return str.replace(/{{(.*)}}/g, replacer);
}

export function openFilePicker(acceptedFileTypes = [], attrs = {}) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ export const tasks = {
markEl: false,
multiple: false,
selected: true,
clearValue: true,
type: 'text-field',
value: '',
delay: 0,
Expand Down Expand Up @@ -397,7 +398,6 @@ export const tasks = {
allowedInputs: true,
maxConnection: 1,
data: {
name: '',
loopId: '',
maxLoop: 0,
loopData: '[]',
Expand Down

0 comments on commit 9e7b4fd

Please sign in to comment.