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.

118 lines
3.2 KiB

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