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
4.1 KiB

  1. <template lang='pug'>
  2. v-container(fluid, grid-list-lg)
  3. v-layout(row wrap)
  4. v-flex(xs12)
  5. .admin-header
  6. img(src='/svg/icon-file.svg', alt='Page', style='width: 80px;')
  7. .admin-header-title
  8. .headline.blue--text.text--darken-2 Pages
  9. .subheading.grey--text Manage pages #[v-chip(label, color='primary', small).white--text coming soon]
  10. v-spacer
  11. v-btn(color='grey', outline, @click='refresh', large)
  12. v-icon.grey--text refresh
  13. v-btn(color='primary', depressed, large, @click='newpage', disabled)
  14. v-icon(left) add
  15. span New Page
  16. v-card.wiki-form.mt-3
  17. v-toolbar(flat, :color='$vuetify.dark ? `grey darken-3-d5` : `white`', height='80')
  18. v-spacer
  19. v-text-field(
  20. outline
  21. v-model='search'
  22. append-icon='search'
  23. label='Search Pages...'
  24. single-line
  25. hide-details
  26. )
  27. v-select.ml-2(
  28. outline
  29. hide-details
  30. single-line
  31. label='Locale'
  32. )
  33. v-select.ml-2(
  34. outline
  35. hide-details
  36. single-line
  37. label='Publish State'
  38. )
  39. v-spacer
  40. v-divider
  41. v-data-table(
  42. :items='pages'
  43. :headers='headers'
  44. :search='search'
  45. :pagination.sync='pagination'
  46. :rows-per-page-items='[15]'
  47. :loading='loading'
  48. must-sort,
  49. hide-actions
  50. )
  51. template(slot='items', slot-scope='props')
  52. tr.is-clickable(:active='props.selected', @click='$router.push(`/pages/` + props.item.id)')
  53. td.text-xs-right {{ props.item.id }}
  54. td
  55. .body-2 {{ props.item.title }}
  56. .caption {{ props.item.description }}
  57. td.admin-pages-path
  58. v-chip(label, small, :color='$vuetify.dark ? `grey darken-4` : `grey lighten-4`') {{ props.item.locale }}
  59. span.ml-2.grey--text(:class='$vuetify.dark ? `text--lighten-1` : `text--darken-2`') {{ props.item.path }}
  60. td {{ props.item.createdAt | moment('calendar') }}
  61. td {{ props.item.updatedAt | moment('calendar') }}
  62. template(slot='no-data')
  63. v-alert.ma-3(icon='warning', :value='true', outline) No pages to display.
  64. .text-xs-center.py-2(v-if='this.pageTotal > 1')
  65. v-pagination(v-model='pagination.page', :length='pageTotal')
  66. </template>
  67. <script>
  68. import pagesQuery from 'gql/admin/pages/pages-query-list.gql'
  69. export default {
  70. data() {
  71. return {
  72. selectedPage: {},
  73. pagination: {},
  74. pages: [],
  75. headers: [
  76. { text: 'ID', value: 'id', width: 50, align: 'right' },
  77. { text: 'Title', value: 'title' },
  78. { text: 'Path', value: 'path' },
  79. { text: 'Created', value: 'createdAt', width: 250 },
  80. { text: 'Last Updated', value: 'updatedAt', width: 250 }
  81. ],
  82. search: '',
  83. loading: false
  84. }
  85. },
  86. computed: {
  87. pageTotal () {
  88. if (this.pagination.rowsPerPage == null || this.pagination.totalItems == null) {
  89. return 0
  90. }
  91. return Math.ceil(this.pages.length / this.pagination.rowsPerPage)
  92. }
  93. },
  94. methods: {
  95. async refresh() {
  96. await this.$apollo.queries.pages.refetch()
  97. this.$store.commit('showNotification', {
  98. message: 'Page list has been refreshed.',
  99. style: 'success',
  100. icon: 'cached'
  101. })
  102. },
  103. newpage() {
  104. this.pageSelectorShown = true
  105. }
  106. },
  107. apollo: {
  108. pages: {
  109. query: pagesQuery,
  110. fetchPolicy: 'network-only',
  111. update: (data) => data.pages.list,
  112. watchLoading (isLoading) {
  113. this.loading = isLoading
  114. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-pages-refresh')
  115. }
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang='scss'>
  121. .admin-pages-path {
  122. display: flex;
  123. justify-content: flex-start;
  124. align-items: center;
  125. font-family: 'Source Sans Pro', sans-serif;
  126. }
  127. </style>