Ahmad Kholid 3 years ago
parent
commit
016ca7d740
3 changed files with 58 additions and 2 deletions
  1. 1 1
      package.json
  2. 54 0
      src/components/newtab/workflow/edit/EditNewTab.vue
  3. 3 1
      src/utils/reference-data.js

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "automa",
-  "version": "0.3.2",
+  "version": "0.4.0",
   "description": "An extension for automating your browser by connecting blocks",
   "license": "MIT",
   "repository": {

+ 54 - 0
src/components/newtab/workflow/edit/EditNewTab.vue

@@ -0,0 +1,54 @@
+<!-- use the current active tab optoin?  -->
+<template>
+  <div class="mb-2 mt-4">
+    <ui-textarea
+      :model-value="data.description"
+      class="w-full mb-2"
+      placeholder="Description"
+      @change="updateData({ description: $event })"
+    />
+    <ui-input
+      v-if="!data.activeTab"
+      :model-value="data.url"
+      title="URL"
+      class="w-full"
+      placeholder="http://example.com/"
+      @change="updateData({ url: $event })"
+    />
+    <a
+      href="https://github.com/Kholid060/automa/wiki/Features#reference-data"
+      rel="noopener"
+      class="text-primary inline-block mb-2 text-sm"
+      target="_blank"
+    >
+      Learn how to add dynamic data
+    </a>
+    <ui-checkbox
+      :model-value="data.updatePrevTab"
+      class="mb-2 leading-tight"
+      title="Use the previously opened new tab instead of creating a new one"
+      @change="updateData({ updatePrevTab: $event })"
+    >
+      Update previously opened tab
+    </ui-checkbox>
+    <ui-checkbox
+      :model-value="data.active"
+      @change="updateData({ active: $event })"
+    >
+      Set as active tab
+    </ui-checkbox>
+  </div>
+</template>
+<script setup>
+const props = defineProps({
+  data: {
+    type: Object,
+    default: () => ({}),
+  },
+});
+const emit = defineEmits(['update:data']);
+
+function updateData(value) {
+  emit('update:data', { ...props.data, ...value });
+}
+</script>

+ 3 - 1
src/utils/reference-data.js

@@ -50,7 +50,9 @@ export default function (block, data) {
           return data.prevBlockData;
         }
 
-        return JSON.stringify(objectPath.get(data[dataKey], path) ?? match);
+        const result = objectPath.get(data[dataKey], path) ?? match;
+
+        return isObject(result) ? JSON.stringify(result) : result;
       }
     );