admin-groups.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template lang='pug'>
  2. v-card(flat)
  3. v-card(flat, color='grey lighten-5').pa-3.pt-4
  4. .headline.blue--text.text--darken-2 Groups
  5. .subheading.grey--text Manage groups
  6. v-card
  7. v-card-title
  8. v-btn(color='primary', dark)
  9. v-icon(left) add
  10. | New Group
  11. v-btn(icon)
  12. v-icon.grey--text refresh
  13. v-spacer
  14. v-text-field(append-icon='search', label='Search', single-line, hide-details, v-model='search')
  15. v-data-table(
  16. v-model='selected'
  17. :items='items',
  18. :headers='headers',
  19. :search='search',
  20. :pagination.sync='pagination',
  21. :rows-per-page-items='[15]'
  22. select-all,
  23. hide-actions,
  24. disable-initial-sort
  25. )
  26. template(slot='headers', slot-scope='props')
  27. tr
  28. th(width='50')
  29. th.text-xs-right(
  30. width='80'
  31. :class='[`column sortable`, pagination.descending ? `desc` : `asc`, pagination.sortBy === `id` ? `active` : ``]'
  32. @click='changeSort(`id`)'
  33. )
  34. v-icon(small) arrow_upward
  35. | ID
  36. th.text-xs-left(
  37. v-for='header in props.headers'
  38. :key='header.text'
  39. :width='header.width'
  40. :class='[`column sortable`, pagination.descending ? `desc` : `asc`, header.value === pagination.sortBy ? `active` : ``]'
  41. @click='changeSort(header.value)'
  42. )
  43. | {{ header.text }}
  44. v-icon(small) arrow_upward
  45. template(slot='items', slot-scope='props')
  46. tr(:active='props.selected')
  47. td
  48. v-checkbox(hide-details, :input-value='props.selected', color='blue darken-2', @click='props.selected = !props.selected')
  49. td.text-xs-right {{ props.item.id }}
  50. td {{ props.item.name }}
  51. td {{ props.item.userCount }}
  52. td: v-btn(icon): v-icon.grey--text.text--darken-1 more_horiz
  53. template(slot='no-data')
  54. v-alert(icon='warning', :value='true') No users to display!
  55. .text-xs-center.py-2(v-if='items.length > 15')
  56. v-pagination(v-model='pagination.page', :length='pages')
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. selected: [],
  63. pagination: {},
  64. items: [
  65. { id: 1, name: 'Administrators', userCount: 1 },
  66. { id: 2, name: 'Users', userCount: 23 }
  67. ],
  68. headers: [
  69. { text: 'Name', value: 'name' },
  70. { text: 'Users', value: 'userCount', width: 200 },
  71. { text: '', value: 'actions', sortable: false, width: 50 }
  72. ],
  73. search: ''
  74. }
  75. },
  76. computed: {
  77. pages () {
  78. if (this.pagination.rowsPerPage == null || this.pagination.totalItems == null) {
  79. return 0
  80. }
  81. return Math.ceil(this.pagination.totalItems / this.pagination.rowsPerPage)
  82. }
  83. },
  84. methods: {
  85. changeSort (column) {
  86. if (this.pagination.sortBy === column) {
  87. this.pagination.descending = !this.pagination.descending
  88. } else {
  89. this.pagination.sortBy = column
  90. this.pagination.descending = false
  91. }
  92. },
  93. toggleAll () {
  94. if (this.selected.length) {
  95. this.selected = []
  96. } else {
  97. this.selected = this.items.slice()
  98. }
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang='scss'>
  104. </style>