WorkflowDetailsCard.vue 5.2 KB

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