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.

74 lines
1.7 KiB

  1. <template>
  2. <v-menu>
  3. <template #activator="{ on: menu }">
  4. <v-tooltip bottom>
  5. <template #activator="{ on: tooltip }">
  6. <v-btn icon v-on="{ ...tooltip, ...menu }">
  7. <v-icon>
  8. {{ mdiSort }}
  9. </v-icon>
  10. </v-btn>
  11. </template>
  12. <span>{{ $t('annotation.selectFilterTooltip') }}</span>
  13. </v-tooltip>
  14. </template>
  15. <v-list>
  16. <v-list-item-group v-model="selected">
  17. <v-list-item v-for="(item, i) in items" :key="i">
  18. <v-list-item-icon>
  19. <v-icon v-if="selected === i">
  20. {{ mdiCheck }}
  21. </v-icon>
  22. </v-list-item-icon>
  23. <v-list-item-content>
  24. <v-list-item-title>
  25. {{ item.title }}
  26. </v-list-item-title>
  27. </v-list-item-content>
  28. </v-list-item>
  29. </v-list-item-group>
  30. </v-list>
  31. </v-menu>
  32. </template>
  33. <script>
  34. import { mdiSort, mdiCheck } from '@mdi/js'
  35. export default {
  36. props: {
  37. value: {
  38. type: String,
  39. default: '',
  40. required: true
  41. }
  42. },
  43. data() {
  44. return {
  45. items: [
  46. { title: 'Lowest score first', param: 'score' },
  47. { title: 'Highest score first', param: '-score' }
  48. ],
  49. mdiSort,
  50. mdiCheck
  51. }
  52. },
  53. computed: {
  54. selected: {
  55. get() {
  56. const index = this.items.findIndex((item) => item.param === this.value)
  57. return index === -1 ? undefined : index
  58. },
  59. set(value) {
  60. console.log(value)
  61. if (value !== undefined) {
  62. this.$emit('click:order', this.items[value].param)
  63. } else {
  64. this.$emit('click:order', '')
  65. }
  66. }
  67. }
  68. }
  69. }
  70. </script>