Skip to content

Commit

Permalink
Update condition for variable display in datatable-filter-modal-view (#…
Browse files Browse the repository at this point in the history
…291)

* Update condition for variable display in datatable-filter-modal-view

* Refactor condition logic in datatable-filter-modal-view.js for variable display when access is open. Variables that are tagged as 'stigmatized' will be filtered out when access is open; otherwise, all variables will be displayed. This modifies the system behaviour by adding a conditional check for the 'isOpenAccess' session variable.
  • Loading branch information
Gcolon021 authored Mar 26, 2024
1 parent fc106db commit fc80f4b
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,22 @@ define(['backbone', 'handlebars', 'underscore', 'text!search-interface/datatable
let data = this.dtData;
const isOpenAccess = JSON.parse(sessionStorage.getItem('isOpenAccess'));
if(!data){
data = this.model.dtVariables.filter(function (variable) {
// Check if the variable is stigmatized and if it is, don't display it
return isOpenAccess && (variable.result.metadata?.is_stigmatized === "false" || variable.result.metadata?.columnmeta_is_stigmatized === "false");
}).map(function(variable) {
if (isOpenAccess) {
// filter out stigmatized variables
data = this.model.dtVariables.filter(function (variable) {
return variable.result.metadata?.is_stigmatized === "false" || variable.result.metadata?.columnmeta_is_stigmatized === "false";
});
} else {
data = this.model.dtVariables;
}

data = data.map(function(variable) {
let values = variable.result.values.join(", ");
return [
existingFilter ?
(_.find(existingFilter.get('variables'), (conceptPath)=>{
return conceptPath.includes(variable.result.metadata.columnmeta_var_id);
}) !== undefined ? true : false) : false,
(_.find(existingFilter.get('variables'), (conceptPath) => {
return conceptPath.includes(variable.result.metadata.columnmeta_var_id);
}) !== undefined) : false,
variable.result.metadata.columnmeta_var_id,
variable.result.metadata.columnmeta_name,
variable.result.metadata.columnmeta_description,
Expand Down

0 comments on commit fc80f4b

Please sign in to comment.