Skip to content

Commit

Permalink
Merge pull request #2279 from bcgov/GWELLS/2265searchResultTablesPersist
Browse files Browse the repository at this point in the history
[GWELLS-2265] Feature** Stores user column preferences in local storagre
  • Loading branch information
dallascrichmond authored Jul 29, 2024
2 parents 6867fd1 + 04f0ae0 commit 29a763d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 10 additions & 6 deletions app/frontend/src/wells/components/SearchColumnSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,10 @@ export default {
const columnIds = [...this.localSelectedColumnIds]
columnIds.sort((columnA, columnB) => {
return this.columnOrders[columnA] - this.columnOrders[columnB]
})
this.$store.commit(SET_SEARCH_RESULT_COLUMNS, columnIds)
this.hideModal()
});
localStorage.setItem('userColumnPreferences', JSON.stringify(columnIds));
this.$store.commit(SET_SEARCH_RESULT_COLUMNS, columnIds);
this.hideModal();
},
cancelChanges () {
this.localSelectedColumnIds = [...this.selectedColumnIds]
Expand All @@ -283,9 +284,12 @@ export default {
}
},
created () {
this.localSelectedColumnIds = [...this.selectedColumnIds]
this.initColumnOrders()
if (localStorage && localStorage.getItem('userColumnPreferences')) {
this.localSelectedColumnIds = JSON.parse(localStorage.getItem('userColumnPreferences'));
} else {
this.localSelectedColumnIds = [...this.selectedColumnIds];
}
this.initColumnOrders();
// listen for reset wells search so we can adjust our selected search columns
this.$store.subscribeAction((action, state) => {
if (action.type === RESET_WELLS_SEARCH) {
Expand Down
4 changes: 4 additions & 0 deletions app/frontend/src/wells/components/SearchResults.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ import SearchResultExports from '@/wells/components/SearchResultExports.vue'
import SearchResultFilter from '@/wells/components/SearchResultFilter.vue'
import SearchColumnSelect from '@/wells/components/SearchColumnSelect.vue'
import filterMixin from '@/wells/components/mixins/filters.js'
import { SET_SEARCH_RESULT_COLUMNS } from '../store/mutations.types'
export default {
mixins: [filterMixin],
Expand Down Expand Up @@ -328,6 +329,9 @@ export default {
}
},
created () {
if(localStorage && localStorage.getItem('userColumnPreferences')) {
this.$store.commit(SET_SEARCH_RESULT_COLUMNS, JSON.parse(localStorage.getItem('userColumnPreferences')));
}
this.initFilterParams()
}
}
Expand Down

0 comments on commit 29a763d

Please sign in to comment.