Browse Source

fix: save media asset path on reopen (#919)

pull/921/head 2.0.0-beta.230
Markus 5 years ago
committed by Nicolas Giard
parent
commit
c88a9fc703
2 changed files with 21 additions and 9 deletions
  1. 13
      client/components/editor/editor-modal-media.vue
  2. 17
      client/store/editor.js

13
client/components/editor/editor-modal-media.vue

@ -228,7 +228,7 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import { sync } from 'vuex-pathify'
import { get, sync } from 'vuex-pathify'
import vueFilePond from 'vue-filepond' import vueFilePond from 'vue-filepond'
import 'filepond/dist/filepond.min.css' import 'filepond/dist/filepond.min.css'
@ -255,7 +255,6 @@ export default {
data() { data() {
return { return {
folders: [], folders: [],
folderTree: [],
files: [], files: [],
assets: [], assets: [],
pagination: {}, pagination: {},
@ -268,9 +267,6 @@ export default {
{ text: 'Absolute Top Right', value: 'abstopright' } { text: 'Absolute Top Right', value: 'abstopright' }
], ],
imageAlignment: '', imageAlignment: '',
currentFolderId: 0,
currentFileId: null,
previousFolderId: 0,
loading: false, loading: false,
newFolderDialog: false, newFolderDialog: false,
newFolderName: '', newFolderName: '',
@ -289,6 +285,9 @@ export default {
set(val) { this.$emit('input', val) } set(val) { this.$emit('input', val) }
}, },
activeModal: sync('editor/activeModal'), activeModal: sync('editor/activeModal'),
folderTree: get('editor/media@folderTree'),
currentFolderId: sync('editor/media@currentFolderId'),
currentFileId: sync('editor/media@currentFileId'),
pageTotal () { pageTotal () {
if (this.pagination.rowsPerPage == null || this.pagination.totalItems == null) { if (this.pagination.rowsPerPage == null || this.pagination.totalItems == null) {
return 0 return 0
@ -400,12 +399,12 @@ export default {
await this.$apollo.queries.assets.refetch() await this.$apollo.queries.assets.refetch()
}, },
downFolder(folder) { downFolder(folder) {
this.folderTree.push(folder)
this.$store.commit('editor/pushMediaFolderTree', folder)
this.currentFolderId = folder.id this.currentFolderId = folder.id
this.currentFileId = null this.currentFileId = null
}, },
upFolder() { upFolder() {
this.folderTree.pop()
this.$store.commit('editor/popMediaFolderTree')
const parentFolder = _.last(this.folderTree) const parentFolder = _.last(this.folderTree)
this.currentFolderId = parentFolder ? parentFolder.id : 0 this.currentFolderId = parentFolder ? parentFolder.id : 0
this.currentFileId = null this.currentFileId = null

17
client/store/editor.js

@ -4,11 +4,24 @@ const state = {
editor: '', editor: '',
content: '', content: '',
mode: 'create', mode: 'create',
activeModal: ''
activeModal: '',
media: {
folderTree: [],
currentFolderId: 0,
currentFileId: null
}
} }
export default { export default {
namespaced: true, namespaced: true,
state, state,
mutations: make.mutations(state)
mutations: {
...make.mutations(state),
pushMediaFolderTree: (state, folder) => {
state.media.folderTree = state.media.folderTree.concat(folder)
},
popMediaFolderTree: (state) => {
state.media.folderTree = state.media.folderTree.slice(0, -1)
}
}
} }
Loading…
Cancel
Save