Added Tempstore Saving
This commit is contained in:
@@ -17,6 +17,10 @@ export const useAuthStore = defineStore("auth", {
|
|||||||
async init(token) {
|
async init(token) {
|
||||||
await this.fetchMe(token)
|
await this.fetchMe(token)
|
||||||
|
|
||||||
|
const tempStore = useTempStore()
|
||||||
|
|
||||||
|
if(this.profile.temp_config) tempStore.setStoredTempConfig(this.profile.temp_config)
|
||||||
|
|
||||||
if(useCapacitor().getIsNative()) {
|
if(useCapacitor().getIsNative()) {
|
||||||
navigateTo("/mobile")
|
navigateTo("/mobile")
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3,33 +3,68 @@ import {defineStore} from 'pinia'
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
export const useTempStore = defineStore('temp', () => {
|
export const useTempStore = defineStore('temp', () => {
|
||||||
|
|
||||||
|
const auth = useAuthStore()
|
||||||
|
|
||||||
const searchStrings = ref({})
|
const searchStrings = ref({})
|
||||||
const filters = ref({})
|
const filters = ref({})
|
||||||
const columns = ref({})
|
const columns = ref({})
|
||||||
const pages = ref({})
|
const pages = ref({})
|
||||||
|
const settings = ref({})
|
||||||
|
|
||||||
|
const storeTempConfig = async () => {
|
||||||
|
const config = {
|
||||||
|
searchStrings: searchStrings.value,
|
||||||
|
columns: columns.value,
|
||||||
|
pages: pages.value,
|
||||||
|
settings: settings.value,
|
||||||
|
}
|
||||||
|
|
||||||
|
await useNuxtApp().$api(`/api/profiles/${auth.profile.id}`,{
|
||||||
|
method: 'PUT',
|
||||||
|
body: {temp_config: config}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function setStoredTempConfig (config) {
|
||||||
|
searchStrings.value = config.searchStrings
|
||||||
|
columns.value = config.columns
|
||||||
|
pages.value = config.pages
|
||||||
|
settings.value = config.settings
|
||||||
|
}
|
||||||
|
|
||||||
function modifySearchString(type,input) {
|
function modifySearchString(type,input) {
|
||||||
searchStrings.value[type] = input
|
searchStrings.value[type] = input
|
||||||
|
storeTempConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearSearchString(type) {
|
function clearSearchString(type) {
|
||||||
searchStrings.value[type] = ""
|
searchStrings.value[type] = ""
|
||||||
|
storeTempConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
function modifyFilter(type,input) {
|
function modifyFilter(type,input) {
|
||||||
filters.value[type] = input
|
filters.value[type] = input
|
||||||
|
storeTempConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
function modifyColumns(type,input) {
|
function modifyColumns(type,input) {
|
||||||
columns.value[type] = input
|
columns.value[type] = input
|
||||||
|
storeTempConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
function modifyPages(type,input) {
|
function modifyPages(type,input) {
|
||||||
pages.value[type] = input
|
pages.value[type] = input
|
||||||
|
storeTempConfig()
|
||||||
|
}
|
||||||
|
|
||||||
|
function modifySettings(type,input) {
|
||||||
|
settings.value[type] = input
|
||||||
|
storeTempConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
setStoredTempConfig,
|
||||||
searchStrings,
|
searchStrings,
|
||||||
modifySearchString,
|
modifySearchString,
|
||||||
clearSearchString,
|
clearSearchString,
|
||||||
@@ -38,7 +73,9 @@ export const useTempStore = defineStore('temp', () => {
|
|||||||
columns,
|
columns,
|
||||||
modifyColumns,
|
modifyColumns,
|
||||||
modifyPages,
|
modifyPages,
|
||||||
pages
|
pages,
|
||||||
|
modifySettings,
|
||||||
|
settings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user