Skip to content

Commit

Permalink
fixed issue with next/save
Browse files Browse the repository at this point in the history
  • Loading branch information
emilie19 committed Nov 17, 2023
1 parent e1739b3 commit 7702ab8
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/components/CurationList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,14 @@ export default {
alert("failed to load relations: " + error)
})
},
searchNextCurationAPI(){
searchNextCurationAPI(saved_json){
let response_promise = null;
response_promise = this.$backend.fetch_next_occurrence_from_q(this.user_query, this.user_query.occurrence_key)
response_promise.then(response => {
this.updateOccurrenceKey(response.data.subjectOccurrenceKeys[0])
if (saved_json != null){
this.saveJson(saved_json)
}
})
.catch(error => {
alert("There are no more occurrence to process.")
Expand Down Expand Up @@ -519,31 +522,34 @@ export default {
this.$gtag.event('back');
}
},
nosaveNext(){
let go_next = Object.keys(this.change_list).length == 0 || confirm('Are you sure you want to continue without saving?')
if (go_next) {
nosaveNext(saved_data){
var go_next = false
if (saved_data == null){
go_next = Object.keys(this.change_list).length == 0 || confirm('Are you sure you want to continue without saving?')
}
if (go_next || saved_data != null) {
this.in_progress = true
this.empty_elements = []
this.current_page = 1
if (this.user_query.occurrences_keys.length == 0){
this.searchNextCurationAPI()
this.searchNextCurationAPI(saved_data)
}
else {
this.searchNextByList()
}
}
},
saveBack() {
this.save()
this.action = "back"
this.save()
},
saveNext() {
this.save()
this.action = "next"
this.save()
},
saveStop() {
this.save()
this.action = "stop"
this.save()
},
save() {
this.pendingSave = Object.keys(this.change_list);
Expand Down Expand Up @@ -617,17 +623,21 @@ export default {
}
saved_data.push(element)
}
var saved_json = { "occurrenceRelations": saved_data }
if (this.action == "next"){
this.nosaveNext(saved_json)
}
else {
this.saveJson(saved_json)
}
},
saveJson(saved_json){
this.$backend.post_matching(saved_json)
.then(() => {
this.change_list = {}
if (this.action == "back"){
this.nosaveBack()
}
else if (this.action == "next"){
this.nosaveNext()
}
else if (this.action == "stop"){
this.searchCurationAPI()
}
Expand Down

0 comments on commit 7702ab8

Please sign in to comment.