Partial implementation of URL syncronization for admin_view_mode.
This commit is contained in:
parent
fe84d4d8f6
commit
79ad12ae92
|
@ -111,7 +111,7 @@ UserPrefsPlugin.install = function (Vue, options = {}) {
|
|||
slug: 'creation_date',
|
||||
name: 'Creation Date'
|
||||
},
|
||||
'view_mode': 'cards',
|
||||
'view_mode': 'table',
|
||||
'admin_view_mode': 'table'
|
||||
},
|
||||
init() {
|
||||
|
|
|
@ -122,6 +122,22 @@ export default {
|
|||
}
|
||||
}
|
||||
|
||||
// Admin View Modes
|
||||
if (this.$route.name != null && this.$route.name != undefined &&
|
||||
(this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage') &&
|
||||
(this.$route.query.admin_view_mode == undefined || to.params.collectionId != from.params.collectionId)
|
||||
) {
|
||||
let adminViewModeKey = (this.collectionId != undefined ? 'admin_view_mode_' + this.collectionId : 'admin_view_mode');
|
||||
let adminViewModeValue = this.$userPrefs.get(adminViewModeKey);
|
||||
|
||||
if (adminViewModeValue)
|
||||
this.$route.query.admin_view_mode = adminViewModeValue;
|
||||
else {
|
||||
this.$route.query.admin_view_mode = 'table';
|
||||
this.$userPrefs.set(adminViewModeKey, 'table');
|
||||
}
|
||||
}
|
||||
|
||||
// Advanced Search
|
||||
if (this.$route.query.metaquery && this.$route.query.metaquery.advancedSearch){
|
||||
this.$store.dispatch('search/set_advanced_query', this.$route.query.metaquery);
|
||||
|
@ -225,15 +241,15 @@ export default {
|
|||
this.$store.dispatch('search/setViewMode', viewMode);
|
||||
this.updateURLQueries();
|
||||
},
|
||||
setAdminViewMode(viewMode) {
|
||||
setAdminViewMode(adminViewMode) {
|
||||
let prefsAdminViewMode = this.collectionId != undefined ? 'admin_view_mode_' + this.collectionId : 'admin_view_mode';
|
||||
if(this.$userPrefs.get(prefsAdminViewMode) != viewMode) {
|
||||
this.$userPrefs.set(prefsAdminViewMode, viewMode)
|
||||
if(this.$userPrefs.get(prefsAdminViewMode) != adminViewMode) {
|
||||
this.$userPrefs.set(prefsAdminViewMode, adminViewMode)
|
||||
.catch(() => { this.$console.log("Error settings user prefs for admin view mode.") });
|
||||
}
|
||||
// Admin view mode is not syncronizing with URL yet.
|
||||
//this.$store.dispatch('search/setViewMode', viewMode);
|
||||
//this.updateURLQueries();
|
||||
|
||||
this.$store.dispatch('search/setAdminViewMode', adminViewMode);
|
||||
this.updateURLQueries();
|
||||
},
|
||||
setInitialViewMode(viewMode) {
|
||||
this.$store.dispatch('search/setViewMode', viewMode);
|
||||
|
|
|
@ -50,7 +50,11 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
|
|||
postQueries.view_mode = null;
|
||||
|
||||
endpoint = endpoint + 'context=edit&'
|
||||
}
|
||||
} else {
|
||||
if (postQueries.admin_view_mode != undefined)
|
||||
postQueries.admin_view_mode = null;
|
||||
}
|
||||
|
||||
axios.tainacan.get(endpoint+query)
|
||||
.then(res => {
|
||||
|
||||
|
|
|
@ -106,4 +106,9 @@ export const setSearchQuery = ({ commit }, searchQuery ) => {
|
|||
// Set ViewMode (view_mode)
|
||||
export const setViewMode = ({ commit }, viewMode ) => {
|
||||
commit('setViewMode', viewMode );
|
||||
};
|
||||
|
||||
// Set AdminViewMode (admin_view_mode)
|
||||
export const setAdminViewMode = ({ commit }, adminViewMode ) => {
|
||||
commit('setAdminViewMode', adminViewMode );
|
||||
};
|
|
@ -52,6 +52,9 @@ export const getViewMode = state => {
|
|||
return state.postquery.view_mode;
|
||||
};
|
||||
|
||||
export const getAdminViewMode = state => {
|
||||
return state.postquery.admin_view_mode;
|
||||
};
|
||||
export const getFetchOnly = state => {
|
||||
return state.postquery.fetch_only;
|
||||
};
|
||||
|
|
|
@ -19,7 +19,8 @@ const state = {
|
|||
'1': 'creation_date',
|
||||
'2': 'author_name'
|
||||
},
|
||||
view_mode: 'table'
|
||||
view_mode: 'table',
|
||||
admin_view_mode: 'table'
|
||||
},
|
||||
totalItems: 0
|
||||
};
|
||||
|
|
|
@ -127,4 +127,8 @@ export const setStatus = ( state, status ) => {
|
|||
|
||||
export const setViewMode = ( state, viewMode ) => {
|
||||
state.postquery.view_mode = viewMode;
|
||||
};
|
||||
|
||||
export const setAdminViewMode = ( state, adminViewMode ) => {
|
||||
state.postquery.admin_view_mode = adminViewMode;
|
||||
};
|
Loading…
Reference in New Issue