Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent multiple calls to concept set list when loading cohort editor #2888

Merged
merged 3 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions js/components/atlas.cohort-editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<div class="modal-header" data-bind="text: ko.i18n('components.atlasCohortEditor.importConceptSet', 'Import Concept Set From Repository...')"></div>
<div class="paddedWrapper">
<concept-set-browser params="
showModal: $component.showModal,
criteriaContext: $component.criteriaContext,
cohortConceptSets: $component.currentCohortDefinition().expression().ConceptSets,
onActionComplete: $component.onAtlasConceptSetSelectAction,
Expand Down
19 changes: 16 additions & 3 deletions js/components/circe/components/ConceptSetBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ define([
self.repositoryConceptSetTableId = params.repositoryConceptSetTableId || "repositoryConceptSetTable";

self.loading = ko.observable(false);
self.showModal = params.showModal;
self.isComponentUsedAsModal = ko.pureComputed(function() {
return(ko.isObservable(self.showModal))
});
self.repositoryConceptSets = ko.observableArray();
self.isProcessing = ko.observable(false);

Expand Down Expand Up @@ -125,9 +129,18 @@ define([

// dispose subscriptions

// startup actions
self.loadConceptSetsFromRepository(self.selectedSource()
.url);
if (self.isComponentUsedAsModal()) {
// Add subscription to load concept set
// list when the modal is displayed
self.showModal.subscribe(() => {
if (self.showModal()){
self.loadConceptSetsFromRepository(self.selectedSource().url);
}
});
} else {
// startup actions
self.loadConceptSetsFromRepository(self.selectedSource().url);
}

this.options = {
Facets: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ <h2 class="selected-reusable-name" data-bind="text: selectedReusable().name"></h
<div class="modal-header" data-bind="text: ko.i18n('components.conceptSetBuilder.selectConceptSet', 'Select Concept Set...')"></div>
<div class="paddedWrapper">
<concept-set-browser params="
showModal: showCsBrowser,
repositoryConceptSetTableId: generateCsTableId(),
criteriaContext: criteriaContext,
cohortConceptSets: ko.observableArray(),
Expand Down
2 changes: 1 addition & 1 deletion js/extensions/bindings/datatableBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ define([
table.clear();

// Rebuild table from data source specified in binding
if (data.length > 0)
if (data && data.length > 0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is unrelated to the referenced issue. This fixes an error whereby the data object is not defined and so calling .length causes an error in the browser.

table.rows.add(data);

// drawing may access observables, which updating we do not want to trigger a redraw to the table
Expand Down
4 changes: 3 additions & 1 deletion js/services/AuthAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,9 @@ define(function(require, exports) {

const executeWithRefresh = async function(httpPromise) {
const result = await httpPromise;
await refreshToken();
if (config.userAuthenticationEnabled) {
await refreshToken();
}
return result;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is also unrelated to the referenced issue. This addition fixes a bug that prevents running Atlas when security is disabled.

}

Expand Down
Loading