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.

131 lines
3.0KB

  1. <template>
  2. <base-material-dialog
  3. :value="value"
  4. icon="mdi-home"
  5. title="Person bearbeiten"
  6. :sub-title="id ? id : 'NEU'"
  7. color="rgb(255, 4, 29)"
  8. :actions="[doc && isMaster ? 'del' : '', isMaster ? 'save' : '', 'cancel']"
  9. @del="del"
  10. @save="save"
  11. @close="close"
  12. @esc="close"
  13. >
  14. <v-row v-if="!isMaster">
  15. Kein Zugriff! {{ isMaster }}
  16. </v-row>
  17. <v-row v-else>
  18. <v-col
  19. cols="6"
  20. >
  21. <v-text-field
  22. v-model="data.givenName"
  23. label="Vorname"
  24. />
  25. </v-col>
  26. <v-col
  27. cols="6"
  28. >
  29. <v-text-field
  30. v-model="data.familyName"
  31. label="Nachname"
  32. />
  33. </v-col>
  34. <v-col
  35. cols="12"
  36. >
  37. <v-text-field
  38. v-model="data.email"
  39. label="E-Mail-Adresse"
  40. />
  41. </v-col>
  42. <v-col
  43. cols="12"
  44. >
  45. <v-checkbox
  46. v-model="data.master"
  47. label="System-Administrator"
  48. />
  49. </v-col>
  50. <v-col
  51. cols="6"
  52. >
  53. <h3>Administrator von:</h3>
  54. {{ adminOf }}
  55. </v-col>
  56. <v-col
  57. cols="6"
  58. >
  59. <h3>Veranstalter von:</h3>
  60. {{ organizerOf }}
  61. </v-col>
  62. </v-row>
  63. </base-material-dialog>
  64. </template>
  65. <script>
  66. import { useAuth } from '@/plugins/auth'
  67. import { useEditDialog } from '@/plugins/editdialog'
  68. export default {
  69. name: 'EditPerson',
  70. props: {
  71. value: {
  72. type: Boolean,
  73. required: true
  74. },
  75. id: {
  76. type: String,
  77. default: null
  78. }
  79. },
  80. setup (props, context) {
  81. return {
  82. ...useAuth(context),
  83. ...useEditDialog(props, context, 'Person(id: $id) { _id givenName familyName email master adminOf { name plz ort } organizerOf { name plz ort } }', ['givenName', 'familyName', 'email', 'master'])
  84. }
  85. },
  86. computed: {
  87. adminOf () {
  88. return this.data.adminOf?.map(e => e.name + ' (' + e.plz + ' ' + e.ort + ')')?.join('<br>')
  89. },
  90. organizerOf () {
  91. return this.data.organizerOf?.map(e => e.name + ' (' + e.plz + ' ' + e.ort + ')')?.join('<br>')
  92. }
  93. },
  94. methods: {
  95. update () {
  96. return {
  97. mutation: `mutation($id: UUID!, $givenName: String, $familyName: String, $email: EmailAddress, $master: Boolean) {
  98. PersonUpdate(id: $id, givenName: $givenName, familyName: $familyName, email: $email, master: $master) {
  99. _id givenName familyName email master
  100. }
  101. }`,
  102. variables: {
  103. master: !!this.data.master
  104. }
  105. }
  106. },
  107. create () {
  108. return {
  109. mutation: `mutation($givenName: String!, $familyName: String!, $email: EmailAddress!, $master: Boolean) {
  110. PersonCreate(givenName: $givenName, familyName: $familyName, email: $email, master: $master) {
  111. _id givenName familyName email master
  112. }
  113. }`,
  114. variables: {
  115. master: !!this.data.master
  116. }
  117. }
  118. }
  119. }
  120. }
  121. </script>
  122. <style lang="sass">
  123. $dialog-elevation: 0
  124. </style>