Skip to content

Commit

Permalink
redirect to the position of the last selected occurrence
Browse files Browse the repository at this point in the history
  • Loading branch information
emilie19 committed Jan 13, 2023
1 parent ecd644c commit ac809c9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/components/OccurrencesElement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ import shared_fields from '@/components/shared_fields.js'
page: {
type: Number,
required: true
}
},
index: {
type: Number,
required: true
},
},
data() {
return {
Expand Down Expand Up @@ -65,11 +69,12 @@ import shared_fields from '@/components/shared_fields.js'
},
},
methods:{
...mapActions(['updateOccurrences', 'updateOccurrencesSelection', 'updateStep', 'updatePage']),
...mapActions(['updateOccurrences', 'updateOccurrencesSelection', 'updateStep', 'updatePage', 'updatePositionDisplay']),
displaySpecimen(){
this.updateOccurrencesSelection(this.occurrence)
this.updateStep(3)
this.updatePage(this.page)
this.updatePositionDisplay("#"+this.page+"_"+this.index)
this.$router.push({
name: this.$router.currentRoute.name,
query: {
Expand Down
9 changes: 5 additions & 4 deletions src/components/OccurrencesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
<th style="width:5%"></th>
</tr>

<OccurrencesElement
v-for="occurrence in processed_occurrences.slice(item_min, item_max)"
:key="occurrence.gbifID" :occurrence="occurrence" :page="current_page" />
<OccurrencesElement :id="current_page+'_'+index"
v-for="(occurrence, index) in processed_occurrences.slice(item_min, item_max)"
:key="occurrence.gbifID" :occurrence="occurrence" :page="current_page" :index="index" />

</table>

Expand Down Expand Up @@ -124,7 +124,7 @@ export default {
};
},
computed: {
...mapState(['page_selection', 'institution_selection', 'datasets_selection', 'occurrence_keys', 'format_selection', 'user_selection', 'filters', 'fields', 'format_selection', 'urls_parameters', 'step', 'theme_color']),
...mapState(['page_selection', 'position_display', 'institution_selection', 'datasets_selection', 'occurrence_keys', 'format_selection', 'user_selection', 'filters', 'fields', 'format_selection', 'urls_parameters', 'step', 'theme_color']),
cssVars() {
return {
'--color': this.theme_color.main,
Expand Down Expand Up @@ -199,6 +199,7 @@ export default {
this.current_page = this.page_selection
this.in_progress = false
this.goToTop()
this.$router.push({ name: 'HomePage', hash: this.position_display, query: this.$route.query}).catch(()=>{});
if (!reload && this.urls_parameters.occurrence != null) {
for (let index in occ) {
if (occ[index].key == this.urls_parameters.occurrence) {
Expand Down
7 changes: 7 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default new Vuex.Store({
format_selection: null,
matching: null,
page_selection: 1,
position_display: "",
fields: {
matcit_specimen: {
format_occurrence: {
Expand Down Expand Up @@ -174,6 +175,9 @@ export default new Vuex.Store({
UPDATE_PAGE(state, value) {
state.page_selection = value
},
UPDATE_POSITION_DISPLAY(state, value) {
state.position_display = value
},
UPDATE_USER(state, value) {
state.user = value
window.sessionStorage.setItem('user', JSON.stringify(value));
Expand Down Expand Up @@ -232,6 +236,9 @@ export default new Vuex.Store({
updatePage(context, value){
context.commit('UPDATE_PAGE', value)
},
updatePositionDisplay(context, value){
context.commit('UPDATE_POSITION_DISPLAY', value)
},
updateOrcidUser(context, user) {
/* an example of user is {name: "John Doe", orcid: "", orcidToken: ""} */
context.commit('UPDATE_USER', user)
Expand Down

0 comments on commit ac809c9

Please sign in to comment.