Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions electrostoreFRONT/src/components/Tableau.vue
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,26 @@ export default {
this.sort.key = this.meta.sort;
this.sort.order = this.meta.sortOrder === "desc" ? "desc" : "asc";
}
let savedScrollTop = 0;
if (this.meta?.saveState) {
const saved = sessionStorage.getItem(this._sessionStateKey());
if (saved) {
const state = JSON.parse(saved);
if (state.sort?.key) {
this.sort.key = state.sort.key;
this.sort.order = state.sort.order === "desc" ? "desc" : "asc";
}
savedScrollTop = state.scrollTop || 0;
}
}
let intervalOffset = this.nextOffset;
[this.nextOffset, this.hasMore] = await this.fetchFunction(100, this.nextOffset, this.meta?.expand || [], buildRSQLFilter(this.filters), buildRSQLSort(this.sort));
await this.refetchListData(intervalOffset, this.nextOffset);
this.isInitializing = false;
if (this.meta?.saveState && savedScrollTop > 0) {
await this.$nextTick();
this.$el.scrollTop = savedScrollTop;
}
},
watch: {
filtersValue: {
Expand All @@ -293,6 +309,13 @@ export default {
},
},
methods: {
_sessionStateKey() {
return `tableau_state_${this.$route?.path}_${this.meta?.stateKey || this.meta?.path + this.meta?.key || "default"}`;
},
_saveState(updates) {
const current = JSON.parse(sessionStorage.getItem(this._sessionStateKey()) || "{}");
sessionStorage.setItem(this._sessionStateKey(), JSON.stringify({ ...current, ...updates }));
},
getDataValue(row, labelKey) {
const label = this.labels.find((l) => l.key === labelKey);
if (!label) {
Expand Down Expand Up @@ -356,8 +379,14 @@ export default {
this.sort.key = key;
this.sort.order = "asc";
}
if (this.meta?.saveState) {
this._saveState({ sort: { key: this.sort.key, order: this.sort.order }, scrollTop: 0 });
}
},
async loadNext(e) {
if (this.meta?.saveState) {
this._saveState({ scrollTop: e.target.scrollTop });
}
if (this.totalCount === 0 || this.loading || !this.hasMore) {
return;
}
Expand Down
7 changes: 5 additions & 2 deletions electrostoreFRONT/src/views/CamerasView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ const tableauLabel = ref([
const tableauMeta = ref({
key: "id_camera",
path: "/cameras/",
saveState: true,
stateKey: "camerasTableState",
});
const filterReady = ref(false);
document.querySelector("#view").classList.remove("overflow-y-scroll");
</script>

Expand All @@ -40,9 +43,9 @@ document.querySelector("#view").classList.remove("overflow-y-scroll");
{{ $t('cameras.Add') }}
</span>
</div>
<FilterContainer :filters="filter" :store-data="camerasStore.cameras" />
<FilterContainer :filters="filter" :store-data="camerasStore.cameras" @ready="filterReady = true" :save-state="true" state-key="camerasFilterState" />
</div>
<Tableau :labels="tableauLabel" :meta="tableauMeta"
<Tableau v-if="filterReady" :labels="tableauLabel" :meta="tableauMeta"
:store-data="[camerasStore.cameras,camerasStore.status]"
:filters="filter"
:loading="camerasStore.loading"
Expand Down
7 changes: 5 additions & 2 deletions electrostoreFRONT/src/views/CommandsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ const tableauMeta = ref({
key: "id_command",
path: "/commands/",
expand: ["commands_items"],
saveState: true,
stateKey: "commandsTableState",
});
const filterReady = ref(false);
document.querySelector("#view").classList.remove("overflow-y-scroll");
</script>

Expand All @@ -62,9 +65,9 @@ document.querySelector("#view").classList.remove("overflow-y-scroll");
{{ $t('commands.Add') }}
</RouterLink>
</div>
<FilterContainer :filters="filter" :store-data="commandsStore.commands" />
<FilterContainer :filters="filter" :store-data="commandsStore.commands" @ready="filterReady = true" :save-state="true" state-key="commandsFilterState" />
</div>
<Tableau :labels="tableauLabel" :meta="tableauMeta"
<Tableau v-if="filterReady" :labels="tableauLabel" :meta="tableauMeta"
:store-data="[commandsStore.commands,commandsStore.items,itemsStore.items]"
:filters="filter"
:loading="commandsStore.commandsLoading"
Expand Down
7 changes: 5 additions & 2 deletions electrostoreFRONT/src/views/IAsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ const tableauLabel = ref([
const tableauMeta = ref({
key: "id_ia",
path: "/ia/",
saveState: true,
stateKey: "iasTableState",
});
const filterReady = ref(false);
document.querySelector("#view").classList.remove("overflow-y-scroll");
</script>

Expand All @@ -43,9 +46,9 @@ document.querySelector("#view").classList.remove("overflow-y-scroll");
{{ $t('ias.Add') }}
</span>
</div>
<FilterContainer :filters="filter" :store-data="IAStore.ias" />
<FilterContainer :filters="filter" :store-data="IAStore.ias" @ready="filterReady = true" :save-state="true" state-key="iasFilterState" />
</div>
<Tableau :labels="tableauLabel" :meta="tableauMeta"
<Tableau v-if="filterReady" :labels="tableauLabel" :meta="tableauMeta"
:store-data="[IAStore.ias]"
:filters="filter"
:loading="IAStore.loading"
Expand Down
7 changes: 5 additions & 2 deletions electrostoreFRONT/src/views/InventoryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ const tableauMeta = ref({
key: "id_item",
path: "/inventory/",
expand: ["item_boxs", "item_tags"],
saveState: true,
stateKey: "inventoryTableState",
});
const filterReady = ref(false);
document.querySelector("#view").classList.remove("overflow-y-scroll");
</script>

Expand All @@ -63,9 +66,9 @@ document.querySelector("#view").classList.remove("overflow-y-scroll");
{{ $t('items.Add') }}
</RouterLink>
</div>
<FilterContainer :filters="filter" :store-data="itemsStore.items" />
<FilterContainer :filters="filter" :store-data="itemsStore.items" @ready="filterReady = true" :save-state="true" state-key="inventoryFilterState" />
</div>
<Tableau :labels="tableauLabel" :meta="tableauMeta"
<Tableau v-if="filterReady" :labels="tableauLabel" :meta="tableauMeta"
:store-data="[itemsStore.items,itemsStore.itemTags,tagsStore.tags,itemsStore.thumbnailsURL]"
:filters="filter"
:loading="itemsStore.itemsLoading"
Expand Down
7 changes: 5 additions & 2 deletions electrostoreFRONT/src/views/ProjetTagsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ const tableauLabel = ref([
const tableauMeta = ref({
key: "id_projet_tag",
path: "/projet-tags/",
saveState: true,
stateKey: "projetTagsTableState",
});
const filterReady = ref(false);
document.querySelector("#view").classList.remove("overflow-y-scroll");
</script>

Expand All @@ -32,9 +35,9 @@ document.querySelector("#view").classList.remove("overflow-y-scroll");
{{ $t('projetTags.Add') }}
</RouterLink>
</div>
<FilterContainer :filters="filter" :store-data="projetTagsStore.projetTags" />
<FilterContainer :filters="filter" :store-data="projetTagsStore.projetTags" @ready="filterReady = true" :save-state="true" state-key="projetTagsFilterState" />
</div>
<Tableau :labels="tableauLabel" :meta="tableauMeta"
<Tableau v-if="filterReady" :labels="tableauLabel" :meta="tableauMeta"
:store-data="[projetTagsStore.projetTags]"
:filters="filter"
:loading="projetTagsStore.projetTagsLoading"
Expand Down
7 changes: 5 additions & 2 deletions electrostoreFRONT/src/views/ProjetsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ const tableauMeta = ref({
key: "id_projet",
path: "/projets/",
expand: ["projets_items", "projets_projet_tags"],
saveState: true,
stateKey: "projetsTableState",
});
const filterReady = ref(false);
document.querySelector("#view").classList.remove("overflow-y-scroll");
</script>

Expand All @@ -87,9 +90,9 @@ document.querySelector("#view").classList.remove("overflow-y-scroll");
{{ t('projets.Add') }}
</RouterLink>
</div>
<FilterContainer :filters="filter" :store-data="projetsStore.projets" />
<FilterContainer :filters="filter" :store-data="projetsStore.projets" @ready="filterReady = true" :save-state="true" state-key="projetsFilterState" />
</div>
<Tableau :labels="tableauLabel" :meta="tableauMeta"
<Tableau v-if="filterReady" :labels="tableauLabel" :meta="tableauMeta"
:store-data="[projetsStore.projets,projetsStore.items,itemsStore.items,projetsStore.projetTagProjet,projetTagsStore.projetTags]"
:filters="filter"
:loading="projetsStore.projetsLoading"
Expand Down
7 changes: 5 additions & 2 deletions electrostoreFRONT/src/views/StoresView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ const tableauMeta = ref({
key: "id_store",
path: "/stores/",
expand: ["stores_tags"],
saveState: true,
stateKey: "storesTableState",
});
const filterReady = ref(false);
document.querySelector("#view").classList.remove("overflow-y-scroll");
</script>

Expand All @@ -61,9 +64,9 @@ document.querySelector("#view").classList.remove("overflow-y-scroll");
{{ $t('stores.Add') }}
</span>
</div>
<FilterContainer :filters="filter" :store-data="storesStore.stores" />
<FilterContainer :filters="filter" :store-data="storesStore.stores" @ready="filterReady = true" :save-state="true" state-key="storesFilterState" />
</div>
<Tableau :labels="tableauLabel" :meta="tableauMeta"
<Tableau v-if="filterReady" :labels="tableauLabel" :meta="tableauMeta"
:store-data="[storesStore.stores,storesStore.storeTags,tagsStore.tags]"
:filters="filter"
:loading="storesStore.storesLoading"
Expand Down
7 changes: 5 additions & 2 deletions electrostoreFRONT/src/views/TagsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ const tableauLabel = ref([
const tableauMeta = ref({
key: "id_tag",
path: "/tags/",
saveState: true,
stateKey: "tagsTableState",
});
const filterReady = ref(false);
document.querySelector("#view").classList.remove("overflow-y-scroll");
</script>

Expand All @@ -34,9 +37,9 @@ document.querySelector("#view").classList.remove("overflow-y-scroll");
{{ $t('tags.Add') }}
</RouterLink>
</div>
<FilterContainer :filters="filter" :store-data="tagsStore.tags" />
<FilterContainer :filters="filter" :store-data="tagsStore.tags" @ready="filterReady = true" :save-state="true" state-key="tagsFilterState" />
</div>
<Tableau :labels="tableauLabel" :meta="tableauMeta"
<Tableau v-if="filterReady" :labels="tableauLabel" :meta="tableauMeta"
:store-data="[tagsStore.tags]"
:filters="filter"
:loading="tagsStore.tagsLoading"
Expand Down
7 changes: 5 additions & 2 deletions electrostoreFRONT/src/views/UsersView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ const tableauLabel = ref([
const tableauMeta = ref({
key: "id_user",
path: "/users/",
saveState: true,
stateKey: "usersTableState",
});
const filterReady = ref(false);
document.querySelector("#view").classList.remove("overflow-y-scroll");
</script>

Expand All @@ -56,9 +59,9 @@ document.querySelector("#view").classList.remove("overflow-y-scroll");
{{ $t('users.Add') }}
</span>
</div>
<FilterContainer :filters="filter" :store-data="usersStore.users" />
<FilterContainer :filters="filter" :store-data="usersStore.users" @ready="filterReady = true" :save-state="true" state-key="usersFilterState" />
</div>
<Tableau :labels="tableauLabel" :meta="tableauMeta"
<Tableau v-if="filterReady" :labels="tableauLabel" :meta="tableauMeta"
:store-data="[usersStore.users]"
:filters="filter"
:loading="usersStore.usersLoading"
Expand Down
Loading