Skip to content

Commit

Permalink
distinguish des from attrs and pis
Browse files Browse the repository at this point in the history
  • Loading branch information
janhenrikoverland committed Aug 29, 2024
1 parent 95232d4 commit 64e2713
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/api/Dimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ Dimension.prototype.isIgnoreDimension = function() {

// dep 1

const getFullId = dim => (dim.programStage ? dim.programStage.id + '.' : '') + dim.dimension;
const getFullId = dim => (dim.programStage && dim.programStage.id ?
dim.programStage.id + '.' : '') + dim.dimension;

Dimension.prototype.url = function(isSorted, response, isFilter) {
if (this.isIgnoreDimension()) {
Expand Down
23 changes: 17 additions & 6 deletions src/api/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import isNumeric from 'd2-utilizr/lib/isNumeric';
import isObject from 'd2-utilizr/lib/isObject';
import isString from 'd2-utilizr/lib/isString';

import { Record, Layout as d2aLayout } from 'd2-analysis';
import { Record, Layout as d2aLayout, dimensionsInit } from 'd2-analysis';

export var Layout = function(refs, c, applyConfig, forceApplyConfig) {
var t = this;
Expand All @@ -20,6 +20,22 @@ export var Layout = function(refs, c, applyConfig, forceApplyConfig) {
// inherit
Object.assign(t, new d2aLayout(refs, c, applyConfig));

// data element dimensions
if (c.dataElementDimensions) {
t.dataElementDimensions = c.dataElementDimensions;
}

// add isDataElement to distinguish from attributes and program indicators
if (t.dataElementDimensions) {
([].concat(t.columns, t.rows, t.filters))
.filter(dimension => dimension)
.forEach(dimension => {
if (c.dataElementDimensions.find(de => de.dataElement.id === dimension.dimension)) {
dimension.isDataElement = true
}
})
}

// program
t.program = isObject(c.program) ? c.program : null;
t.programStage = isObject(c.programStage) ? c.programStage : null;
Expand Down Expand Up @@ -122,11 +138,6 @@ export var Layout = function(refs, c, applyConfig, forceApplyConfig) {
? c.reportParams.paramParentOrganisationUnit
: isBoolean(c.parentOrganisationUnit) ? c.parentOrganisationUnit : false;

// data element dimensions
if (c.dataElementDimensions) {
t.dataElementDimensions = c.dataElementDimensions;
}

// force apply
Object.assign(t, forceApplyConfig);

Expand Down

0 comments on commit 64e2713

Please sign in to comment.