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.

ClearAtSelect.vue 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <!--
  2. - @copyright Copyright (c) 2020 Georg Ehrke <oc.list@georgehrke.com>
  3. - @author Georg Ehrke <oc.list@georgehrke.com>
  4. -
  5. - @license GNU AGPL version 3 or any later version
  6. -
  7. - This program is free software: you can redistribute it and/or modify
  8. - it under the terms of the GNU Affero General Public License as
  9. - published by the Free Software Foundation, either version 3 of the
  10. - License, or (at your option) any later version.
  11. -
  12. - This program is distributed in the hope that it will be useful,
  13. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. - GNU Affero General Public License for more details.
  16. -
  17. - You should have received a copy of the GNU Affero General Public License
  18. - along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. -
  20. -->
  21. <template>
  22. <div class="clear-at-select">
  23. <span
  24. class="clear-at-select__label">
  25. {{ $t('user_select', 'Clear status after') }}
  26. </span>
  27. <Multiselect
  28. label="label"
  29. :value="option"
  30. :options="options"
  31. open-direction="top"
  32. @select="select" />
  33. </div>
  34. </template>
  35. <script>
  36. import Multiselect from '@nextcloud/vue/dist/Components/Multiselect'
  37. import { getAllClearAtOptions } from '../services/clearAtOptionsService'
  38. import { clearAtFilter } from '../filters/clearAtFilter'
  39. export default {
  40. name: 'ClearAtSelect',
  41. components: {
  42. Multiselect,
  43. },
  44. props: {
  45. clearAt: {
  46. type: Object,
  47. default: null,
  48. },
  49. },
  50. data() {
  51. return {
  52. options: getAllClearAtOptions(),
  53. }
  54. },
  55. computed: {
  56. /**
  57. * Returns an object of the currently selected option
  58. *
  59. * @returns {Object}
  60. */
  61. option() {
  62. return {
  63. clearAt: this.clearAt,
  64. label: clearAtFilter(this.clearAt),
  65. }
  66. },
  67. },
  68. methods: {
  69. /**
  70. * Triggered when the user selects a new option.
  71. *
  72. * @param {Object=} option The new selected option
  73. */
  74. select(option) {
  75. if (!option) {
  76. return
  77. }
  78. this.$emit('selectClearAt', option.clearAt)
  79. },
  80. },
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .clear-at-select {
  85. display: flex;
  86. margin-bottom: 10px;
  87. align-items: center;
  88. &__label {
  89. margin-right: 10px;
  90. }
  91. .multiselect {
  92. flex-grow: 1;
  93. }
  94. }
  95. </style>