PageDataDialog.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template lang="pug">
  2. q-card.page-data-dialog(style='width: 750px;')
  3. q-toolbar.bg-primary.text-white.flex
  4. .text-subtitle2 {{t('editor.pageData.title')}}
  5. q-space
  6. q-btn(
  7. icon='las la-times'
  8. dense
  9. flat
  10. v-close-popup
  11. )
  12. q-card-section.page-data-dialog-selector
  13. //- .text-overline.text-white {{t('editor.pageData.template')}}
  14. .flex.q-gutter-sm
  15. q-select(
  16. dark
  17. v-model='state.templateId'
  18. :label='t(`editor.pageData.template`)'
  19. :aria-label='t(`editor.pageData.template`)'
  20. :options='templates'
  21. option-value='id'
  22. map-options
  23. emit-value
  24. standout
  25. dense
  26. style='flex: 1 0 auto;'
  27. )
  28. q-btn.acrylic-btn(
  29. dark
  30. icon='las la-pen'
  31. :label='t(`common.actions.manage`)'
  32. unelevated
  33. no-caps
  34. color='deep-orange-9'
  35. @click='editTemplates'
  36. )
  37. q-tabs.alt-card(
  38. v-model='state.mode'
  39. inline-label
  40. no-caps
  41. )
  42. q-tab(
  43. name='visual'
  44. label='Visual'
  45. )
  46. q-tab(
  47. name='code'
  48. label='YAML'
  49. )
  50. q-scroll-area(
  51. :thumb-style='siteStore.thumbStyle'
  52. :bar-style='siteStore.barStyle'
  53. style='height: calc(100% - 50px - 75px - 48px);'
  54. )
  55. q-card-section(v-if='state.mode === `visual`')
  56. .q-gutter-sm
  57. q-input(
  58. label='Attribute Text'
  59. dense
  60. outlined
  61. )
  62. template(v-slot:before)
  63. q-icon(name='las la-font', color='primary')
  64. q-input(
  65. label='Attribute Number'
  66. dense
  67. outlined
  68. type='number'
  69. )
  70. template(v-slot:before)
  71. q-icon(name='las la-infinity', color='primary')
  72. .q-py-xs
  73. q-checkbox(
  74. label='Attribute Boolean'
  75. color='primary'
  76. dense
  77. size='lg'
  78. )
  79. q-no-ssr(v-else, :placeholder='t(`common.loading`)')
  80. codemirror.admin-theme-cm(
  81. ref='cmData'
  82. v-model='state.content'
  83. :options='{ mode: `text/yaml` }'
  84. )
  85. q-dialog(
  86. v-model='state.showDataTemplateDialog'
  87. )
  88. page-data-template-dialog
  89. </template>
  90. <script setup>
  91. import { useI18n } from 'vue-i18n'
  92. import { useQuasar } from 'quasar'
  93. import { nextTick, onMounted, reactive, ref, watch } from 'vue'
  94. import PageDataTemplateDialog from './PageDataTemplateDialog.vue'
  95. import { usePageStore } from 'src/stores/page'
  96. import { useSiteStore } from 'src/stores/site'
  97. // QUASAR
  98. const $q = useQuasar()
  99. // STORES
  100. const pageStore = usePageStore()
  101. const siteStore = useSiteStore()
  102. // I18N
  103. const { t } = useI18n()
  104. // DATA
  105. const state = reactive({
  106. showDataTemplateDialog: false,
  107. templateId: '',
  108. content: '',
  109. mode: 'visual'
  110. })
  111. const templates = [
  112. {
  113. id: '',
  114. label: 'None',
  115. data: []
  116. },
  117. ...siteStore.pageDataTemplates,
  118. {
  119. id: 'basic',
  120. label: 'Basic',
  121. data: []
  122. }
  123. ]
  124. // METHODS
  125. function editTemplates () {
  126. state.showDataTemplateDialog = !state.showDataTemplateDialog
  127. }
  128. </script>
  129. <style lang="scss">
  130. .page-data-dialog {
  131. &-selector {
  132. @at-root .body--light & {
  133. background-color: $dark-3;
  134. box-shadow: inset 0px 1px 0 0 rgba(0,0,0,.75), inset 0px -1px 0 0 rgba(0,0,0,.75), 0 -1px 0 0 rgba(255,255,255,.1);
  135. border-bottom: 1px solid #FFF;
  136. }
  137. @at-root .body--dark & {
  138. background-color: $dark-4;
  139. box-shadow: inset 0px 1px 0 0 rgba(0,0,0, 0.75), inset 0px -1px 0 0 rgba(0,0,0,.75), 0 -1px 0 0 rgba(255,255,255,.1);
  140. border-bottom: 1px solid lighten($dark-3, 10%);
  141. }
  142. }
  143. }
  144. </style>