1
0

App.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <script>
  2. import { RouterLink, RouterView } from 'vue-router'
  3. import { mapState, mapActions } from 'pinia'
  4. import { UserStore } from '@/stores/user'
  5. import { ConcernementsStore } from '@/stores/concernements'
  6. import StaticMenu from '@components/block/StaticMenu.vue'
  7. import UserBlock from '@components/block/UserBlock.vue'
  8. import SearchBlock from '@components/block/SearchBlock.vue'
  9. import MapConcernements from '@components/MapConcernements.vue'
  10. import ConcernementMapItem from '@components/ConcernementMapItem.vue'
  11. export default {
  12. data() {
  13. return {
  14. mapitems: [],
  15. // not_cloned_mapitems: [],
  16. // superposed_cloned_mapitems: []
  17. }
  18. },
  19. created () {
  20. this.loadContentTypeDefinition();
  21. this.loadConcernements()
  22. },
  23. mounted () {
  24. console.log('APP onMounted')
  25. this.checkUser()
  26. },
  27. computed: {
  28. ...mapState(UserStore,['isloggedin']),
  29. ...mapState(ConcernementsStore,['map_mode',
  30. 'concernements',
  31. 'concernements_loaded',
  32. 'concernementsByID',
  33. 'allSuperpositions_bycids',
  34. 'allSuperpositions_clustered',
  35. 'allMapItems_byid',
  36. 'opened_recit']),
  37. },
  38. watch: {
  39. concernements_loaded:{
  40. handler (n, o) {
  41. if(n && !o){
  42. this.parseMapitems()
  43. }
  44. },
  45. deep: true
  46. }
  47. },
  48. methods: {
  49. ...mapActions(ConcernementsStore,['loadConcernements']),
  50. ...mapActions(ConcernementsStore,['loadContentTypeDefinition']),
  51. ...mapActions(UserStore,['checkUser']),
  52. parseMapitems() {
  53. // let couple_ids = Object.keys(this.allSuperpositions_bycids);
  54. // console.log('App couple_ids', couple_ids);
  55. // loop through all concernement
  56. for(let [concernement_id, concernement] of Object.entries(this.concernementsByID)){
  57. // create the main mapitem object
  58. let mapitem = {
  59. id: concernement.id,
  60. concernement: concernement,
  61. // superposition_ids: [],
  62. superposition_cluster_index: -1,
  63. clone: false,
  64. }
  65. // loop through all superposition_clusters
  66. for( let [cluster_index, cluster] of this.allSuperpositions_clustered.entries()){
  67. let cids = [];
  68. // console.log(`cluster ${cluster_index}`, cluster);
  69. for( let s of cluster){
  70. cids.push(s.cid)
  71. }
  72. // console.log(`cids:${cids}`);
  73. if(cids.indexOf(concernement.id) !== -1){
  74. // console.log('concernement in cluster');
  75. if (mapitem.superposition_cluster_index === -1) {
  76. // if main map item does not yet have a superposition use it and alter his id (for matter constraints)
  77. mapitem.superposition_cluster_index = cluster_index
  78. mapitem.id = `${concernement.id}___${cluster_index}`
  79. }else{
  80. let mapitem_superposition = {
  81. id: `${concernement.id}___${cluster_index}`,
  82. concernement: concernement,
  83. superposition_cluster_index: cluster_index,
  84. clone: true
  85. };
  86. this.mapitems.push(mapitem_superposition);
  87. this.allMapItems_byid[mapitem_superposition.id] = mapitem_superposition;
  88. }
  89. }
  90. }
  91. this.mapitems.push(mapitem)
  92. this.allMapItems_byid[mapitem.id] = mapitem;
  93. }
  94. console.log('App mapitems', this.mapitems);
  95. }
  96. },
  97. components: {
  98. MapConcernements,
  99. ConcernementMapItem,
  100. StaticMenu,
  101. UserBlock,
  102. SearchBlock
  103. }
  104. }
  105. </script>
  106. <template>
  107. <header id="header">
  108. <div class="row title">
  109. <h1>
  110. <router-link :to="{ name: 'home' }"><span class="title">Atlas</span> des cartes d'atterrissage</router-link>
  111. </h1>
  112. </div>
  113. <div class="row top">
  114. <StaticMenu/>
  115. <SearchBlock/>
  116. <UserBlock/>
  117. </div>
  118. </header>
  119. <div id="main-content">
  120. <MapConcernements>
  121. <transition name="fade">
  122. <div class="loading" v-if="mapitems.length === 0">Chargement</div>
  123. </transition>
  124. <template v-if="mapitems.length > 0">
  125. <template v-for="(mapitem,index) in mapitems">
  126. <!-- && ((map_mode === 'superposition' && mapitem.clone) || !mapitem.clone) -->
  127. <ConcernementMapItem
  128. v-if="mapitem.concernement.visible"
  129. :key="mapitem.id"
  130. :mapitem="mapitem"
  131. />
  132. </template>
  133. </template>
  134. </MapConcernements>
  135. <div id="content" :class="{'recit-opened':opened_recit}">
  136. <RouterView />
  137. </div>
  138. </div>
  139. </template>
  140. <style lang="scss" scoped>
  141. .fade-enter-active,
  142. .fade-leave-active {
  143. transition: opacity 1s ease;
  144. }
  145. .fade-enter-from,
  146. .fade-leave-to {
  147. opacity: 0;
  148. }
  149. </style>