admin-groups-edit.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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', @click='assignUser')
  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. user-search(v-model='searchUserDialog')
  107. </template>
  108. <script>
  109. import Criterias from '../common/criterias.vue'
  110. import UserSearch from '../common/user-search.vue'
  111. import groupQuery from 'gql/admin-groups-query-single.gql'
  112. import deleteGroupMutation from 'gql/admin-groups-mutation-delete.gql'
  113. export default {
  114. components: {
  115. Criterias,
  116. UserSearch
  117. },
  118. data() {
  119. return {
  120. group: {
  121. id: 7,
  122. name: 'Editors',
  123. users: []
  124. },
  125. deleteGroupDialog: false,
  126. searchUserDialog: false,
  127. pagination: {},
  128. users: [],
  129. headers: [
  130. { text: 'ID', value: 'id', width: 50, align: 'right' },
  131. { text: 'Name', value: 'name' },
  132. { text: 'Email', value: 'email' },
  133. { text: '', value: 'actions', sortable: false, width: 50 }
  134. ],
  135. search: '',
  136. tab: '1'
  137. }
  138. },
  139. computed: {
  140. pages () {
  141. if (this.pagination.rowsPerPage == null || this.pagination.totalItems == null) {
  142. return 0
  143. }
  144. return Math.ceil(this.pagination.totalItems / this.pagination.rowsPerPage)
  145. }
  146. },
  147. methods: {
  148. async deleteGroupConfirm(group) {
  149. this.deleteGroupDialog = true
  150. this.selectedGroup = group
  151. },
  152. async deleteGroup() {
  153. this.deleteGroupDialog = false
  154. try {
  155. await this.$apollo.mutate({
  156. mutation: deleteGroupMutation,
  157. variables: {
  158. id: this.group.id
  159. },
  160. watchLoading (isLoading) {
  161. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-delete')
  162. }
  163. })
  164. this.$store.commit('showNotification', {
  165. style: 'success',
  166. message: `Group ${this.group.name} has been deleted.`,
  167. icon: 'delete'
  168. })
  169. this.$router.replace('/groups')
  170. } catch (err) {
  171. this.$store.commit('showNotification', {
  172. style: 'red',
  173. message: err.message,
  174. icon: 'warning'
  175. })
  176. }
  177. },
  178. assignUser() {
  179. this.searchUserDialog = true
  180. }
  181. },
  182. apollo: {
  183. group: {
  184. query: groupQuery,
  185. variables() {
  186. return {
  187. id: this.$route.params.id
  188. }
  189. },
  190. update: (data) => data.groups.single,
  191. watchLoading (isLoading) {
  192. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-refresh')
  193. }
  194. }
  195. }
  196. }
  197. </script>
  198. <style lang='scss'>
  199. </style>