Browse Source

feat(editor): add bubbles and cancelable to trigger-event

Ahmad Kholid 3 years ago
parent
commit
05b607cf8b

+ 21 - 7
src/components/newtab/workflow/WorkflowDetailsCard.vue

@@ -35,12 +35,22 @@
     </p>
     </p>
   </div>
   </div>
   <div class="flex px-4 mt-2 space-x-2">
   <div class="flex px-4 mt-2 space-x-2">
-    <ui-button
-      :disabled="!dataChanged"
-      variant="accent"
-      class="flex-1"
-      @click="$emit('save')"
-    >
+    <ui-button variant="accent" class="flex-1 relative" @click="$emit('save')">
+      <span
+        v-if="dataChanged"
+        class="
+          inline-block
+          absolute
+          h-3
+          w-3
+          rounded-full
+          bg-primary
+          -ml-1
+          -mt-1
+          top-0
+          left-0
+        "
+      ></span>
       <v-remixicon name="riSaveLine" class="mr-2 -ml-1" />
       <v-remixicon name="riSaveLine" class="mr-2 -ml-1" />
       Save
       Save
     </ui-button>
     </ui-button>
@@ -54,7 +64,11 @@
         </ui-button>
         </ui-button>
       </template>
       </template>
       <ui-list>
       <ui-list>
-        <ui-list-item class="cursor-pointer" @click="$emit('showDataColumns')">
+        <ui-list-item
+          v-close-popover
+          class="cursor-pointer"
+          @click="$emit('showDataColumns')"
+        >
           <v-remixicon name="riKey2Line" class="mr-2 -ml-1" />
           <v-remixicon name="riKey2Line" class="mr-2 -ml-1" />
           <span>Data columns</span>
           <span>Data columns</span>
         </ui-list-item>
         </ui-list-item>

+ 20 - 4
src/components/newtab/workflow/edit/EditTriggerEvent.vue

@@ -11,7 +11,6 @@
       </option>
       </option>
     </ui-select>
     </ui-select>
     <button
     <button
-      v-if="componentName"
       class="mb-2 block w-full text-left mt-4 focus:ring-0"
       class="mb-2 block w-full text-left mt-4 focus:ring-0"
       @click="showOptions = !showOptions"
       @click="showOptions = !showOptions"
     >
     >
@@ -23,9 +22,24 @@
       <span class="align-middle">Options</span>
       <span class="align-middle">Options</span>
     </button>
     </button>
     <transition-expand>
     <transition-expand>
-      <div v-if="showOptions && componentName">
+      <div v-if="showOptions">
+        <div class="grid grid-cols-2 gap-2 mb-4">
+          <ui-checkbox
+            :model-value="params.bubbles"
+            @change="updateParams({ ...params, bubbles: $event })"
+          >
+            Bubbles
+          </ui-checkbox>
+          <ui-checkbox
+            :model-value="params.cancelable"
+            @change="updateParams({ ...params, cancelable: $event })"
+          >
+            Cancelable
+          </ui-checkbox>
+        </div>
         <component
         <component
           :is="componentName"
           :is="componentName"
+          v-if="componentName"
           :params="params"
           :params="params"
           @update="updateParams"
           @update="updateParams"
         />
         />
@@ -88,8 +102,10 @@ function handleEventChange(value) {
   componentName.value = eventComponents[eventType];
   componentName.value = eventComponents[eventType];
 
 
   if (eventType !== props.eventType) {
   if (eventType !== props.eventType) {
-    payload.eventParams = {};
-    params.value = {};
+    const defaultParams = { bubbles: true, cancelable: true };
+
+    payload.eventParams = defaultParams;
+    params.value = defaultParams;
   }
   }
 
 
   updateData(payload);
   updateData(payload);

+ 1 - 1
src/utils/shared.js

@@ -191,7 +191,7 @@ export const tasks = {
       multiple: false,
       multiple: false,
       eventName: '',
       eventName: '',
       eventType: '',
       eventType: '',
-      eventParams: {},
+      eventParams: { bubbles: true, cancelable: false },
     },
     },
   },
   },
   conditions: {
   conditions: {