cache last location in media picker
This commit is contained in:
@@ -10,10 +10,12 @@
|
||||
|
||||
<script>
|
||||
import api from '../api';
|
||||
import { arrayMove } from '../../../utils';
|
||||
import { arrayMove, generateId } from '../../../utils';
|
||||
import * as overlays from '../../../services/overlay';
|
||||
import MediaPreviews from './media-previews.vue';
|
||||
|
||||
let media_last_query = { parentId: null, search: null, page: 1 };
|
||||
|
||||
export default {
|
||||
name: 'uiMediapicker',
|
||||
|
||||
@@ -91,14 +93,14 @@
|
||||
component: () => import('../overlays/media.vue'),
|
||||
display: 'editor',
|
||||
width: 1240,
|
||||
model: {
|
||||
parentId: null
|
||||
}
|
||||
model: { ...media_last_query }
|
||||
});
|
||||
|
||||
if (result.eventType == 'confirm' && result.value)
|
||||
{
|
||||
this.add(result.value);
|
||||
let item = result.value.item;
|
||||
media_last_query = JSON.parse(JSON.stringify(result.value.query));
|
||||
this.add(item);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -86,7 +86,10 @@
|
||||
gridConfig: {
|
||||
width: 180,
|
||||
selectable: true,
|
||||
items: null
|
||||
items: null,
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
setQuery: false
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -120,7 +123,9 @@
|
||||
|
||||
mounted()
|
||||
{
|
||||
this.parentId = this.config.parentId;
|
||||
this.parentId = this.config.model.parentId;
|
||||
this.search = this.config.model.search;
|
||||
this.gridConfig.page = this.config.model.page || 1;
|
||||
this.gridConfig.items = this.getItems;
|
||||
this.gridConfig.scrollContainerSelector = '.media-overlay content';
|
||||
this.loaded = true;
|
||||
@@ -136,20 +141,19 @@
|
||||
query = {};
|
||||
}
|
||||
|
||||
query.pageSize = 50;
|
||||
|
||||
if (!query.search || !this.hierarchy.length)
|
||||
{
|
||||
const hierarchy = await api.folders.getHierarchy(this.id);
|
||||
this.hierarchy = hierarchy.data;
|
||||
}
|
||||
|
||||
|
||||
if (query.search)
|
||||
{
|
||||
return await api.search(this.search, this.id, query);
|
||||
}
|
||||
|
||||
return await api.folders.getChildren(this.id, true, query);
|
||||
return await api.folders.getChildren(this.id, true, { ...query });
|
||||
},
|
||||
|
||||
|
||||
@@ -161,14 +165,20 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
this.config.confirm(item);
|
||||
this.config.confirm({
|
||||
item,
|
||||
query: {
|
||||
search: this.search,
|
||||
parentId: this.parentId,
|
||||
page: this.$refs.grid.filter.page
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
async selectItem(id)
|
||||
{
|
||||
console.info(id);
|
||||
this.parentId = id;
|
||||
await this.refresh();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user