admin-pages-edit.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template lang='pug'>
  2. v-container(fluid, grid-list-lg)
  3. v-layout(row, wrap, v-if='page.id')
  4. v-flex(xs12)
  5. .admin-header
  6. img.animated.fadeInUp(src='/svg/icon-view-details.svg', alt='Edit Page', style='width: 80px;')
  7. .admin-header-title
  8. .headline.blue--text.text--darken-2.animated.fadeInLeft Page Details
  9. .subheading.grey--text.animated.fadeInLeft.wait-p2s
  10. v-chip.ml-0.mr-2(label, small).caption ID {{page.id}}
  11. span /{{page.locale}}/{{page.path}}
  12. v-spacer
  13. template(v-if='page.isPublished')
  14. status-indicator.mr-3(positive, pulse)
  15. .caption.green--text {{$t('common:page.published')}}
  16. template(v-else)
  17. status-indicator.mr-3(negative, pulse)
  18. .caption.red--text {{$t('common:page.unpublished')}}
  19. template(v-if='page.isPrivate')
  20. status-indicator.mr-3.ml-4(intermediary, pulse)
  21. .caption.deep-orange--text {{$t('common:page.private')}}
  22. template(v-else)
  23. status-indicator.mr-3.ml-4(active, pulse)
  24. .caption.blue--text {{$t('common:page.global')}}
  25. v-spacer
  26. v-btn.animated.fadeInRight.wait-p4s(color='grey', large, outline, to='/pages')
  27. v-icon arrow_back
  28. v-divider.animated.fadeInRight.wait-p3s.mx-3(vertical)
  29. v-dialog(v-model='deletePageDialog', max-width='500')
  30. v-btn.animated.fadeInDown.wait-p1s(color='red', large, outline, slot='activator')
  31. v-icon(color='red') delete
  32. v-card.wiki-form
  33. .dialog-header.is-short.is-red
  34. v-icon.mr-2(color='white') highlight_off
  35. span {{$t('common:page.delete')}}
  36. v-card-text
  37. i18next.body-2(path='common:page.deleteTitle', tag='div')
  38. span.red--text.text--darken-2(place='title') {{page.title}}
  39. .caption {{$t('common:page.deleteSubtitle')}}
  40. v-chip.mt-3.ml-0.mr-1(label, color='red lighten-4', disabled, small)
  41. .caption.red--text.text--darken-2 {{page.locale.toUpperCase()}}
  42. v-chip.mt-3.mx-0(label, color='red lighten-5', disabled, small)
  43. span.red--text.text--darken-2 /{{page.path}}
  44. v-card-chin
  45. v-spacer
  46. v-btn(flat, @click='deletePageDialog = false', :disabled='loading') {{$t('common:actions.cancel')}}
  47. v-btn(color='red darken-2', @click='deletePage', :loading='loading').white--text {{$t('common:actions.delete')}}
  48. v-btn.animated.fadeInDown(color='teal', large, outline, @click='rerenderPage')
  49. v-icon(left) system_update_alt
  50. span Re-render
  51. v-flex(xs12, lg6)
  52. v-card.animated.fadeInUp
  53. v-toolbar(color='primary', dense, dark, flat)
  54. v-icon.mr-2 subject
  55. span Properties
  56. v-list.py-0(two-line, dense)
  57. v-list-item
  58. v-list-item-content
  59. v-list-item-title.caption.grey--text Title
  60. v-list-item-sub-title.body-2.grey--text.text--darken-3 {{ page.title }}
  61. v-divider
  62. v-list-item
  63. v-list-item-content
  64. v-list-item-title.caption.grey--text Description
  65. v-list-item-sub-title.body-2.grey--text.text--darken-3 {{ page.description || '-' }}
  66. v-divider
  67. v-list-item
  68. v-list-item-content
  69. v-list-item-title.caption.grey--text Locale
  70. v-list-item-sub-title.body-2.grey--text.text--darken-3 {{ page.locale }}
  71. v-list-item-action
  72. v-btn(icon)
  73. v-icon(color='grey') edit
  74. v-divider
  75. v-list-item
  76. v-list-item-content
  77. v-list-item-title.caption.grey--text Path
  78. v-list-item-sub-title.body-2.grey--text.text--darken-3 {{ page.path }}
  79. v-list-item-action
  80. v-btn(icon)
  81. v-icon(color='grey') edit
  82. v-divider
  83. v-list-item
  84. v-list-item-content
  85. v-list-item-title.caption.grey--text Editor
  86. v-list-item-sub-title.body-2.grey--text.text--darken-3 {{ page.editor || '?' }}
  87. v-divider
  88. v-list-item
  89. v-list-item-content
  90. v-list-item-title.caption.grey--text Content Type
  91. v-list-item-sub-title.body-2.grey--text.text--darken-3 {{ page.contentType || '?' }}
  92. v-toolbar.elevation-2.mt-3.animated.fadeInUp.wait-p4s(color='white', dense)
  93. v-spacer
  94. v-btn(color='primary', flat, :href='`/` + page.locale + `/` + page.path')
  95. v-icon(left) subject
  96. span View
  97. v-divider(vertical)
  98. v-btn(color='primary', flat, :href='`/e/` + page.locale + `/` + page.path')
  99. v-icon(left) edit
  100. span Edit
  101. v-divider(vertical)
  102. v-btn(color='primary', flat, :href='`/s/` + page.locale + `/` + page.path')
  103. v-icon(left) code
  104. span Source
  105. v-divider(vertical)
  106. v-btn(color='primary', flat, :href='`/h/` + page.locale + `/` + page.path')
  107. v-icon(left) history
  108. span History
  109. v-spacer
  110. .caption.mt-4.grey--text.animated.fadeInUp.wait-p6s Page Hash: {{ page.hash }}
  111. v-flex(xs12, lg6)
  112. v-card.animated.fadeInUp.wait-p2s
  113. v-toolbar(color='primary', dense, dark, flat)
  114. v-icon.mr-2 people
  115. span Users
  116. v-list.py-0(two-line, dense)
  117. v-list-item
  118. v-list-item-avatar
  119. v-btn(icon, :to='`/users/` + page.creatorId')
  120. v-icon(color='grey') person
  121. v-list-item-content
  122. v-list-item-title.caption.grey--text Creator
  123. v-list-item-sub-title.body-2.grey--text.text--darken-3 {{ page.creatorName }} #[em.caption ({{ page.creatorEmail }})]
  124. v-list-item-action
  125. v-list-item-action-text {{ page.createdAt | moment('calendar') }}
  126. v-divider
  127. v-list-item
  128. v-list-item-avatar
  129. v-btn(icon, :to='`/users/` + page.authorId')
  130. v-icon(color='grey') person
  131. v-list-item-content
  132. v-list-item-title.caption.grey--text Last Editor
  133. v-list-item-sub-title.body-2.grey--text.text--darken-3 {{ page.authorName }} #[em.caption ({{ page.authorEmail }})]
  134. v-list-item-action
  135. v-list-item-action-text {{ page.updatedAt | moment('calendar') }}
  136. v-card.mt-3.animated.fadeInUp.wait-p4s
  137. v-toolbar(color='primary', dense, dark, flat)
  138. v-icon.mr-2 history
  139. span Recent History
  140. v-spacer
  141. v-chip(label, color='white', small).primary--text coming soon
  142. v-timeline.mx-3(dense, clipped)
  143. v-timeline-item(color='teal', small, v-if='page.createdAt !== page.updatedAt')
  144. v-layout(justify-space-between)
  145. v-flex(xs7) Page Modified by #[strong {{ page.authorName }}] #[em.caption ({{ page.authorEmail }})]
  146. v-flex.text-xs-right(xs5).caption.grey--text.text-darken-2 {{ page.updatedAt | moment('calendar') }}
  147. v-timeline-item(hide-dot, small)
  148. .body-1 ...
  149. v-btn.mx-0(outline, color='grey', :href='`/h/` + page.locale + `/` + page.path') View Full History
  150. .body-1 ...
  151. v-timeline-item(color='pink', small)
  152. v-layout(justify-space-between)
  153. v-flex(xs7) Page created by #[strong {{ page.creatorName }}] #[em.caption ({{ page.creatorEmail }})]
  154. v-flex.text-xs-right(xs5).caption.grey--text.text-darken-2 {{ page.createdAt | moment('calendar') }}
  155. v-layout(row, align-center, v-else)
  156. v-progress-circular(indeterminate, width='2', color='grey')
  157. .body-2.pl-3.grey--text {{ $t('common:page.loading') }}
  158. </template>
  159. <script>
  160. import _ from 'lodash'
  161. import { StatusIndicator } from 'vue-status-indicator'
  162. import pageQuery from 'gql/admin/pages/pages-query-single.gql'
  163. import deletePageMutation from 'gql/common/common-pages-mutation-delete.gql'
  164. export default {
  165. components: {
  166. StatusIndicator
  167. },
  168. data() {
  169. return {
  170. deletePageDialog: false,
  171. page: {},
  172. loading: false
  173. }
  174. },
  175. methods: {
  176. async deletePage() {
  177. this.loading = true
  178. this.$store.commit(`loadingStart`, 'page-delete')
  179. try {
  180. const resp = await this.$apollo.mutate({
  181. mutation: deletePageMutation,
  182. variables: {
  183. id: this.page.id
  184. }
  185. })
  186. if (_.get(resp, 'data.pages.delete.responseResult.succeeded', false)) {
  187. this.$store.commit('showNotification', {
  188. style: 'green',
  189. message: `Page deleted successfully.`,
  190. icon: 'check'
  191. })
  192. this.$router.replace('/pages')
  193. } else {
  194. throw new Error(_.get(resp, 'data.pages.delete.responseResult.message', this.$t('common:error.unexpected')))
  195. }
  196. } catch (err) {
  197. this.$store.commit('pushGraphError', err)
  198. }
  199. this.$store.commit(`loadingStop`, 'page-delete')
  200. },
  201. async rerenderPage() {
  202. this.$store.commit('showNotification', {
  203. style: 'indigo',
  204. message: `Coming soon...`,
  205. icon: 'directions_boat'
  206. })
  207. }
  208. },
  209. apollo: {
  210. page: {
  211. query: pageQuery,
  212. variables() {
  213. return {
  214. id: _.toSafeInteger(this.$route.params.id)
  215. }
  216. },
  217. fetchPolicy: 'network-only',
  218. update: (data) => data.pages.single,
  219. watchLoading (isLoading) {
  220. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-pages-refresh')
  221. }
  222. }
  223. }
  224. }
  225. </script>
  226. <style lang='scss'>
  227. </style>