Skip to content

Commit

Permalink
Prevent multiple calls to concept set list when loading cohort editor
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonysena committed Oct 2, 2023
1 parent cb1a150 commit 74e95ac
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
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)
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;
}

Expand Down

0 comments on commit 74e95ac

Please sign in to comment.