Browse Source

feat: expandable blocks list

Ahmad Kholid 3 years ago
parent
commit
60dc9b3405
1 changed files with 20 additions and 5 deletions
  1. 20 5
      src/components/newtab/workflow/WorkflowDetailsCard.vue

+ 20 - 5
src/components/newtab/workflow/WorkflowDetailsCard.vue

@@ -65,16 +65,23 @@
     >
     >
       <p>{{ t('workflow.cantEdit') }}</p>
       <p>{{ t('workflow.cantEdit') }}</p>
     </div>
     </div>
-    <template v-for="(items, catId) in blocks" :key="catId">
-      <div class="flex items-center top-0 space-x-2 mb-2">
+    <ui-expand
+      v-for="(items, catId) in blocks"
+      :key="catId"
+      v-model="expandList[catId]"
+      hide-header-icon
+      header-class="flex items-center py-2 focus:ring-0 w-full text-left text-gray-600 dark:text-gray-200"
+    >
+      <template #header="{ show }">
         <span
         <span
           :class="categories[catId].color"
           :class="categories[catId].color"
           class="h-3 w-3 rounded-full"
           class="h-3 w-3 rounded-full"
         ></span>
         ></span>
-        <p class="capitalize text-gray-600 dark:text-gray-200">
+        <p class="capitalize flex-1 ml-2">
           {{ categories[catId].name }}
           {{ categories[catId].name }}
         </p>
         </p>
-      </div>
+        <v-remixicon :name="show ? 'riSubtractLine' : 'riAddLine'" size="20" />
+      </template>
       <div class="grid grid-cols-2 gap-2 mb-4">
       <div class="grid grid-cols-2 gap-2 mb-4">
         <div
         <div
           v-for="block in items"
           v-for="block in items"
@@ -107,7 +114,7 @@
           </p>
           </p>
         </div>
         </div>
       </div>
       </div>
-    </template>
+    </ui-expand>
   </div>
   </div>
 </template>
 </template>
 <script setup>
 <script setup>
@@ -159,13 +166,21 @@ const blocksArr = Object.entries(tasks).map(([key, block]) => ({
   id: key,
   id: key,
   name: t(`workflow.blocks.${key}.name`),
   name: t(`workflow.blocks.${key}.name`),
 }));
 }));
+const categoriesExpand = Object.keys(categories).reduce((acc, key) => {
+  acc[key] = true;
+
+  return acc;
+}, {});
 
 
 const query = ref('');
 const query = ref('');
+const expandList = ref(categoriesExpand);
+
 const blocks = computed(() =>
 const blocks = computed(() =>
   blocksArr.reduce((arr, block) => {
   blocksArr.reduce((arr, block) => {
     if (
     if (
       block.name.toLocaleLowerCase().includes(query.value.toLocaleLowerCase())
       block.name.toLocaleLowerCase().includes(query.value.toLocaleLowerCase())
     ) {
     ) {
+      expandList.value[block.category] = true;
       (arr[block.category] = arr[block.category] || []).push(block);
       (arr[block.category] = arr[block.category] || []).push(block);
     }
     }