Skip to content

Commit

Permalink
v1.28.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Kholid060 committed Aug 23, 2023
2 parents cd3e144 + 3799e94 commit 4f28146
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "automa",
"version": "1.28.5",
"version": "1.28.6",
"description": "An extension for automating your browser by connecting blocks",
"repository": {
"type": "git",
Expand Down
23 changes: 22 additions & 1 deletion src/components/newtab/workflow/edit/EditAttributeValue.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
<template>
<edit-interaction-base v-bind="{ data }" @change="updateData">
<hr />
<edit-autocomplete>
<ui-select
:label="t('common.action')"
:model-value="data.action || 'get'"
class="mt-2 w-full"
@change="updateData({ action: $event })"
>
<option v-for="action in ['get', 'set']" :key="action" :value="action">
{{ t(`workflow.blocks.attribute-value.forms.action.${action}`) }}
</option>
</ui-select>
<edit-autocomplete class="mt-2">
<ui-input
:model-value="data.attributeName"
:label="t('workflow.blocks.attribute-value.forms.name')"
Expand All @@ -11,7 +21,18 @@
@change="updateData({ attributeName: $event })"
/>
</edit-autocomplete>
<edit-autocomplete v-if="data.action === 'set'" class="mt-2">
<ui-input
:model-value="data.attributeValue"
:label="t('workflow.blocks.attribute-value.forms.value')"
autocomplete="off"
placeholder="value"
class="w-full"
@change="updateData({ attributeValue: $event })"
/>
</edit-autocomplete>
<insert-workflow-data
v-else
:data="data"
extra-row
variables
Expand Down
11 changes: 8 additions & 3 deletions src/content/blocksHandler/handlerAttributeValue.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import handleSelector from '../handleSelector';

function attributeValue(block) {
function handleAttributeValue(block) {
return new Promise((resolve, reject) => {
let result = [];
const { attributeName, multiple } = block.data;
const { attributeName, multiple, attributeValue, action } = block.data;
const isCheckboxOrRadio = (element) => {
if (element.tagName !== 'INPUT') return false;

Expand All @@ -12,6 +12,11 @@ function attributeValue(block) {

handleSelector(block, {
onSelected(element) {
if (action === 'set') {
element.setAttribute(attributeName, attributeValue);
return;
}

let value = element.getAttribute(attributeName);

if (attributeName === 'checked' && isCheckboxOrRadio(element)) {
Expand All @@ -33,4 +38,4 @@ function attributeValue(block) {
});
}

export default attributeValue;
export default handleAttributeValue;
5 changes: 5 additions & 0 deletions src/locales/en/blocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,11 @@
"name": "Attribute name",
"checkbox": "Insert to table",
"column": "Select column",
"value": "Attribute value",
"action": {
"get": "Get attribute value",
"set": "Set attribute value"
},
"extraRow": {
"checkbox": "Add extra row",
"placeholder": "Value",
Expand Down
50 changes: 39 additions & 11 deletions src/utils/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export const tasks = {
outputs: 1,
maxConnection: 1,
allowedInputs: true,
refDataKeys: ['fileName', 'selector'],
refDataKeys: ['fileName', 'selector', 'variableName'],
autocomplete: ['variableName'],
data: {
description: '',
Expand Down Expand Up @@ -332,7 +332,13 @@ export const tasks = {
outputs: 1,
allowedInputs: true,
maxConnection: 1,
refDataKeys: ['selector', 'prefixText', 'suffixText', 'extraRowValue'],
refDataKeys: [
'selector',
'variableName',
'prefixText',
'suffixText',
'extraRowValue',
],
autocomplete: ['variableName'],
data: {
disableBlock: false,
Expand Down Expand Up @@ -368,7 +374,7 @@ export const tasks = {
outputs: 1,
allowedInputs: true,
maxConnection: 1,
refDataKeys: ['name'],
refDataKeys: ['name', 'variableName'],
data: {
disableBlock: false,
name: '',
Expand Down Expand Up @@ -445,7 +451,13 @@ export const tasks = {
outputs: 1,
allowedInputs: true,
maxConnection: 1,
refDataKeys: ['selector', 'attributeName', 'extraRowValue'],
refDataKeys: [
'selector',
'variableName',
'attributeName',
'extraRowValue',
'attributeValue',
],
autocomplete: ['variableName'],
data: {
disableBlock: false,
Expand All @@ -456,11 +468,13 @@ export const tasks = {
selector: '',
markEl: false,
multiple: false,
attributeValue: '',
attributeName: '',
assignVariable: false,
variableName: '',
dataColumn: '',
saveData: true,
action: 'get',
addExtraRow: false,
extraRowValue: '',
extraRowDataColumn: '',
Expand All @@ -477,7 +491,13 @@ export const tasks = {
outputs: 1,
allowedInputs: true,
maxConnection: 1,
refDataKeys: ['selector', 'value', 'optionPosition', 'delay'],
refDataKeys: [
'selector',
'variableName',
'value',
'optionPosition',
'delay',
],
autocomplete: ['variableName'],
data: {
disableBlock: false,
Expand Down Expand Up @@ -577,7 +597,7 @@ export const tasks = {
outputs: 1,
allowedInputs: true,
maxConnection: 1,
refDataKeys: ['customData', 'range', 'spreadsheetId'],
refDataKeys: ['customData', 'range', 'spreadsheetId', 'variableName'],
autocomplete: ['refKey'],
data: {
disableBlock: false,
Expand Down Expand Up @@ -609,7 +629,13 @@ export const tasks = {
outputs: 1,
allowedInputs: true,
maxConnection: 1,
refDataKeys: ['customData', 'range', 'spreadsheetId', 'sheetName'],
refDataKeys: [
'customData',
'range',
'spreadsheetId',
'sheetName',
'variableName',
],
autocomplete: ['refKey'],
data: {
disableBlock: false,
Expand Down Expand Up @@ -705,7 +731,7 @@ export const tasks = {
outputs: 2,
allowedInputs: true,
maxConnection: 1,
refDataKeys: ['body', 'url'],
refDataKeys: ['body', 'url', 'variableName'],
autocomplete: ['variableName'],
data: {
disableBlock: false,
Expand Down Expand Up @@ -879,7 +905,7 @@ export const tasks = {
allowedInputs: true,
maxConnection: 1,
autocomplete: ['variableName'],
refDataKeys: ['dataToCopy'],
refDataKeys: ['dataToCopy', 'variableName'],
data: {
disableBlock: false,
description: '',
Expand Down Expand Up @@ -984,7 +1010,7 @@ export const tasks = {
outputs: 1,
allowedInputs: true,
maxConnection: 1,
refDataKeys: ['selector', 'url', 'filename'],
refDataKeys: ['selector', 'url', 'filename', 'variableName'],
data: {
disableBlock: false,
description: '',
Expand Down Expand Up @@ -1058,7 +1084,7 @@ export const tasks = {
outputs: 1,
allowedInputs: true,
maxConnection: 1,
refDataKeys: ['filename', 'downloadId'],
refDataKeys: ['filename', 'downloadId', 'variableName'],
autocomplete: ['variableName'],
data: {
disableBlock: false,
Expand Down Expand Up @@ -1178,6 +1204,7 @@ export const tasks = {
outputs: 1,
allowedInputs: true,
maxConnection: 1,
refDataKeys: ['variableName'],
data: {
disableBlock: false,
description: '',
Expand Down Expand Up @@ -1344,6 +1371,7 @@ export const tasks = {
'url',
'value',
'jsonCode',
'variableName',
],
data: {
disableBlock: false,
Expand Down
2 changes: 1 addition & 1 deletion src/workflowEngine/utils/testConditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default async function (conditionsArr, workflowData) {
newRefData[keyword] = workflowData.refData[keyword];
});

if (workflowData.isMV2) {
if (workflowData.isMV2 && data.context !== 'background') {
conditionValue = await workflowData.sendMessage({
type: 'condition-builder',
data: {
Expand Down

0 comments on commit 4f28146

Please sign in to comment.