Skip to content

Commit

Permalink
Fix initView after activateValueSet (#1147)
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Sep 10, 2024
1 parent 8b8991d commit b1963de
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions rdmo/projects/static/projects/js/project_questions/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,21 @@ angular.module('project_questions')
service[key] = angular.copy(future[key]);
});

// activate fist valueset
if (angular.isDefined(service.valuesets[service.page.id][service.set_prefix])) {
if (angular.isDefined(past.page) &&
past.page.is_collection &&
past.page.attribute == service.page.attribute &&
!service.settings.project_questions_cycle_sets) {
// use the same set index as before
service.set_index = past.set_index
// activate first or current valueset, but only if the page did actually change
if (angular.isUndefined(past.page) || past.page.id !== page_id) {
if (angular.isDefined(service.valuesets[service.page.id][service.set_prefix])) {
if (angular.isDefined(past.page) &&
past.page.is_collection &&
past.page.attribute == service.page.attribute &&
!service.settings.project_questions_cycle_sets) {
// use the same set index as before
service.set_index = past.set_index
} else {
service.set_index = service.valuesets[service.page.id][service.set_prefix][0].set_index;
}
} else {
service.set_index = service.valuesets[service.page.id][service.set_prefix][0].set_index;
service.set_index = null;
}
} else {
service.set_index = null;
}

// focus the first field
Expand Down Expand Up @@ -1221,13 +1223,13 @@ angular.module('project_questions')
});
};

service.activateValueSet = function(set_prefix) {
service.activateValueSet = function(set_index) {
if (service.settings.project_questions_autosave) {
service.save(false).then(function() {
service.set_index = set_prefix;
service.set_index = set_index;
});
} else {
service.set_index = set_prefix;
service.set_index = set_index;
}
};

Expand Down

0 comments on commit b1963de

Please sign in to comment.