Map.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <b-overlay :show="loading" rounded="sm" class="h-100">
  3. <div class="d-flex flex-column h-100 px-4 py-3">
  4. <div id="maps">
  5. <div>
  6. <h4>Carte avec duplication</h4>
  7. <div class="node-map">
  8. <node-map
  9. v-if="data"
  10. v-bind="mapSingle"
  11. :show-id="showId"
  12. />
  13. </div>
  14. </div>
  15. <div>
  16. <h4>Carte avec liens multiples</h4>
  17. <div class="node-map">
  18. <node-map
  19. v-if="data"
  20. v-bind="mapMany"
  21. :show-id="showId"
  22. id="map-2"
  23. />
  24. </div>
  25. </div>
  26. </div>
  27. <b-form class="mt-4">
  28. <b-form-group label="Texte de départ :" label-cols="2" class="mb-2">
  29. <b-form-select
  30. v-model="textId"
  31. @input="query"
  32. :options="textsDepartOptions"
  33. />
  34. </b-form-group>
  35. <b-form-group label="Profondeur :" label-cols="2" class="mb-2">
  36. <b-form-spinbutton
  37. v-model="depth"
  38. @input="query"
  39. min="0" max="6"
  40. inline
  41. />
  42. </b-form-group>
  43. <b-form-checkbox v-model="showId" name="check-button" switch>
  44. Afficher les numéros
  45. </b-form-checkbox>
  46. </b-form>
  47. </div>
  48. </b-overlay>
  49. </template>
  50. <script>
  51. import { mapGetters } from 'vuex'
  52. import NodeMap from '@/components/NodeMap'
  53. import { toSingleManyData, toManyManyData } from '@/helpers/d3Data'
  54. export default {
  55. name: 'Home',
  56. components: {
  57. NodeMap
  58. },
  59. data () {
  60. return {
  61. loading: false,
  62. textId: undefined,
  63. showId: true,
  64. depth: 3,
  65. data: null,
  66. mapSingle: { nodes: null, links: null },
  67. mapMany: { nodes: null, links: null }
  68. }
  69. },
  70. computed: {
  71. ...mapGetters(['textsDepartOptions'])
  72. },
  73. methods: {
  74. query () {
  75. const { textId: id, depth } = this
  76. this.data = null
  77. this.loading = true
  78. this.$store.dispatch('GET_TREE_WITH_DEPTH', { id, depth }).then((data) => {
  79. this.mapSingle = toSingleManyData(data)
  80. this.mapMany = toManyManyData(data)
  81. this.data = data
  82. this.loading = false
  83. })
  84. }
  85. },
  86. created () {
  87. this.loading = true
  88. this.$store.dispatch('GET_TEXTS_DEPART').then(textsDepart => {
  89. this.textId = textsDepart[0].id
  90. })
  91. }
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. #maps {
  96. width: 100%;
  97. height: 100%;
  98. display: flex;
  99. & > div {
  100. flex-basis: 50%;
  101. display: flex;
  102. flex-direction: column;
  103. & + div .node-map {
  104. border-left: none;
  105. }
  106. }
  107. .node-map {
  108. height: 100%;
  109. border: 1px solid grey;
  110. }
  111. }
  112. .col > * {
  113. width: auto;
  114. }
  115. </style>