You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
3.4 KiB

  1. <template>
  2. <div class="picker-wrap">
  3. <!-- <pre style="position: fixed; z-index: 500; right: 0; top: 7rem; font-size: 0.6rem; color: orange;">
  4. {{ selectedAirport }}
  5. </pre> -->
  6. <v-select
  7. :value="selectedAirportComp"
  8. label="iata"
  9. :options="airports"
  10. :filter-by="filterBy"
  11. placeholder="stuff"
  12. @input="changeAirport"
  13. >
  14. <template #no-options="{ search, searching }">
  15. <template v-if="searching">
  16. No results found for <em>{{ search }}</em>.
  17. </template>
  18. <em
  19. v-else
  20. style="opacity: 0.5;"
  21. >
  22. Start typing to search for an airport.
  23. </em>
  24. </template>
  25. <template #selected-option="option">
  26. <div class="picker-item">
  27. <div class="picker-item__section">
  28. <div class="picker-item__iata">
  29. {{ option.iata }}
  30. </div>
  31. </div>
  32. <div class="picker-item__section">
  33. <div class="picker-item__name">
  34. {{ option.name }}
  35. </div>
  36. <div class="picker-item__muni">
  37. {{ option.municipality }}
  38. </div>
  39. </div>
  40. </div>
  41. </template>
  42. <template #option="option">
  43. <div class="picker-item">
  44. <div class="picker-item__section">
  45. <div class="picker-item__iata">
  46. {{ option.iata }}
  47. </div>
  48. </div>
  49. <div class="picker-item__section">
  50. <div class="picker-item__name">
  51. {{ option.name }}
  52. </div>
  53. <div class="picker-item__muni">
  54. {{ option.municipality }}
  55. </div>
  56. </div>
  57. </div>
  58. </template>
  59. </v-select>
  60. </div>
  61. </template>
  62. <script>
  63. export default {
  64. props: {
  65. airports: {
  66. type: [Array],
  67. default () {
  68. return []
  69. }
  70. },
  71. selectedAirport: {
  72. type: [Object],
  73. default () {
  74. return {
  75. iata: '',
  76. lat: '',
  77. long: '',
  78. icon: '',
  79. name: '',
  80. municipality: '',
  81. type: '',
  82. search: ''
  83. }
  84. }
  85. }
  86. },
  87. data () {
  88. return {
  89. mountains: [],
  90. filterBy: (option, label, search) => {
  91. const temp = search.toLowerCase()
  92. return option.search.toLowerCase().includes(temp)
  93. }
  94. }
  95. },
  96. computed: {
  97. selectedAirportComp () {
  98. return {
  99. iata: this.selectedAirport.iata,
  100. lat: this.selectedAirport.lat,
  101. long: this.selectedAirport.long,
  102. icon: this.selectedAirport.icon,
  103. name: this.selectedAirport.name,
  104. municipality: this.selectedAirport.municipality,
  105. type: this.selectedAirport.type,
  106. search: this.selectedAirport.search,
  107. label: this.selectedAirport.label
  108. }
  109. }
  110. },
  111. methods: {
  112. changeAirport (value) {
  113. if (value) {
  114. this.$emit('select-airport', value)
  115. } else {
  116. this.$emit('deselect-airport', value)
  117. }
  118. }
  119. }
  120. }
  121. </script>
  122. <style>
  123. html {
  124. color: black;
  125. }
  126. .picker-wrap {
  127. margin: 1rem;
  128. }
  129. .picker-wrap:last-of-type {
  130. margin-top: 0;
  131. }
  132. .vs__search {
  133. font-size: 3rem !important;
  134. padding: 0.5rem;
  135. }
  136. .picker-item {
  137. padding: 0.5rem;
  138. display: flex;
  139. flex-direction: row;
  140. align-items: center;
  141. }
  142. .picker-item__name {
  143. font-size: 1rem;
  144. }
  145. .picker-item__muni {
  146. color: blue;
  147. }
  148. .picker-item__iata {
  149. font-size: 3rem;
  150. margin-right: 1rem;
  151. }
  152. </style>