PageActionsCol.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template lang="pug">
  2. .page-actions.column.items-stretch.order-last(:class='editorStore.isActive ? `is-editor` : ``')
  3. q-btn.q-py-md(
  4. flat
  5. icon='las la-pen-nib'
  6. :color='editorStore.isActive ? `white` : `deep-orange-9`'
  7. aria-label='Page Properties'
  8. @click='togglePageProperties'
  9. )
  10. q-tooltip(anchor='center left' self='center right') Page Properties
  11. q-btn.q-py-md(
  12. flat
  13. icon='las la-project-diagram'
  14. :color='editorStore.isActive ? `white` : `deep-orange-9`'
  15. aria-label='Page Data'
  16. @click='togglePageData'
  17. disable
  18. v-if='flagsStore.experimental'
  19. )
  20. q-tooltip(anchor='center left' self='center right') Page Data
  21. template(v-if='!(editorStore.isActive && editorStore.mode === `create`)')
  22. q-separator.q-my-sm(inset)
  23. q-btn.q-py-sm(
  24. flat
  25. icon='las la-ellipsis-h'
  26. :color='editorStore.isActive ? `deep-orange-2` : `grey`'
  27. aria-label='Page Actions'
  28. )
  29. q-tooltip(anchor='center left' self='center right') Page Actions
  30. q-menu(
  31. anchor='top left'
  32. self='top right'
  33. auto-close
  34. transition-show='jump-left'
  35. )
  36. q-list(padding, style='min-width: 225px;')
  37. q-item(clickable)
  38. q-item-section.items-center(avatar)
  39. q-icon(color='deep-orange-9', name='las la-history', size='sm')
  40. q-item-section
  41. q-item-label View History
  42. q-item(clickable)
  43. q-item-section.items-center(avatar)
  44. q-icon(color='deep-orange-9', name='las la-code', size='sm')
  45. q-item-section
  46. q-item-label View Source
  47. q-item(clickable)
  48. q-item-section.items-center(avatar)
  49. q-icon(color='deep-orange-9', name='las la-atom', size='sm')
  50. q-item-section
  51. q-item-label Convert Page
  52. q-item(clickable)
  53. q-item-section.items-center(avatar)
  54. q-icon(color='deep-orange-9', name='las la-magic', size='sm')
  55. q-item-section
  56. q-item-label Re-render Page
  57. q-item(clickable)
  58. q-item-section.items-center(avatar)
  59. q-icon(color='deep-orange-9', name='las la-sun', size='sm')
  60. q-item-section
  61. q-item-label View Backlinks
  62. q-space
  63. template(v-if='!(editorStore.isActive && editorStore.mode === `create`)')
  64. q-btn.q-py-sm(
  65. flat
  66. icon='las la-copy'
  67. :color='editorStore.isActive ? `deep-orange-2` : `grey`'
  68. aria-label='Duplicate Page'
  69. @click='duplicatePage'
  70. )
  71. q-tooltip(anchor='center left' self='center right') Duplicate Page
  72. q-btn.q-py-sm(
  73. flat
  74. icon='las la-share'
  75. :color='editorStore.isActive ? `deep-orange-2` : `grey`'
  76. aria-label='Rename / Move Page'
  77. @click='renamePage'
  78. )
  79. q-tooltip(anchor='center left' self='center right') Rename / Move Page
  80. q-btn.q-py-sm(
  81. flat
  82. icon='las la-trash'
  83. :color='editorStore.isActive ? `deep-orange-2` : `grey`'
  84. aria-label='Delete Page'
  85. @click='deletePage'
  86. :class='editorStore.isActive ? `q-pb-md` : ``'
  87. )
  88. q-tooltip(anchor='center left' self='center right') Delete Page
  89. span.page-actions-mode(v-else) {{ t('common.actions.newPage') }}
  90. </template>
  91. <script setup>
  92. import { useQuasar } from 'quasar'
  93. import { computed, defineAsyncComponent, onMounted, reactive, ref, watch } from 'vue'
  94. import { useRouter, useRoute } from 'vue-router'
  95. import { useI18n } from 'vue-i18n'
  96. import { useEditorStore } from 'src/stores/editor'
  97. import { useFlagsStore } from 'src/stores/flags'
  98. import { usePageStore } from 'src/stores/page'
  99. import { useSiteStore } from 'src/stores/site'
  100. // QUASAR
  101. const $q = useQuasar()
  102. // STORES
  103. const editorStore = useEditorStore()
  104. const flagsStore = useFlagsStore()
  105. const pageStore = usePageStore()
  106. const siteStore = useSiteStore()
  107. // ROUTER
  108. const router = useRouter()
  109. const route = useRoute()
  110. // I18N
  111. const { t } = useI18n()
  112. // METHODS
  113. function togglePageProperties () {
  114. siteStore.$patch({
  115. sideDialogComponent: 'PagePropertiesDialog',
  116. sideDialogShown: true
  117. })
  118. }
  119. function togglePageData () {
  120. siteStore.$patch({
  121. sideDialogComponent: 'PageDataDialog',
  122. sideDialogShown: true
  123. })
  124. }
  125. function duplicatePage () {
  126. $q.dialog({
  127. component: defineAsyncComponent(() => import('../components/TreeBrowserDialog.vue')),
  128. componentProps: {
  129. mode: 'duplicatePage',
  130. folderPath: '',
  131. itemId: pageStore.id,
  132. itemTitle: pageStore.title,
  133. itemFileName: pageStore.path
  134. }
  135. }).onOk(() => {
  136. // TODO: change route to new location
  137. })
  138. }
  139. function renamePage () {
  140. $q.dialog({
  141. component: defineAsyncComponent(() => import('../components/TreeBrowserDialog.vue')),
  142. componentProps: {
  143. mode: 'renamePage',
  144. folderPath: '',
  145. itemId: pageStore.id,
  146. itemTitle: pageStore.title,
  147. itemFileName: pageStore.path
  148. }
  149. }).onOk(() => {
  150. // TODO: change route to new location
  151. })
  152. }
  153. function deletePage () {
  154. $q.dialog({
  155. component: defineAsyncComponent(() => import('../components/PageDeleteDialog.vue')),
  156. componentProps: {
  157. pageId: pageStore.id,
  158. pageName: pageStore.title
  159. }
  160. }).onOk(() => {
  161. router.replace('/')
  162. })
  163. }
  164. </script>
  165. <style lang="scss">
  166. .page-actions {
  167. flex: 0 0 56px;
  168. @at-root .body--light & {
  169. background-color: $grey-3;
  170. }
  171. @at-root .body--dark & {
  172. background-color: $dark-4;
  173. }
  174. &.is-editor {
  175. @at-root .body--light & {
  176. background-color: $deep-orange-9;
  177. }
  178. @at-root .body--dark & {
  179. background-color: $deep-orange-9;
  180. }
  181. }
  182. &-mode {
  183. writing-mode: vertical-rl;
  184. text-orientation: mixed;
  185. padding: 1.75rem 1rem 1.75rem 0;
  186. color: $deep-orange-3;
  187. font-weight: 500;
  188. }
  189. }
  190. </style>