panel.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. :key="k"
  30. ref="src"
  31. class="flow-funcs__src hover-anim 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. {{ k }}
  37. </div>
  38. </div>
  39. </hx-collapsible>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import HxCollapsible from '@/components/shared/hx-collapsible'
  45. export default {
  46. name: 'FlowPanel',
  47. components: {HxCollapsible},
  48. props: {
  49. active: {type: Boolean, default: true},
  50. registry: {type: Object, default: () => {}}
  51. },
  52. data () {
  53. return {
  54. funcsViewBlocks: true
  55. }
  56. },
  57. computed: {
  58. funcsGroups () {
  59. let group = {}
  60. for (let r in this.registry) {
  61. group[this.registry[r].group] = true
  62. }
  63. return Object.keys(group)
  64. },
  65. funcsGroup () {
  66. return (g) => {
  67. const ret = Object.keys(this.registry).filter(v => this.registry[v].group === g)
  68. return ret
  69. }
  70. }
  71. },
  72. methods: {
  73. fnDrag (ev, src) {
  74. ev.dataTransfer.setData('text/plain', src)
  75. }
  76. }
  77. }
  78. </script>
  79. <style>
  80. .flow-funcs__container {
  81. white-space: nowrap;
  82. width:0px;
  83. transition: all .3s;
  84. height:100%;
  85. overflow-x:hidden;
  86. overflow-y:auto;
  87. }
  88. .flow-funcs__container.active {
  89. width:300px;
  90. }
  91. .flow-funcs__control {
  92. display:flex;
  93. flex-flow:row;
  94. }
  95. .flow-funcs__control .item{
  96. font-size:14px;
  97. padding:13px;
  98. flex:1;
  99. height:100%;
  100. text-align:center;
  101. color:black;
  102. text-overflow: ellipsis;
  103. min-width:50px;
  104. height:50px;
  105. overflow:hidden;
  106. }
  107. .flow-funcs__inner {
  108. overflow:hidden;
  109. margin-top:20px;
  110. }
  111. .flow-funcs__inner .hx-collapsible__header {
  112. font-size:14px;
  113. padding:5px 10px;
  114. transition: all .3s;
  115. }
  116. .flow-funcs__group{
  117. display:flex;
  118. flex-flow:column;
  119. padding:10px;
  120. }
  121. .flow-funcs__src {
  122. font-size:12px;
  123. padding:11px 5px;
  124. margin-top:1px;
  125. text-align:center;
  126. transition: all .3s;
  127. position:relative;
  128. display:flex;
  129. justify-content: center;
  130. align-items: center;
  131. cursor: move;
  132. cursor: grab;
  133. cursor: -moz-grab;
  134. cursor: -webkit-grab;
  135. }
  136. .flow-funcs__group.blocks {
  137. flex-flow: row;
  138. flex-wrap: wrap;
  139. justify-content: flex-start;
  140. align-content: center;
  141. }
  142. .flow-funcs__group.blocks .flow-funcs__src {
  143. text-overflow: ellipsis;
  144. margin:1px;
  145. width: 60px;
  146. height:60px;
  147. overflow:hidden;
  148. }
  149. .flow-funcs__toggle {
  150. margin:0;
  151. position:relative;
  152. }
  153. </style>