Media list can load folder breadcrumb via axios call

parent 5b45c8dd
...@@ -103,6 +103,7 @@ ...@@ -103,6 +103,7 @@
</template> </template>
<script> <script>
import axios from 'axios'
import NewFolder from './NewFolder.vue'; import NewFolder from './NewFolder.vue';
import UploadButton from './UploadButton.vue'; import UploadButton from './UploadButton.vue';
import RenameFolder from './RenameFolder.vue'; import RenameFolder from './RenameFolder.vue';
...@@ -134,8 +135,7 @@ ...@@ -134,8 +135,7 @@
selectedMedia: {}, selectedMedia: {},
folderBreadcrumb: [ folderBreadcrumb: [
{id: 0, name: 'Home'}, {id: 0, name: 'Home'},
//{id: 37, name: 'Folder'}, ],
]
} }
}, },
methods: { methods: {
...@@ -162,8 +162,25 @@ ...@@ -162,8 +162,25 @@
}, },
fetchMediaData() { fetchMediaData() {
this.tableIsLoading = true; this.tableIsLoading = true;
if (this.$route.query.folder_id !== undefined) {
this.queryServer({folder_id: this.$route.query.folder_id});
this.fetchFolderBreadcrumb(this.$route.query.folder_id);
return;
}
this.queryServer(); this.queryServer();
}, },
fetchFolderBreadcrumb(folderId) {
if (folderId === 0) {
this.folderBreadcrumb = [
{id: 0, name: 'Home'},
];
return;
}
axios.get(route('api.media.folders.breadcrumb', {folder: folderId}))
.then(response => {
this.folderBreadcrumb = response.data;
});
},
handleSizeChange(event) { handleSizeChange(event) {
console.log('per page :' + event); console.log('per page :' + event);
this.tableIsLoading = true; this.tableIsLoading = true;
...@@ -188,7 +205,8 @@ ...@@ -188,7 +205,8 @@
this.tableIsLoading = true; this.tableIsLoading = true;
this.queryServer({folder_id: scope.row.id}); this.queryServer({folder_id: scope.row.id});
this.folderId = scope.row.id; this.folderId = scope.row.id;
this.folderBreadcrumb.push({id: scope.row.id, name: scope.row.filename}); this.$router.push({ query: { folder_id: scope.row.id }});
this.fetchFolderBreadcrumb(scope.row.id);
}, },
insertMedia(scope) { insertMedia(scope) {
this.$events.emit('fileWasSelected', scope.row); this.$events.emit('fileWasSelected', scope.row);
...@@ -200,7 +218,8 @@ ...@@ -200,7 +218,8 @@
return route('admin.media.media.edit', {media: scope.row.id}); return route('admin.media.media.edit', {media: scope.row.id});
}, },
loadEditForm(scope) { loadEditForm(scope) {
this.$events.emit('editMediaWasClicked', scope.row); console.log('clicked edit to' + scope.row.id);
this.$router.push({name: 'admin.media.media.edit', params: {mediaId: scope.row.id}})
}, },
showEditFolder(scope) { showEditFolder(scope) {
this.$events.emit('editFolderWasClicked', scope); this.$events.emit('editFolderWasClicked', scope);
...@@ -209,7 +228,13 @@ ...@@ -209,7 +228,13 @@
this.tableIsLoading = true; this.tableIsLoading = true;
this.queryServer({folder_id: folderId}); this.queryServer({folder_id: folderId});
this.folderId = folderId; this.folderId = folderId;
this.folderBreadcrumb.splice(index+1, this.folderBreadcrumb.length); if (folderId === 0) {
this.$router.push({ query: {}});
} else {
this.$router.push({ query: { folder_id: folderId }});
}
this.fetchFolderBreadcrumb(folderId);
}, },
}, },
mounted() { mounted() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment