KitList.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <b-overlay
  3. :show="filteredNodes === undefined"
  4. class="kit-list"
  5. z-index="0" spinner-variant="kit"
  6. >
  7. <div class="kit-list-wrapper">
  8. <header class="kit-list-header">
  9. <page-view
  10. v-if="intro"
  11. :page="intro" no-close slug="intro"
  12. class="small"
  13. />
  14. <search-input v-model="search" class="input-search" />
  15. </header>
  16. <div class="kit-list-container nodes-grid">
  17. <node-view
  18. v-for="node in filteredNodes" :key="'kit-' + node.id"
  19. :node="node"
  20. mode="card"
  21. @click.native.capture="openNode(node.id)"
  22. />
  23. </div>
  24. </div>
  25. </b-overlay>
  26. </template>
  27. <script>
  28. import { mapGetters } from 'vuex'
  29. import { NodeView } from '@/components/nodes'
  30. import { PageView } from '@/components/layouts'
  31. import { SearchInput } from '@/components/formItems'
  32. import { searchInNode } from '@/store/utils'
  33. export default {
  34. name: 'KitList',
  35. components: {
  36. NodeView,
  37. PageView,
  38. SearchInput
  39. },
  40. props: {
  41. },
  42. data () {
  43. return {
  44. search: '',
  45. intro: null
  46. }
  47. },
  48. computed: {
  49. ...mapGetters(['sheets']),
  50. filteredNodes () {
  51. if (!this.sheets) return
  52. const search = this.search.toLowerCase()
  53. return this.sheets.filter(node => searchInNode(search, node))
  54. }
  55. },
  56. methods: {
  57. openNode (id) {
  58. this.$store.dispatch('OPEN_KIT_NODE', id)
  59. }
  60. },
  61. async created () {
  62. this.$store.dispatch('INIT_KIT')
  63. this.$store.dispatch('QUERY_PAGE', 'kit').then(page => {
  64. this.intro = page
  65. })
  66. }
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. .kit-list {
  71. overflow-y: auto;
  72. height: 100%;
  73. &-wrapper {
  74. padding: 1.15rem;
  75. @include media-breakpoint-up($size-bp) {
  76. padding: 2.15rem;
  77. }
  78. }
  79. &-header {
  80. margin-bottom: 1.15rem;
  81. @include media-breakpoint-up($size-bp) {
  82. display: flex;
  83. justify-content: space-between;
  84. margin-bottom: 2.15rem;
  85. }
  86. .input-search {
  87. min-width: 30%;
  88. margin-bottom: 2.15rem;
  89. margin-top: 1.15rem;
  90. @include media-breakpoint-up($size-bp) {
  91. margin: 0;
  92. margin-left: 1.15rem;
  93. }
  94. }
  95. }
  96. .node-view {
  97. cursor: pointer;
  98. }
  99. }
  100. </style>