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.

PredefinedStatusesList.vue 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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
  23. v-if="hasLoaded"
  24. class="predefined-statuses-list">
  25. <PredefinedStatus
  26. v-for="status in predefinedStatuses"
  27. :key="status.id"
  28. :message-id="status.id"
  29. :icon="status.icon"
  30. :message="status.message"
  31. :clear-at="status.clearAt"
  32. @select="selectStatus(status)" />
  33. </div>
  34. <div
  35. v-else
  36. class="predefined-statuses-list">
  37. <div class="icon icon-loading-small" />
  38. </div>
  39. </template>
  40. <script>
  41. import PredefinedStatus from './PredefinedStatus'
  42. import { mapState } from 'vuex'
  43. export default {
  44. name: 'PredefinedStatusesList',
  45. components: {
  46. PredefinedStatus,
  47. },
  48. computed: {
  49. ...mapState({
  50. predefinedStatuses: state => state.predefinedStatuses.predefinedStatuses,
  51. }),
  52. /**
  53. * Indicator whether the predefined statuses have already been loaded
  54. *
  55. * @returns {boolean}
  56. */
  57. hasLoaded() {
  58. return this.predefinedStatuses.length > 0
  59. },
  60. },
  61. /**
  62. * Loads all predefined statuses from the server
  63. * when this component is mounted
  64. */
  65. mounted() {
  66. this.$store.dispatch('loadAllPredefinedStatuses')
  67. },
  68. methods: {
  69. /**
  70. * Emits an event when the user selects a status
  71. *
  72. * @param {Object} status The selected status
  73. */
  74. selectStatus(status) {
  75. this.$emit('selectStatus', status)
  76. },
  77. },
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. .predefined-statuses-list {
  82. display: flex;
  83. flex-direction: column;
  84. margin-bottom: 10px;
  85. }
  86. </style>