WorkflowDetailsCard.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <div class="px-4 flex items-center mb-2">
  3. <ui-popover>
  4. <template #trigger>
  5. <span
  6. title="Workflow icon"
  7. class="
  8. p-2
  9. inline-block
  10. rounded-lg
  11. cursor-pointer
  12. bg-accent
  13. text-white
  14. mr-2
  15. align-middle
  16. "
  17. >
  18. <v-remixicon :name="workflow.icon" />
  19. </span>
  20. </template>
  21. <p class="mb-2">Workflow icon</p>
  22. <div class="grid grid-cols-4 gap-1">
  23. <span
  24. v-for="icon in icons"
  25. :key="icon"
  26. class="cursor-pointer rounded-lg inline-block p-2 hoverable"
  27. @click="$emit('update', { icon })"
  28. >
  29. <v-remixicon :name="icon" />
  30. </span>
  31. </div>
  32. </ui-popover>
  33. <p
  34. class="
  35. font-semibold
  36. text-overflow
  37. inline-block
  38. text-lg
  39. flex-1
  40. mr-4
  41. align-middle
  42. "
  43. >
  44. {{ workflow.name }}
  45. </p>
  46. </div>
  47. <div class="flex px-4 mt-2 space-x-2">
  48. <ui-button variant="accent" class="flex-1 relative" @click="$emit('save')">
  49. <span
  50. v-if="dataChanged"
  51. class="
  52. inline-block
  53. absolute
  54. h-3
  55. w-3
  56. rounded-full
  57. bg-primary
  58. -ml-1
  59. -mt-1
  60. top-0
  61. left-0
  62. "
  63. ></span>
  64. <v-remixicon name="riSaveLine" class="mr-2 -ml-1" />
  65. Save
  66. </ui-button>
  67. <ui-button icon title="Execute" @click="$emit('execute')">
  68. <v-remixicon name="riPlayLine" />
  69. </ui-button>
  70. <ui-popover>
  71. <template #trigger>
  72. <ui-button icon title="More">
  73. <v-remixicon name="riMore2Line" />
  74. </ui-button>
  75. </template>
  76. <ui-list>
  77. <ui-list-item
  78. v-close-popover
  79. class="cursor-pointer"
  80. @click="$emit('rename')"
  81. >
  82. <v-remixicon name="riPencilLine" class="mr-2 -ml-1" />
  83. <span>Rename</span>
  84. </ui-list-item>
  85. <ui-list-item
  86. v-close-popover
  87. class="cursor-pointer"
  88. @click="$emit('export', workflow)"
  89. >
  90. <v-remixicon name="riDownloadLine" class="mr-2 -ml-1" />
  91. <span>Export</span>
  92. </ui-list-item>
  93. <ui-list-item
  94. v-close-popover
  95. class="cursor-pointer"
  96. @click="$emit('showDataColumns')"
  97. >
  98. <v-remixicon name="riKey2Line" class="mr-2 -ml-1" />
  99. <span>Data columns</span>
  100. </ui-list-item>
  101. <ui-list-item
  102. v-close-popover
  103. class="cursor-pointer"
  104. @click="$emit('showSettings')"
  105. >
  106. <v-remixicon name="riSettings3Line" class="mr-2 -ml-1" />
  107. <span>Settings</span>
  108. </ui-list-item>
  109. <ui-list-item
  110. v-close-popover
  111. class="cursor-pointer"
  112. @click="$emit('delete')"
  113. >
  114. <v-remixicon name="riDeleteBin7Line" class="mr-2 -ml-1" />
  115. <span>Delete</span>
  116. </ui-list-item>
  117. </ui-list>
  118. </ui-popover>
  119. </div>
  120. <hr class="m-4 border-gray-100" />
  121. <div class="scroll bg-scroll overflow-auto px-4 flex-1 overflow-auto">
  122. <template v-for="(items, catId) in taskList" :key="catId">
  123. <div class="flex items-center top-0 space-x-2 mb-2">
  124. <span
  125. :class="categories[catId].color"
  126. class="h-3 w-3 rounded-full"
  127. ></span>
  128. <p class="capitalize text-gray-600">{{ categories[catId].name }}</p>
  129. </div>
  130. <div class="grid grid-cols-2 gap-2 mb-4">
  131. <div
  132. v-for="block in items"
  133. :key="block.id"
  134. :title="block.description || block.name"
  135. draggable="true"
  136. class="
  137. select-none
  138. cursor-move
  139. relative
  140. p-4
  141. rounded-lg
  142. bg-input
  143. transition
  144. "
  145. @dragstart="
  146. $event.dataTransfer.setData('block', JSON.stringify(block))
  147. "
  148. >
  149. <v-remixicon :name="block.icon" size="24" class="mb-2" />
  150. <p class="leading-tight text-overflow">
  151. {{ block.name }}
  152. </p>
  153. </div>
  154. </div>
  155. </template>
  156. </div>
  157. </template>
  158. <script setup>
  159. import { tasks, categories } from '@/utils/shared';
  160. defineProps({
  161. workflow: {
  162. type: Object,
  163. default: () => ({}),
  164. },
  165. dataChanged: {
  166. type: Boolean,
  167. default: false,
  168. },
  169. });
  170. defineEmits([
  171. 'save',
  172. 'export',
  173. 'update',
  174. 'rename',
  175. 'delete',
  176. 'execute',
  177. 'showSettings',
  178. 'showDataColumns',
  179. ]);
  180. const taskList = Object.keys(tasks).reduce((arr, key) => {
  181. const task = tasks[key];
  182. (arr[task.category] = arr[task.category] || []).push({ id: key, ...task });
  183. return arr;
  184. }, {});
  185. const icons = [
  186. 'riGlobalLine',
  187. 'riFileTextLine',
  188. 'riEqualizerLine',
  189. 'riTimerLine',
  190. 'riCalendarLine',
  191. 'riFlashlightLine',
  192. 'riLightbulbFlashLine',
  193. 'riDatabase2Line',
  194. 'riWindowLine',
  195. 'riCursorLine',
  196. 'riDownloadLine',
  197. 'riCommandLine',
  198. ];
  199. </script>