admin-groups-edit.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template lang='pug'>
  2. v-card
  3. v-card(flat, color='grey lighten-5').pa-3.pt-4
  4. .headline.blue--text.text--darken-2 Edit Group
  5. .subheading.grey--text {{group.name}}
  6. v-btn(color='primary', fab, absolute, bottom, right, small, to='/groups'): v-icon arrow_upward
  7. v-tabs(v-model='tab', color='grey lighten-4', fixed-tabs, slider-color='primary', show-arrows)
  8. v-tab(key='properties') Properties
  9. v-tab(key='rights') Permissions
  10. v-tab(key='users') Users
  11. v-tab-item(key='properties', :transition='false', :reverse-transition='false')
  12. v-card
  13. v-card-text
  14. v-text-field(v-model='group.name', label='Group Name', counter='255', prepend-icon='people')
  15. v-card-actions.pa-3
  16. v-btn(color='primary', @click='')
  17. v-icon(left) check
  18. | Save Changes
  19. .caption.ml-4.grey--text ID: {{group.id}}
  20. v-spacer
  21. v-dialog(v-model='deleteGroupDialog', max-width='500')
  22. v-btn(color='red', flat, @click='', slot='activator')
  23. v-icon(left) delete
  24. | Delete Group
  25. v-card
  26. .dialog-header.is-red Delete Group?
  27. v-card-text Are you sure you want to delete group #[strong {{ group.name }}]? All users will be unassigned from this group.
  28. v-card-actions
  29. v-spacer
  30. v-btn(flat, @click='deleteGroupDialog = false') Cancel
  31. v-btn(color='red', dark, @click='deleteGroup') Delete
  32. v-tab-item(key='rights', :transition='false', :reverse-transition='false')
  33. v-card
  34. v-card-title.pb-0
  35. v-subheader
  36. v-icon.mr-2 border_color
  37. .subheading Read and Write
  38. v-spacer
  39. v-btn(flat, outline)
  40. v-icon(left) arrow_drop_down
  41. | Load Preset
  42. v-btn(flat, outline)
  43. v-icon(left) vertical_align_bottom
  44. | Import Rules
  45. .pa-3.pl-4
  46. criterias
  47. v-divider.my-0
  48. v-card-title.pb-0
  49. v-subheader
  50. v-icon.mr-2 pageview
  51. .subheading Read Only
  52. v-spacer
  53. v-btn(flat, outline)
  54. v-icon(left) arrow_drop_down
  55. | Load Preset
  56. v-btn(flat, outline)
  57. v-icon(left) vertical_align_bottom
  58. | Import Rules
  59. .pa-3.pl-4
  60. criterias
  61. v-divider.my-0
  62. v-card-title.pb-0
  63. v-subheader Legend
  64. .px-4.pb-4
  65. .body-1.px-1.py-2 Any number of rules can be used at the same time. However, some rules requires more processing time than others. Rule types are color-coded as followed:
  66. .caption
  67. v-icon(color='blue') stop
  68. span Fast rules. None or insignificant latency introduced to all page loads.
  69. .caption
  70. v-icon(color='orange') stop
  71. span Medium rules. Some latency added to all page loads.
  72. .caption
  73. v-icon(color='red') stop
  74. span Slow rules. May adds noticeable latency to all page loads. Avoid using in multiple rules.
  75. v-tab-item(key='users', :transition='false', :reverse-transition='false')
  76. v-card
  77. v-card-title.pb-0
  78. v-btn(color='primary')
  79. v-icon(left) assignment_ind
  80. | Assign User
  81. v-data-table(
  82. :items='group.users',
  83. :headers='headers',
  84. :search='search',
  85. :pagination.sync='pagination',
  86. :rows-per-page-items='[15]'
  87. hide-actions
  88. )
  89. template(slot='items', slot-scope='props')
  90. tr(:active='props.selected')
  91. td.text-xs-right {{ props.item.id }}
  92. td {{ props.item.name }}
  93. td {{ props.item.email }}
  94. td
  95. v-menu(bottom, right, min-width='200')
  96. v-btn(icon, slot='activator'): v-icon.grey--text.text--darken-1 more_horiz
  97. v-list
  98. v-list-tile(@click='deleteGroupConfirm(props.item)')
  99. v-list-tile-action: v-icon(color='orange') highlight_off
  100. v-list-tile-content
  101. v-list-tile-title Unassign
  102. template(slot='no-data')
  103. v-alert.ma-3(icon='warning', :value='true', outline) No users to display.
  104. .text-xs-center.py-2(v-if='users.length > 15')
  105. v-pagination(v-model='pagination.page', :length='pages')
  106. </template>
  107. <script>
  108. import Criterias from '../common/criterias.vue'
  109. import groupQuery from 'gql/admin-groups-query-single.gql'
  110. import deleteGroupMutation from 'gql/admin-groups-mutation-delete.gql'
  111. export default {
  112. components: {
  113. Criterias
  114. },
  115. data() {
  116. return {
  117. group: {
  118. id: 7,
  119. name: 'Editors',
  120. users: []
  121. },
  122. deleteGroupDialog: false,
  123. pagination: {},
  124. users: [],
  125. headers: [
  126. { text: 'ID', value: 'id', width: 50, align: 'right' },
  127. { text: 'Name', value: 'name' },
  128. { text: 'Email', value: 'email' },
  129. { text: '', value: 'actions', sortable: false, width: 50 }
  130. ],
  131. search: '',
  132. tab: '1'
  133. }
  134. },
  135. computed: {
  136. pages () {
  137. if (this.pagination.rowsPerPage == null || this.pagination.totalItems == null) {
  138. return 0
  139. }
  140. return Math.ceil(this.pagination.totalItems / this.pagination.rowsPerPage)
  141. }
  142. },
  143. methods: {
  144. async deleteGroupConfirm(group) {
  145. this.deleteGroupDialog = true
  146. this.selectedGroup = group
  147. },
  148. async deleteGroup() {
  149. this.deleteGroupDialog = false
  150. try {
  151. await this.$apollo.mutate({
  152. mutation: deleteGroupMutation,
  153. variables: {
  154. id: this.group.id
  155. },
  156. watchLoading (isLoading) {
  157. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-delete')
  158. }
  159. })
  160. this.$store.commit('showNotification', {
  161. style: 'success',
  162. message: `Group ${this.group.name} has been deleted.`,
  163. icon: 'delete'
  164. })
  165. this.$router.replace('/groups')
  166. } catch (err) {
  167. this.$store.commit('showNotification', {
  168. style: 'red',
  169. message: err.message,
  170. icon: 'warning'
  171. })
  172. }
  173. }
  174. },
  175. apollo: {
  176. group: {
  177. query: groupQuery,
  178. variables() {
  179. return {
  180. id: this.$route.params.id
  181. }
  182. },
  183. update: (data) => data.groups.single,
  184. watchLoading (isLoading) {
  185. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-refresh')
  186. }
  187. }
  188. }
  189. }
  190. </script>
  191. <style lang='scss'>
  192. </style>