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.

358 lines
12 KiB

6 years ago
5 years ago
5 years ago
6 years ago
  1. <template lang='pug'>
  2. v-dialog(
  3. v-model='isShown'
  4. persistent
  5. width='1000'
  6. :fullscreen='$vuetify.breakpoint.smAndDown'
  7. )
  8. .dialog-header
  9. v-icon(color='white') mdi-tag-text-outline
  10. .subtitle-1.white--text.ml-3 {{$t('editor:props.pageProperties')}}
  11. v-spacer
  12. v-btn.mx-0(
  13. outlined
  14. dark
  15. @click.native='close'
  16. )
  17. v-icon(left) mdi-check
  18. span {{ $t('common:actions.ok') }}
  19. v-card(tile)
  20. v-tabs(color='white', background-color='blue darken-1', dark, centered)
  21. v-tab {{$t('editor:props.info')}}
  22. v-tab {{$t('editor:props.scheduling')}}
  23. v-tab(disabled) {{$t('editor:props.scripts')}}
  24. v-tab {{$t('editor:props.social')}}
  25. v-tab-item
  26. v-card-text.pt-5
  27. .overline.pb-5 {{$t('editor:props.pageInfo')}}
  28. v-text-field(
  29. ref='iptTitle'
  30. outlined
  31. :label='$t(`editor:props.title`)'
  32. counter='255'
  33. v-model='title'
  34. )
  35. v-text-field(
  36. outlined
  37. :label='$t(`editor:props.shortDescription`)'
  38. counter='255'
  39. v-model='description'
  40. persistent-hint
  41. :hint='$t(`editor:props.shortDescriptionHint`)'
  42. )
  43. v-divider
  44. v-card-text.grey.pt-5(:class='darkMode ? `darken-3-d3` : `lighten-5`')
  45. .overline.pb-5 {{$t('editor:props.path')}}
  46. v-container.pa-0(fluid, grid-list-lg)
  47. v-layout(row, wrap)
  48. v-flex(xs12, md2)
  49. v-select(
  50. outlined
  51. :label='$t(`editor:props.locale`)'
  52. suffix='/'
  53. :items='namespaces'
  54. v-model='locale'
  55. hide-details
  56. )
  57. v-flex(xs12, md10)
  58. v-text-field(
  59. outlined
  60. :label='$t(`editor:props.path`)'
  61. append-icon='mdi-folder-search'
  62. v-model='path'
  63. :hint='$t(`editor:props.pathHint`)'
  64. persistent-hint
  65. @click:append='showPathSelector'
  66. )
  67. v-divider
  68. v-card-text.grey.pt-5(:class='darkMode ? `darken-3-d5` : `lighten-4`')
  69. .overline.pb-5 {{$t('editor:props.categorization')}}
  70. v-chip-group.radius-5.mb-5(column, v-if='tags && tags.length > 0')
  71. v-chip(
  72. v-for='tag of tags'
  73. :key='`tag-` + tag'
  74. close
  75. label
  76. color='teal'
  77. text-color='teal lighten-5'
  78. @click:close='removeTag(tag)'
  79. ) {{tag}}
  80. v-combobox(
  81. :label='$t(`editor:props.tags`)'
  82. outlined
  83. v-model='tags'
  84. :hint='$t(`editor:props.tagsHint`)'
  85. :items='newTagSuggestions'
  86. :loading='$apollo.queries.newTagSuggestions.loading'
  87. persistent-hint
  88. deletable-chips
  89. hide-no-data
  90. hide-selected
  91. :search-input.sync='newTagSearch'
  92. multiple
  93. )
  94. template(v-slot:selection='{ attrs, item, parent, selected }')
  95. span
  96. v-tab-item
  97. v-card-text
  98. .overline.pb-5 {{$t('editor:props.publishState')}} #[v-chip.ml-3(label, color='grey', small, outlined).white--text coming soon]
  99. v-switch(
  100. :label='$t(`editor:props.publishToggle`)'
  101. v-model='isPublished'
  102. color='primary'
  103. :hint='$t(`editor:props.publishToggleHint`)'
  104. persistent-hint
  105. disabled
  106. inset
  107. )
  108. v-divider
  109. v-card-text.grey.pt-5(:class='darkMode ? `darken-3-d3` : `lighten-5`')
  110. v-container.pa-0(fluid, grid-list-lg)
  111. v-row
  112. v-col(cols='6')
  113. v-dialog(
  114. ref='menuPublishStart'
  115. :close-on-content-click='false'
  116. v-model='isPublishStartShown'
  117. :return-value.sync='publishStartDate'
  118. width='460px'
  119. :disabled='!isPublished || true'
  120. )
  121. template(v-slot:activator='{ on }')
  122. v-text-field(
  123. v-on='on'
  124. :label='$t(`editor:props.publishStart`)'
  125. v-model='publishStartDate'
  126. prepend-icon='mdi-calendar-check'
  127. readonly
  128. outlined
  129. clearable
  130. :hint='$t(`editor:props.publishStartHint`)'
  131. persistent-hint
  132. :disabled='!isPublished || true'
  133. )
  134. v-date-picker(
  135. v-model='publishStartDate'
  136. :min='(new Date()).toISOString().substring(0, 10)'
  137. color='primary'
  138. reactive
  139. scrollable
  140. landscape
  141. )
  142. v-spacer
  143. v-btn(
  144. flat=''
  145. color='primary'
  146. @click='isPublishStartShown = false'
  147. ) {{$t('common:actions.cancel')}}
  148. v-btn(
  149. flat=''
  150. color='primary'
  151. @click='$refs.menuPublishStart.save(publishStartDate)'
  152. ) {{$t('common:actions.ok')}}
  153. v-col(cols='6')
  154. v-dialog(
  155. ref='menuPublishEnd'
  156. :close-on-content-click='false'
  157. v-model='isPublishEndShown'
  158. :return-value.sync='publishEndDate'
  159. width='460px'
  160. :disabled='!isPublished || true'
  161. )
  162. template(v-slot:activator='{ on }')
  163. v-text-field(
  164. v-on='on'
  165. :label='$t(`editor:props.publishEnd`)'
  166. v-model='publishEndDate'
  167. prepend-icon='mdi-calendar-remove'
  168. readonly
  169. outlined
  170. clearable
  171. :hint='$t(`editor:props.publishEndHint`)'
  172. persistent-hint
  173. :disabled='!isPublished || true'
  174. )
  175. v-date-picker(
  176. v-model='publishEndDate'
  177. :min='(new Date()).toISOString().substring(0, 10)'
  178. color='primary'
  179. reactive
  180. scrollable
  181. landscape
  182. )
  183. v-spacer
  184. v-btn(
  185. flat=''
  186. color='primary'
  187. @click='isPublishEndShown = false'
  188. ) {{$t('common:actions.cancel')}}
  189. v-btn(
  190. flat=''
  191. color='primary'
  192. @click='$refs.menuPublishEnd.save(publishEndDate)'
  193. ) {{$t('common:actions.ok')}}
  194. v-tab-item
  195. v-card-text
  196. .overline.pb-3 {{$t('editor:props.js')}}
  197. v-textarea(
  198. outlined
  199. rows='5'
  200. :hint='$t(`editor:props.jsHint`)'
  201. persistent-hint
  202. )
  203. v-divider
  204. v-card-text.grey.pt-5(:class='darkMode ? `darken-3-d3` : `lighten-5`')
  205. .overline.pb-3 {{$t('editor:props.css')}}
  206. v-textarea(
  207. outlined
  208. rows='5'
  209. :hint='$t(`editor:props.cssHint`)'
  210. persistent-hint
  211. )
  212. v-tab-item
  213. v-card-text
  214. .overline.pb-5 {{$t('editor:props.socialFeatures')}} #[v-chip.ml-3(label, color='grey', small, outlined).white--text coming soon]
  215. v-switch(
  216. :label='$t(`editor:props.allowComments`)'
  217. v-model='isPublished'
  218. color='primary'
  219. :hint='$t(`editor:props.allowCommentsHint`)'
  220. persistent-hint
  221. disabled
  222. inset
  223. )
  224. v-switch(
  225. :label='$t(`editor:props.allowRatings`)'
  226. v-model='isPublished'
  227. color='primary'
  228. :hint='$t(`editor:props.allowRatingsHint`)'
  229. persistent-hint
  230. disabled
  231. inset
  232. )
  233. v-switch(
  234. :label='$t(`editor:props.displayAuthor`)'
  235. v-model='isPublished'
  236. color='primary'
  237. :hint='$t(`editor:props.displayAuthorHint`)'
  238. persistent-hint
  239. disabled
  240. inset
  241. )
  242. v-switch(
  243. :label='$t(`editor:props.displaySharingBar`)'
  244. v-model='isPublished'
  245. color='primary'
  246. :hint='$t(`editor:props.displaySharingBarHint`)'
  247. persistent-hint
  248. disabled
  249. inset
  250. )
  251. page-selector(:mode='pageSelectorMode', v-model='pageSelectorShown', :path='path', :locale='locale', :open-handler='setPath')
  252. </template>
  253. <script>
  254. import _ from 'lodash'
  255. import { sync, get } from 'vuex-pathify'
  256. import gql from 'graphql-tag'
  257. /* global siteLangs, siteConfig */
  258. export default {
  259. props: {
  260. value: {
  261. type: Boolean,
  262. default: false
  263. }
  264. },
  265. data() {
  266. return {
  267. isPublishStartShown: false,
  268. isPublishEndShown: false,
  269. pageSelectorShown: false,
  270. namespaces: siteLangs.length ? siteLangs.map(ns => ns.code) : [siteConfig.lang],
  271. newTag: '',
  272. newTagSuggestions: [],
  273. newTagSearch: ''
  274. }
  275. },
  276. computed: {
  277. isShown: {
  278. get() { return this.value },
  279. set(val) { this.$emit('input', val) }
  280. },
  281. darkMode: get('site/dark'),
  282. mode: get('editor/mode'),
  283. title: sync('page/title'),
  284. description: sync('page/description'),
  285. locale: sync('page/locale'),
  286. tags: sync('page/tags'),
  287. path: sync('page/path'),
  288. isPublished: sync('page/isPublished'),
  289. publishStartDate: sync('page/publishStartDate'),
  290. publishEndDate: sync('page/publishEndDate'),
  291. pageSelectorMode () {
  292. return (this.mode === 'create') ? 'create' : 'move'
  293. }
  294. },
  295. watch: {
  296. value(newValue, oldValue) {
  297. if (newValue) {
  298. _.delay(() => {
  299. this.$refs.iptTitle.focus()
  300. // this.$tours['editorPropertiesTour'].start()
  301. }, 500)
  302. }
  303. }
  304. },
  305. methods: {
  306. addTag () {
  307. this.$nextTick(() => {
  308. this.tags.push(this.newTag)
  309. })
  310. },
  311. removeTag (tag) {
  312. this.tags = _.without(this.tags, tag)
  313. },
  314. close() {
  315. this.isShown = false
  316. },
  317. showPathSelector() {
  318. this.pageSelectorShown = true
  319. },
  320. setPath({ path, locale }) {
  321. this.locale = locale
  322. this.path = path
  323. }
  324. },
  325. apollo: {
  326. newTagSuggestions: {
  327. query: gql`
  328. query ($query: String!) {
  329. pages {
  330. searchTags (query: $query)
  331. }
  332. }
  333. `,
  334. variables () {
  335. return {
  336. query: this.newTagSearch
  337. }
  338. },
  339. fetchPolicy: 'cache-first',
  340. update: (data) => _.get(data, 'pages.searchTags', []),
  341. skip () {
  342. return !this.value || _.isEmpty(this.newTagSearch)
  343. },
  344. throttle: 500
  345. }
  346. }
  347. }
  348. </script>
  349. <style lang='scss'>
  350. </style>