2
0

editor-modal-media.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <template lang='pug'>
  2. v-card.editor-modal-media.animated.fadeInLeft(flat, tile)
  3. v-container.pa-3(grid-list-lg, fluid)
  4. v-layout(row, wrap)
  5. v-flex(xs12, lg9)
  6. v-card.radius-7.animated.fadeInLeft.wait-p1s(:light='!$vuetify.theme.dark', :dark='$vuetify.theme.dark')
  7. v-card-text
  8. .d-flex
  9. v-toolbar.radius-7(:color='$vuetify.theme.dark ? `teal` : `teal lighten-5`', dense, flat, height='44')
  10. .body-2(:class='$vuetify.theme.dark ? `white--text` : `teal--text`') {{$t('editor:assets.title')}}
  11. v-spacer
  12. v-btn(text, icon, @click='refresh')
  13. v-icon(:color='$vuetify.theme.dark ? `white` : `teal`') mdi-refresh
  14. v-dialog(v-model='newFolderDialog', max-width='550')
  15. template(v-slot:activator='{ on }')
  16. v-btn.ml-3.my-0.mr-0.radius-7(outlined, large, color='teal', :icon='$vuetify.breakpoint.xsOnly', v-on='on')
  17. v-icon(:left='$vuetify.breakpoint.mdAndUp') mdi-plus
  18. span.hidden-sm-and-down(:class='$vuetify.theme.dark ? `teal--text text--lighten-3` : ``') {{$t('editor:assets.newFolder')}}
  19. v-card
  20. .dialog-header.is-short.subtitle-1 {{$t('editor:assets.newFolder')}}
  21. v-card-text.pt-5
  22. v-text-field.md2(
  23. outlined
  24. prepend-icon='mdi-folder-outline'
  25. v-model='newFolderName'
  26. :label='$t(`editor:assets.folderName`)'
  27. counter='255'
  28. @keyup.enter='createFolder'
  29. @keyup.esc='newFolderDialog = false'
  30. ref='folderNameIpt'
  31. )
  32. i18next.caption.grey--text.text--darken-1.pl-5(path='editor:assets.folderNameNamingRules', tag='div')
  33. a(place='namingRules', href='https://docs-beta.requarks.io/guide/assets#naming-restrictions', target='_blank') {{$t('editor:assets.folderNameNamingRulesLink')}}
  34. v-card-chin
  35. v-spacer
  36. v-btn(text, @click='newFolderDialog = false') {{$t('common:actions.cancel')}}
  37. v-btn.px-3(color='primary', @click='createFolder', :disabled='!isFolderNameValid', :loading='newFolderLoading') {{$t('common:actions.create')}}
  38. v-toolbar(flat, dense, :color='$vuetify.theme.dark ? `grey darken-3` : `white`')
  39. template(v-if='folderTree.length > 0')
  40. .body-2
  41. span.mr-1 /
  42. template(v-for='folder of folderTree')
  43. span(:key='folder.id') {{folder.name}}
  44. span.mx-1 /
  45. .body-2(v-else) / #[em root]
  46. template(v-if='folders.length > 0 || currentFolderId > 0')
  47. v-btn.is-icon.mx-1(:color='$vuetify.theme.dark ? `grey lighten-1` : `grey darken-2`', outlined, :dark='currentFolderId > 0', @click='upFolder()', :disabled='currentFolderId === 0')
  48. v-icon mdi-folder-upload
  49. v-btn.btn-normalcase.mx-1(v-for='folder of folders', :key='folder.id', depressed, color='grey darken-2', dark, @click='downFolder(folder)')
  50. v-icon(left) mdi-folder
  51. span.caption(style='text-transform: none;') {{ folder.name }}
  52. v-divider.mt-2
  53. v-data-table(
  54. :items='assets'
  55. :headers='headers'
  56. :page.sync='pagination'
  57. :items-per-page='15'
  58. :loading='loading'
  59. must-sort,
  60. hide-default-footer,
  61. dense
  62. )
  63. template(slot='item', slot-scope='props')
  64. tr.is-clickable(
  65. @click.left='currentFileId = props.item.id'
  66. @click.right.prevent=''
  67. :class='currentFileId === props.item.id ? ($vuetify.theme.dark ? `grey darken-3-d5` : `teal lighten-5`) : ``'
  68. )
  69. td.text-xs-right(v-if='$vuetify.breakpoint.smAndUp') {{ props.item.id }}
  70. td
  71. .body-2(:class='currentFileId === props.item.id ? `teal--text` : ``') {{ props.item.filename }}
  72. .caption.grey--text {{ props.item.description }}
  73. td.text-xs-center(v-if='$vuetify.breakpoint.lgAndUp')
  74. v-chip.ma-0(small, :color='$vuetify.theme.dark ? `grey darken-4` : `grey lighten-4`')
  75. .caption {{props.item.ext.toUpperCase().substring(1)}}
  76. td(v-if='$vuetify.breakpoint.mdAndUp') {{ props.item.fileSize | prettyBytes }}
  77. td(v-if='$vuetify.breakpoint.mdAndUp') {{ props.item.createdAt | moment('from') }}
  78. td(v-if='$vuetify.breakpoint.smAndUp')
  79. v-menu(offset-x, min-width='200')
  80. template(v-slot:activator='{ on }')
  81. v-btn(icon, v-on='on', tile, small)
  82. v-icon(color='grey darken-2') mdi-dots-horizontal
  83. v-list(nav, style='border-top: 5px solid #444;')
  84. v-list-item(@click='', disabled)
  85. v-list-item-avatar(size='24')
  86. v-icon(color='teal') mdi-text-short
  87. v-list-item-content {{$t('common:actions.properties')}}
  88. template(v-if='props.item.kind === `IMAGE`')
  89. v-list-item(@click='previewDialog = true', disabled)
  90. v-list-item-avatar(size='24')
  91. v-icon(color='green') mdi-image-search-outline
  92. v-list-item-content {{$t('common:actions.preview')}}
  93. v-list-item(@click='', disabled)
  94. v-list-item-avatar(size='24')
  95. v-icon(color='indigo') mdi-crop-rotate
  96. v-list-item-content {{$t('common:actions.edit')}}
  97. v-list-item(@click='', disabled)
  98. v-list-item-avatar(size='24')
  99. v-icon(color='purple') mdi-flash-circle
  100. v-list-item-content {{$t('common:actions.optimize')}}
  101. v-list-item(@click='openRenameDialog')
  102. v-list-item-avatar(size='24')
  103. v-icon(color='orange') mdi-keyboard-outline
  104. v-list-item-content {{$t('common:actions.rename')}}
  105. v-list-item(@click='', disabled)
  106. v-list-item-avatar(size='24')
  107. v-icon(color='blue') mdi-file-move
  108. v-list-item-content {{$t('common:actions.move')}}
  109. v-list-item(@click='deleteDialog = true')
  110. v-list-item-avatar(size='24')
  111. v-icon(color='red') mdi-file-hidden
  112. v-list-item-content {{$t('common:actions.delete')}}
  113. template(slot='no-data')
  114. v-alert.mt-3.radius-7(icon='mdi-folder-open-outline', :value='true', outlined, color='teal') {{$t('editor:assets.folderEmpty')}}
  115. .text-xs-center.py-2(v-if='this.pageTotal > 1')
  116. v-pagination(v-model='pagination', :length='pageTotal', color='teal')
  117. .d-flex.mt-3
  118. v-toolbar.radius-7(flat, :color='$vuetify.theme.dark ? `grey darken-2` : `grey lighten-4`', dense, height='44')
  119. .body-2(:class='$vuetify.theme.dark ? `grey--text text--lighten-1` : `grey--text text--darken-1`') {{$t('editor:assets.fileCount', { count: assets.length })}}
  120. v-btn.ml-3.mr-0.my-0.radius-7(color='teal', large, @click='insert', :disabled='!currentFileId', :dark='currentFileId !== null')
  121. v-icon(left) mdi-playlist-plus
  122. span {{$t('common:actions.insert')}}
  123. v-flex(xs12, lg3)
  124. v-card.radius-7.animated.fadeInRight.wait-p3s(:light='!$vuetify.theme.dark', :dark='$vuetify.theme.dark')
  125. v-card-text
  126. .d-flex
  127. v-toolbar.radius-7(:color='$vuetify.theme.dark ? `teal` : `teal lighten-5`', dense, flat, height='44')
  128. v-icon.mr-3(:color='$vuetify.theme.dark ? `white` : `teal`') mdi-cloud-upload
  129. .body-2(:class='$vuetify.theme.dark ? `white--text` : `teal--text`') {{$t('editor:assets.uploadAssets')}}
  130. v-btn.my-0.ml-3.mr-0.radius-7(outlined, large, color='teal', @click='browse', v-if='$vuetify.breakpoint.mdAndUp')
  131. v-icon(left) mdi-library-plus
  132. span(:class='$vuetify.theme.dark ? `teal--text text--lighten-3` : ``') {{$t('common:actions.browse')}}
  133. file-pond.mt-3(
  134. name='mediaUpload'
  135. ref='pond'
  136. :label-idle='$t(`editor:assets.uploadAssetsDropZone`)'
  137. allow-multiple='true'
  138. :files='files'
  139. max-files='10'
  140. server='/u'
  141. :instant-upload='false'
  142. :allow-revert='false'
  143. @processfile='onFileProcessed'
  144. )
  145. v-divider
  146. v-card-actions.pa-3
  147. .caption.grey--text.text-darken-2 Max 10 files, 5 MB each
  148. v-spacer
  149. v-btn.px-4(color='teal', dark, @click='upload') {{$t('common:actions.upload')}}
  150. v-card.mt-3.radius-7.animated.fadeInRight.wait-p4s(:light='!$vuetify.theme.dark', :dark='$vuetify.theme.dark')
  151. v-card-text.pb-0
  152. v-toolbar.radius-7(:color='$vuetify.theme.dark ? `teal` : `teal lighten-5`', dense, flat)
  153. v-icon.mr-3(:color='$vuetify.theme.dark ? `white` : `teal`') mdi-cloud-download
  154. .body-2(:class='$vuetify.theme.dark ? `white--text` : `teal--text`') {{$t('editor:assets.fetchImage')}}
  155. v-spacer
  156. v-chip(label, color='white', small).teal--text coming soon
  157. v-text-field.mt-3(
  158. v-model='remoteImageUrl'
  159. outlined
  160. color='teal'
  161. single-line
  162. placeholder='https://example.com/image.jpg'
  163. )
  164. v-divider
  165. v-card-actions.pa-3
  166. .caption.grey--text.text-darken-2 Max 5 MB
  167. v-spacer
  168. v-btn.px-4(color='teal', disabled) {{$t('common:actions.fetch')}}
  169. v-card.mt-3.radius-7.animated.fadeInRight.wait-p4s(:light='!$vuetify.theme.dark', :dark='$vuetify.theme.dark')
  170. v-card-text.pb-0
  171. v-toolbar.radius-7(:color='$vuetify.theme.dark ? `teal` : `teal lighten-5`', dense, flat)
  172. v-icon.mr-3(:color='$vuetify.theme.dark ? `white` : `teal`') mdi-format-align-top
  173. .body-2(:class='$vuetify.theme.dark ? `white--text` : `teal--text`') {{$t('editor:assets.imageAlign')}}
  174. v-select.mt-3(
  175. v-model='imageAlignment'
  176. :items='imageAlignments'
  177. outlined
  178. single-line
  179. color='teal'
  180. placeholder='None'
  181. )
  182. //- RENAME DIALOG
  183. v-dialog(v-model='renameDialog', max-width='550', persistent)
  184. v-card
  185. .dialog-header.is-short.is-orange
  186. v-icon.mr-2(color='white') mdi-keyboard
  187. span {{$t('editor:assets.renameAsset')}}
  188. v-card-text.pt-5
  189. .body-2 {{$t('editor:assets.renameAssetSubtitle')}}
  190. v-text-field(
  191. outlined
  192. single-line
  193. :counter='255'
  194. v-model='renameAssetName'
  195. @keyup.enter='renameAsset'
  196. :disabled='renameAssetLoading'
  197. )
  198. v-card-chin
  199. v-spacer
  200. v-btn(text, @click='renameDialog = false', :disabled='renameAssetLoading') {{$t('common:actions.cancel')}}
  201. v-btn.px-3(color='orange darken-3', @click='renameAsset', :loading='renameAssetLoading').white--text {{$t('common:actions.rename')}}
  202. //- DELETE DIALOG
  203. v-dialog(v-model='deleteDialog', max-width='550', persistent)
  204. v-card
  205. .dialog-header.is-short.is-red
  206. v-icon.mr-2(color='white') mdi-trash-can-outline
  207. span {{$t('editor:assets.deleteAsset')}}
  208. v-card-text.pt-5
  209. .body-2 {{$t('editor:assets.deleteAssetConfirm')}}
  210. .body-2.red--text.text--darken-2 {{currentAsset.filename}}?
  211. .caption.mt-3 {{$t('editor:assets.deleteAssetWarn')}}
  212. v-card-chin
  213. v-spacer
  214. v-btn(text, @click='deleteDialog = false', :disabled='deleteAssetLoading') {{$t('common:actions.cancel')}}
  215. v-btn.px-3(color='red darken-2', @click='deleteAsset', :loading='deleteAssetLoading').white--text {{$t('common:actions.delete')}}
  216. </template>
  217. <script>
  218. import _ from 'lodash'
  219. import { get, sync } from 'vuex-pathify'
  220. import vueFilePond from 'vue-filepond'
  221. import 'filepond/dist/filepond.min.css'
  222. import listAssetQuery from 'gql/editor/editor-media-query-list.gql'
  223. import listFolderAssetQuery from 'gql/editor/editor-media-query-folder-list.gql'
  224. import createAssetFolderMutation from 'gql/editor/editor-media-mutation-folder-create.gql'
  225. import renameAssetMutation from 'gql/editor/editor-media-mutation-asset-rename.gql'
  226. import deleteAssetMutation from 'gql/editor/editor-media-mutation-asset-delete.gql'
  227. const FilePond = vueFilePond()
  228. const localeSegmentRegex = /^[A-Z]{2}(-[A-Z]{2})?$/i
  229. const disallowedFolderChars = /[A-Z()=.!@#$%?&*+`~<>,;:\\/[\]¬{| ]/
  230. export default {
  231. components: {
  232. FilePond
  233. },
  234. props: {
  235. value: {
  236. type: Boolean,
  237. default: false
  238. }
  239. },
  240. data() {
  241. return {
  242. folders: [],
  243. files: [],
  244. assets: [],
  245. pagination: 1,
  246. remoteImageUrl: '',
  247. imageAlignments: [
  248. { text: 'None', value: '' },
  249. { text: 'Left', value: 'left' },
  250. { text: 'Centered', value: 'center' },
  251. { text: 'Right', value: 'right' },
  252. { text: 'Absolute Top Right', value: 'abstopright' }
  253. ],
  254. imageAlignment: '',
  255. loading: false,
  256. newFolderDialog: false,
  257. newFolderName: '',
  258. newFolderLoading: false,
  259. previewDialog: false,
  260. renameDialog: false,
  261. renameAssetName: '',
  262. renameAssetLoading: false,
  263. deleteDialog: false,
  264. deleteAssetLoading: false
  265. }
  266. },
  267. computed: {
  268. isShown: {
  269. get() { return this.value },
  270. set(val) { this.$emit('input', val) }
  271. },
  272. activeModal: sync('editor/activeModal'),
  273. folderTree: get('editor/media@folderTree'),
  274. currentFolderId: sync('editor/media@currentFolderId'),
  275. currentFileId: sync('editor/media@currentFileId'),
  276. pageTotal () {
  277. if (!this.assets) {
  278. return 0
  279. }
  280. return Math.ceil(this.assets.length / 15)
  281. },
  282. headers() {
  283. return _.compact([
  284. this.$vuetify.breakpoint.smAndUp && { text: this.$t('editor:assets.headerId'), value: 'id', width: 50, align: 'right' },
  285. { text: this.$t('editor:assets.headerFilename'), value: 'filename' },
  286. this.$vuetify.breakpoint.lgAndUp && { text: this.$t('editor:assets.headerType'), value: 'ext', width: 50 },
  287. this.$vuetify.breakpoint.mdAndUp && { text: this.$t('editor:assets.headerFileSize'), value: 'fileSize', width: 110 },
  288. this.$vuetify.breakpoint.mdAndUp && { text: this.$t('editor:assets.headerAdded'), value: 'createdAt', width: 175 },
  289. this.$vuetify.breakpoint.smAndUp && { text: this.$t('editor:assets.headerActions'), value: '', width: 40, sortable: false, align: 'right' }
  290. ])
  291. },
  292. isFolderNameValid() {
  293. return this.newFolderName.length > 1 && !localeSegmentRegex.test(this.newFolderName) && !disallowedFolderChars.test(this.newFolderName)
  294. },
  295. currentAsset () {
  296. return _.find(this.assets, ['id', this.currentFileId]) || {}
  297. }
  298. },
  299. watch: {
  300. newFolderDialog(newValue, oldValue) {
  301. if (newValue) {
  302. this.$nextTick(() => {
  303. this.$refs.folderNameIpt.focus()
  304. })
  305. }
  306. }
  307. },
  308. filters: {
  309. prettyBytes(num) {
  310. if (typeof num !== 'number' || isNaN(num)) {
  311. throw new TypeError('Expected a number')
  312. }
  313. let exponent
  314. let unit
  315. let neg = num < 0
  316. let units = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
  317. if (neg) {
  318. num = -num
  319. }
  320. if (num < 1) {
  321. return (neg ? '-' : '') + num + ' B'
  322. }
  323. exponent = Math.min(Math.floor(Math.log(num) / Math.log(1000)), units.length - 1)
  324. num = (num / Math.pow(1000, exponent)).toFixed(2) * 1
  325. unit = units[exponent]
  326. return (neg ? '-' : '') + num + ' ' + unit
  327. }
  328. },
  329. methods: {
  330. async refresh() {
  331. await this.$apollo.queries.assets.refetch()
  332. this.$store.commit('showNotification', {
  333. message: this.$t('editor:assets.refreshSuccess'),
  334. style: 'success',
  335. icon: 'check'
  336. })
  337. },
  338. insert () {
  339. const asset = _.find(this.assets, ['id', this.currentFileId])
  340. const assetPath = this.folderTree.map(f => f.slug).join('/')
  341. this.$root.$emit('editorInsert', {
  342. kind: asset.kind,
  343. path: this.currentFolderId > 0 ? `/${assetPath}/${asset.filename}` : `/${asset.filename}`,
  344. text: asset.filename,
  345. align: this.imageAlignment
  346. })
  347. this.activeModal = ''
  348. },
  349. browse () {
  350. this.$refs.pond.browse()
  351. },
  352. async upload () {
  353. const files = this.$refs.pond.getFiles()
  354. if (files.length < 1) {
  355. return this.$store.commit('showNotification', {
  356. message: this.$t('editor:assets.noUploadError'),
  357. style: 'warning',
  358. icon: 'warning'
  359. })
  360. }
  361. for (let file of files) {
  362. file.setMetadata({
  363. folderId: this.currentFolderId
  364. })
  365. }
  366. await this.$refs.pond.processFiles()
  367. },
  368. async onFileProcessed (err, file) {
  369. if (err) {
  370. return this.$store.commit('showNotification', {
  371. message: this.$t('editor:assets.uploadFailed'),
  372. style: 'error',
  373. icon: 'error'
  374. })
  375. }
  376. _.delay(() => {
  377. this.$refs.pond.removeFile(file.id)
  378. }, 5000)
  379. await this.$apollo.queries.assets.refetch()
  380. },
  381. downFolder(folder) {
  382. this.$store.commit('editor/pushMediaFolderTree', folder)
  383. this.currentFolderId = folder.id
  384. this.currentFileId = null
  385. },
  386. upFolder() {
  387. this.$store.commit('editor/popMediaFolderTree')
  388. const parentFolder = _.last(this.folderTree)
  389. this.currentFolderId = parentFolder ? parentFolder.id : 0
  390. this.currentFileId = null
  391. },
  392. async createFolder() {
  393. this.$store.commit(`loadingStart`, 'editor-media-createfolder')
  394. this.newFolderLoading = true
  395. try {
  396. const resp = await this.$apollo.mutate({
  397. mutation: createAssetFolderMutation,
  398. variables: {
  399. parentFolderId: this.currentFolderId,
  400. slug: this.newFolderName
  401. }
  402. })
  403. if (_.get(resp, 'data.assets.createFolder.responseResult.succeeded', false)) {
  404. await this.$apollo.queries.folders.refetch()
  405. this.$store.commit('showNotification', {
  406. message: this.$t('editor:assets.folderCreateSuccess'),
  407. style: 'success',
  408. icon: 'check'
  409. })
  410. this.newFolderDialog = false
  411. this.newFolderName = ''
  412. } else {
  413. this.$store.commit('pushGraphError', new Error(_.get(resp, 'data.assets.createFolder.responseResult.message')))
  414. }
  415. } catch (err) {
  416. this.$store.commit('pushGraphError', err)
  417. }
  418. this.newFolderLoading = false
  419. this.$store.commit(`loadingStop`, 'editor-media-createfolder')
  420. },
  421. openRenameDialog() {
  422. this.renameAssetName = this.currentAsset.filename
  423. this.renameDialog = true
  424. },
  425. async renameAsset() {
  426. this.$store.commit(`loadingStart`, 'editor-media-renameasset')
  427. this.renameAssetLoading = true
  428. try {
  429. const resp = await this.$apollo.mutate({
  430. mutation: renameAssetMutation,
  431. variables: {
  432. id: this.currentFileId,
  433. filename: this.renameAssetName
  434. }
  435. })
  436. if (_.get(resp, 'data.assets.renameAsset.responseResult.succeeded', false)) {
  437. await this.$apollo.queries.assets.refetch()
  438. this.$store.commit('showNotification', {
  439. message: this.$t('editor:assets.renameSuccess'),
  440. style: 'success',
  441. icon: 'check'
  442. })
  443. this.renameDialog = false
  444. this.renameAssetName = ''
  445. } else {
  446. this.$store.commit('pushGraphError', new Error(_.get(resp, 'data.assets.renameAsset.responseResult.message')))
  447. }
  448. } catch (err) {
  449. this.$store.commit('pushGraphError', err)
  450. }
  451. this.renameAssetLoading = false
  452. this.$store.commit(`loadingStop`, 'editor-media-renameasset')
  453. },
  454. async deleteAsset() {
  455. this.$store.commit(`loadingStart`, 'editor-media-deleteasset')
  456. this.deleteAssetLoading = true
  457. try {
  458. const resp = await this.$apollo.mutate({
  459. mutation: deleteAssetMutation,
  460. variables: {
  461. id: this.currentFileId
  462. }
  463. })
  464. if (_.get(resp, 'data.assets.deleteAsset.responseResult.succeeded', false)) {
  465. this.currentFileId = null
  466. await this.$apollo.queries.assets.refetch()
  467. this.$store.commit('showNotification', {
  468. message: this.$t('editor:assets.deleteSuccess'),
  469. style: 'success',
  470. icon: 'check'
  471. })
  472. this.deleteDialog = false
  473. } else {
  474. this.$store.commit('pushGraphError', new Error(_.get(resp, 'data.assets.deleteAsset.responseResult.message')))
  475. }
  476. } catch (err) {
  477. this.$store.commit('pushGraphError', err)
  478. }
  479. this.deleteAssetLoading = false
  480. this.$store.commit(`loadingStop`, 'editor-media-deleteasset')
  481. }
  482. },
  483. apollo: {
  484. folders: {
  485. query: listFolderAssetQuery,
  486. variables() {
  487. return {
  488. parentFolderId: this.currentFolderId
  489. }
  490. },
  491. fetchPolicy: 'network-only',
  492. update: (data) => data.assets.folders,
  493. watchLoading (isLoading) {
  494. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'editor-media-folders-list-refresh')
  495. }
  496. },
  497. assets: {
  498. query: listAssetQuery,
  499. variables() {
  500. return {
  501. folderId: this.currentFolderId,
  502. kind: 'ALL'
  503. }
  504. },
  505. throttle: 1000,
  506. fetchPolicy: 'network-only',
  507. update: (data) => data.assets.list,
  508. watchLoading (isLoading) {
  509. this.loading = isLoading
  510. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'editor-media-list-refresh')
  511. }
  512. }
  513. }
  514. }
  515. </script>
  516. <style lang='scss'>
  517. .editor-modal-media {
  518. position: fixed;
  519. top: 112px;
  520. left: 64px;
  521. z-index: 10;
  522. width: calc(100vw - 64px - 17px);
  523. height: calc(100vh - 112px - 24px);
  524. background-color: rgba(darken(mc('grey', '900'), 3%), .9) !important;
  525. overflow: auto;
  526. @include until($tablet) {
  527. left: 40px;
  528. width: calc(100vw - 40px);
  529. height: calc(100vh - 112px - 24px);
  530. }
  531. .filepond--root {
  532. margin-bottom: 0;
  533. }
  534. .filepond--drop-label {
  535. cursor: pointer;
  536. > label {
  537. cursor: pointer;
  538. }
  539. }
  540. .v-btn--icon {
  541. padding: 0 20px;
  542. }
  543. }
  544. </style>