Skip to content

Commit

Permalink
Merge pull request rdmorganiser#820 from rdmorganiser/fix_projects_qu…
Browse files Browse the repository at this point in the history
…estions_refresh

Fix optionset refresh in projects_questions (rdmorganiser#819)
  • Loading branch information
jochenklar authored Nov 24, 2023
2 parents 3a5c294 + 472e3e7 commit 5e63c75
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions rdmo/projects/static/projects/js/project_questions/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ angular.module('project_questions')
service.prev = function() {
service.error = null; // reset error when moving to previous questionset
if (service.settings.project_questions_autosave) {
service.save(false).then(function() {
service.save(false, true).then(function() {
back = true;
service.initView(service.page.prev_page);
})
Expand All @@ -885,7 +885,7 @@ angular.module('project_questions')
service.next = function() {
service.error = null; // reset error when moving to next questionset
if (service.settings.project_questions_autosave) {
service.save(false).then(function() {
service.save(false, true).then(function() {
service.initView(service.page.next_page);
})
} else {
Expand All @@ -896,7 +896,7 @@ angular.module('project_questions')
service.jump = function(section, page) {
service.error = null; // reset error before saving
if (service.settings.project_questions_autosave) {
service.save(false).then(function() {
service.save(false, true).then(function() {
if (service.error !== null) {
// pass, dont jump
} else if (angular.isDefined(page)) {
Expand All @@ -918,7 +918,7 @@ angular.module('project_questions')
}
};

service.save = function(proceed) {
service.save = function(proceed, jump) {
service.error = null; // reset error
return service.storeValues().then(function() {
if (service.error !== null) {
Expand Down Expand Up @@ -969,19 +969,20 @@ angular.module('project_questions')
}

// check if we need to refresh the site
angular.forEach([service.page].concat(service.questionsets), function(questionset) {
angular.forEach(questionset.elements, function(element) {
if (element.model == 'questions.question') {
var question = element;
angular.forEach(question.optionsets, function(optionset) {
if (optionset.has_refresh) {
return service.initView(service.page.id);
}
});
}
if (angular.isUndefined(jump) || !jump) {
angular.forEach([service.page].concat(service.questionsets), function(questionset) {
angular.forEach(questionset.elements, function(element) {
if (element.model == 'questions.question') {
var question = element;
angular.forEach(question.optionsets, function(optionset) {
if (optionset.has_refresh) {
return service.initView(service.page.id);
}
});
}
});
});
});

}
// re-evaluate conditions
angular.forEach([service.page].concat(service.questionsets), function(questionset) {
angular.forEach(service.valuesets[questionset.id], function(valuesets, set_prefix) {
Expand Down

0 comments on commit 5e63c75

Please sign in to comment.