panel.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <div
  3. class="flow-funcs__container"
  4. :class="{active:active}">
  5. <div class="flow-funcs__control">
  6. <!-- make this toggle able -->
  7. <button
  8. class="item"
  9. @click="funcsViewBlocks=!funcsViewBlocks">
  10. {{ funcsViewBlocks ? 'List':'Blocks' }} view
  11. </button>
  12. <button
  13. class="item"
  14. @click="$emit('toggleResizeable')">
  15. Resize
  16. </button>
  17. </div>
  18. <div class="flow-funcs__inner">
  19. <hx-collapsible
  20. v-for="g in funcsGroups"
  21. :key="g">
  22. <div
  23. class="flow-funcs__header"
  24. slot="header">{{ g }}</div>
  25. <div
  26. class="flow-funcs__group"
  27. :class="{blocks:funcsViewBlocks}">
  28. <div
  29. ref="src"
  30. :key="k"
  31. class="flow-funcs__src hover"
  32. draggable="true"
  33. v-for="k in funcsGroup(g)"
  34. @dragstart="fnDrag($event,k)"
  35. :style="{ 'background': registry[k].style && registry[k].style.color, }"
  36. :title="k"
  37. >
  38. {{ k }}
  39. </div>
  40. </div>
  41. </hx-collapsible>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. import HxCollapsible from '@/components/shared/hx-collapsible'
  47. export default {
  48. name: 'FlowPanel',
  49. components: {HxCollapsible},
  50. props: {
  51. active: {type: Boolean, default: true},
  52. registry: {type: Object, default: () => {}}
  53. },
  54. data () {
  55. return {
  56. funcsViewBlocks: true
  57. }
  58. },
  59. computed: {
  60. funcsGroups () {
  61. // Set
  62. let group = new Set()
  63. for (let r in this.registry) {
  64. for (let c of this.registry[r].categories) {
  65. group.add(c)
  66. }
  67. }
  68. return [...group]
  69. },
  70. funcsGroup () {
  71. return (g) => {
  72. const ret = Object.keys(this.registry).filter(v => this.registry[v].categories.includes(g))
  73. return ret
  74. }
  75. }
  76. },
  77. methods: {
  78. fnDrag (ev, src) {
  79. ev.dataTransfer.setData('text/plain', src)
  80. }
  81. }
  82. }
  83. </script>
  84. <style>
  85. .flow-funcs__container {
  86. white-space: nowrap;
  87. width:0;
  88. transition: all 0.3s;
  89. height:100%;
  90. overflow-x:hidden;
  91. overflow-y:auto;
  92. }
  93. .flow-funcs__container.active {
  94. width:300px;
  95. }
  96. .flow-funcs__control {
  97. display:flex;
  98. flex-flow:row;
  99. }
  100. .flow-funcs__control .item{
  101. font-size:14px;
  102. padding:13px;
  103. flex:1;
  104. height:100%;
  105. text-align:center;
  106. color:black;
  107. text-overflow: ellipsis;
  108. min-width:50px;
  109. height:50px;
  110. overflow:hidden;
  111. }
  112. .flow-funcs__inner {
  113. overflow:hidden;
  114. margin-top:20px;
  115. }
  116. .flow-funcs__inner .hx-collapsible__header {
  117. font-size:14px;
  118. padding:5px 10px;
  119. transition: all 0.3s;
  120. }
  121. .flow-funcs__group{
  122. display:flex;
  123. flex-flow:column;
  124. padding:10px;
  125. }
  126. .flow-funcs__src {
  127. font-size:14px;
  128. padding:12px 4px;
  129. margin-top:1px;
  130. text-align:center;
  131. transition: all 0.3s;
  132. position:relative;
  133. display:flex;
  134. justify-content: center;
  135. align-items: center;
  136. cursor: move;
  137. cursor: grab;
  138. cursor: -moz-grab;
  139. cursor: -webkit-grab;
  140. }
  141. .flow-funcs__group.blocks {
  142. flex-flow: row;
  143. flex-wrap: wrap;
  144. align-content: center;
  145. }
  146. .flow-funcs__group.blocks .flow-funcs__src {
  147. display:block;
  148. font-size:10px;
  149. width: calc(25% - 2px);
  150. padding:18px 4px;
  151. text-overflow: ellipsis;
  152. margin:1px;
  153. word-wrap: break-all;
  154. overflow:hidden;
  155. }
  156. .flow-funcs__toggle {
  157. margin:0;
  158. position:relative;
  159. }
  160. </style>