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.

125 lines
3.3 KiB

  1. <template lang='pug'>
  2. v-dialog(
  3. v-model='isShown'
  4. max-width='550'
  5. persistent
  6. overlay-color='red darken-4'
  7. overlay-opacity='.7'
  8. )
  9. v-card
  10. .dialog-header.is-short.is-red
  11. v-icon.mr-2(color='white') mdi-file-document-box-remove-outline
  12. span {{$t('common:page.delete')}}
  13. v-card-text.pt-5
  14. i18next.body-1(path='common:page.deleteTitle', tag='div')
  15. span.red--text.text--darken-2(place='title') {{pageTitle}}
  16. .caption {{$t('common:page.deleteSubtitle')}}
  17. v-chip.mt-3.ml-0.mr-1(label, color='red lighten-4', small)
  18. .caption.red--text.text--darken-2 {{pageLocale.toUpperCase()}}
  19. v-chip.mt-3.mx-0(label, color='red lighten-5', small)
  20. span.red--text.text--darken-2 /{{pagePath}}
  21. v-card-chin
  22. v-spacer
  23. v-btn(text, @click='discard', :disabled='loading') {{$t('common:actions.cancel')}}
  24. v-btn.px-4(color='red darken-2', @click='deletePage', :loading='loading').white--text {{$t('common:actions.delete')}}
  25. </template>
  26. <script>
  27. import _ from 'lodash'
  28. import { get } from 'vuex-pathify'
  29. import deletePageMutation from 'gql/common/common-pages-mutation-delete.gql'
  30. export default {
  31. props: {
  32. value: {
  33. type: Boolean,
  34. default: false
  35. }
  36. },
  37. data() {
  38. return {
  39. loading: false
  40. }
  41. },
  42. computed: {
  43. isShown: {
  44. get() { return this.value },
  45. set(val) { this.$emit('input', val) }
  46. },
  47. pageTitle: get('page/title'),
  48. pagePath: get('page/path'),
  49. pageLocale: get('page/locale'),
  50. pageId: get('page/id')
  51. },
  52. watch: {
  53. isShown(newValue, oldValue) {
  54. if (newValue) {
  55. document.body.classList.add('page-deleted-pending')
  56. }
  57. }
  58. },
  59. methods: {
  60. discard() {
  61. document.body.classList.remove('page-deleted-pending')
  62. this.isShown = false
  63. },
  64. async deletePage() {
  65. this.loading = true
  66. this.$store.commit(`loadingStart`, 'page-delete')
  67. this.$nextTick(async () => {
  68. try {
  69. const resp = await this.$apollo.mutate({
  70. mutation: deletePageMutation,
  71. variables: {
  72. id: this.pageId
  73. }
  74. })
  75. if (_.get(resp, 'data.pages.delete.responseResult.succeeded', false)) {
  76. this.isShown = false
  77. _.delay(() => {
  78. document.body.classList.add('page-deleted')
  79. _.delay(() => {
  80. window.location.assign('/')
  81. }, 1200)
  82. }, 400)
  83. } else {
  84. throw new Error(_.get(resp, 'data.pages.delete.responseResult.message', this.$t('common:error.unexpected')))
  85. }
  86. } catch (err) {
  87. this.$store.commit('pushGraphError', err)
  88. }
  89. this.$store.commit(`loadingStop`, 'page-delete')
  90. this.loading = false
  91. })
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang='scss'>
  97. body.page-deleted-pending {
  98. perspective: 50vw;
  99. height: 100vh;
  100. overflow: hidden;
  101. .application {
  102. background-color: mc('grey', '900');
  103. }
  104. .application--wrap {
  105. transform-style: preserve-3d;
  106. transform: translateZ(-5vw) rotateX(2deg);
  107. border-radius: 7px;
  108. overflow: hidden;
  109. }
  110. }
  111. body.page-deleted {
  112. perspective: 50vw;
  113. .application--wrap {
  114. transform-style: preserve-3d;
  115. transform: translateZ(-1000vw) rotateX(60deg);
  116. opacity: 0;
  117. }
  118. }
  119. </style>