Allowed Filters to stay Persistent, Introduced Extra Column for ActivePhase
This commit is contained in:
@@ -86,9 +86,7 @@ const changePage = (number) => {
|
||||
setupPage()
|
||||
}
|
||||
|
||||
const resetColum = (column) => {
|
||||
columnsToFilter.value[column] = itemsMeta.value.distinctValues[column]
|
||||
}
|
||||
|
||||
|
||||
const changeSort = (column) => {
|
||||
if(sort.value.column === column) {
|
||||
@@ -131,7 +129,11 @@ const setupPage = async () => {
|
||||
items.value = data
|
||||
itemsMeta.value = meta
|
||||
if(!initialSetupDone.value){
|
||||
Object.keys(itemsMeta.value.distinctValues).forEach(distinctValue => {
|
||||
Object.keys(tempStore.filters[type]).forEach((column) => {
|
||||
columnsToFilter.value[column] = tempStore.filters[type][column]
|
||||
})
|
||||
|
||||
Object.keys(itemsMeta.value.distinctValues).filter(i => !Object.keys(tempStore.filters[type]).includes(i)).forEach(distinctValue => {
|
||||
columnsToFilter.value[distinctValue] = itemsMeta.value.distinctValues[distinctValue]
|
||||
})
|
||||
}
|
||||
@@ -144,8 +146,14 @@ const setupPage = async () => {
|
||||
|
||||
setupPage()
|
||||
|
||||
|
||||
|
||||
const handleFilterChange = async (action,column) => {
|
||||
if(action === 'reset') {
|
||||
columnsToFilter.value[column] = itemsMeta.value.distinctValues[column]
|
||||
} else if(action === 'change') {
|
||||
tempStore.modifyFilter(type,column,columnsToFilter.value[column])
|
||||
}
|
||||
setupPage()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -328,7 +336,7 @@ setupPage()
|
||||
:options="itemsMeta?.distinctValues?.[column.key]"
|
||||
v-model="columnsToFilter[column.key]"
|
||||
multiple
|
||||
@change="setupPage"
|
||||
@change="handleFilterChange('change', column.key)"
|
||||
searchable
|
||||
searchable-placeholder="Suche..."
|
||||
:search-attributes="[column.key]"
|
||||
@@ -367,7 +375,7 @@ setupPage()
|
||||
v-if="columnsToFilter[column.key]?.length !== itemsMeta.distinctValues?.[column.key]?.length && column.distinct"
|
||||
>
|
||||
<UButton
|
||||
@click="resetColum(column.key)"
|
||||
@click="handleFilterChange('reset',column.key)"
|
||||
variant="outline"
|
||||
color="rose"
|
||||
>
|
||||
|
||||
@@ -35,9 +35,6 @@ export const useAuthStore = defineStore("auth", {
|
||||
console.log("Auth initStore")
|
||||
await this.fetchMe()
|
||||
|
||||
const tempStore = useTempStore()
|
||||
|
||||
if(this.profile.temp_config) tempStore.setStoredTempConfig(this.profile.temp_config)
|
||||
if(this.activeTenant > 0) {
|
||||
this.loading = false
|
||||
if(useCapacitor().getIsNative()) {
|
||||
@@ -99,6 +96,8 @@ export const useAuthStore = defineStore("auth", {
|
||||
|
||||
async fetchMe(jwt= null) {
|
||||
console.log("Auth fetchMe")
|
||||
const tempStore = useTempStore()
|
||||
|
||||
try {
|
||||
const me = await useNuxtApp().$api("/api/me", {
|
||||
headers: { Authorization: `Bearer ${jwt}`,
|
||||
@@ -117,6 +116,8 @@ export const useAuthStore = defineStore("auth", {
|
||||
|
||||
this.profile = me.profile
|
||||
|
||||
if(this.profile.temp_config) tempStore.setStoredTempConfig(this.profile.temp_config)
|
||||
|
||||
if(me.activeTenant > 0) {
|
||||
this.activeTenant = me.activeTenant
|
||||
this.activeTenantData = me.tenants.find(i => i.id === me.activeTenant)
|
||||
|
||||
@@ -1088,9 +1088,9 @@ export const useDataStore = defineStore('data', () => {
|
||||
},
|
||||
sortable: true
|
||||
},{
|
||||
key: "phase",
|
||||
key: "active_phase",
|
||||
label: "Phase",
|
||||
component: phase
|
||||
distinct:true
|
||||
},{
|
||||
key: "name",
|
||||
label: "Name",
|
||||
|
||||
@@ -17,6 +17,7 @@ export const useTempStore = defineStore('temp', () => {
|
||||
columns: columns.value,
|
||||
pages: pages.value,
|
||||
settings: settings.value,
|
||||
filters: filters.value
|
||||
}
|
||||
|
||||
await useNuxtApp().$api(`/api/profiles/${auth.profile.id}`,{
|
||||
@@ -30,6 +31,7 @@ export const useTempStore = defineStore('temp', () => {
|
||||
columns.value = config.columns
|
||||
pages.value = config.pages
|
||||
settings.value = config.settings
|
||||
filters.value = config.filters
|
||||
}
|
||||
|
||||
function modifySearchString(type,input) {
|
||||
@@ -42,8 +44,10 @@ export const useTempStore = defineStore('temp', () => {
|
||||
storeTempConfig()
|
||||
}
|
||||
|
||||
function modifyFilter(type,input) {
|
||||
filters.value[type] = input
|
||||
function modifyFilter(domain,type,input) {
|
||||
if(!filters.value[domain]) filters.value[domain] = {}
|
||||
|
||||
filters.value[domain][type] = input
|
||||
storeTempConfig()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user