admin-groups.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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-dialog(v-model='newGroupDialog', max-width='500')
  9. v-btn(color='primary', dark, slot='activator')
  10. v-icon(left) add
  11. | New Group
  12. v-card
  13. .dialog-header.is-short New Group
  14. v-card-text
  15. v-text-field(v-model='newGroupName', label='Group Name', autofocus, counter='255')
  16. v-card-actions
  17. v-spacer
  18. v-btn(flat, @click='newGroupDialog = false') Cancel
  19. v-btn(color='primary', @click='createGroup') Create
  20. v-btn(icon)
  21. v-icon.grey--text refresh
  22. v-spacer
  23. v-text-field(append-icon='search', label='Search', single-line, hide-details, v-model='search')
  24. v-data-table(
  25. v-model='selected'
  26. :items='groups',
  27. :headers='headers',
  28. :search='search',
  29. :pagination.sync='pagination',
  30. :rows-per-page-items='[15]'
  31. hide-actions,
  32. disable-initial-sort
  33. )
  34. template(slot='items', slot-scope='props')
  35. tr(:active='props.selected')
  36. td.text-xs-right {{ props.item.id }}
  37. td {{ props.item.name }}
  38. td {{ props.item.userCount }}
  39. td: v-btn(icon): v-icon.grey--text.text--darken-1 more_horiz
  40. template(slot='no-data')
  41. v-alert.ma-3(icon='warning', :value='true', outline) No groups to display.
  42. .text-xs-center.py-2(v-if='groups.length > 15')
  43. v-pagination(v-model='pagination.page', :length='pages')
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. newGroupDialog: false,
  50. newGroupName: '',
  51. selected: [],
  52. pagination: {},
  53. groups: [],
  54. headers: [
  55. { text: 'ID', value: 'id', width: 50, align: 'right' },
  56. { text: 'Name', value: 'name' },
  57. { text: 'Users', value: 'userCount', width: 200 },
  58. { text: '', value: 'actions', sortable: false, width: 50 }
  59. ],
  60. search: ''
  61. }
  62. },
  63. computed: {
  64. pages () {
  65. if (this.pagination.rowsPerPage == null || this.pagination.totalItems == null) {
  66. return 0
  67. }
  68. return Math.ceil(this.pagination.totalItems / this.pagination.rowsPerPage)
  69. }
  70. },
  71. methods: {
  72. async createGroup() {
  73. // try {
  74. // const resp = await this.$apollo.mutate({
  75. // mutation: CONSTANTS.GRAPH.GROUPS.CREATE,
  76. // variables: {
  77. // name: this.newGroupName
  78. // }
  79. // })
  80. // } catch (err) {
  81. // }
  82. }
  83. }
  84. }
  85. </script>
  86. <style lang='scss'>
  87. </style>