openchs-models 1.31.19 → 1.31.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,10 +13,16 @@ var _ResourceUtil = _interopRequireDefault(require("./utility/ResourceUtil"));
13
13
 
14
14
  var _StandardReportCardType = _interopRequireDefault(require("./StandardReportCardType"));
15
15
 
16
+ var _lodash = _interopRequireDefault(require("lodash"));
17
+
16
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
19
 
18
20
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
21
 
22
+ function throwInvalidIndexError(index, reportCardsLength) {
23
+ throw new Error(`Invalid index ${index} specified for reportCard with length ${reportCardsLength}`);
24
+ }
25
+
20
26
  class ReportCard extends _BaseEntity.default {
21
27
  constructor(that = null) {
22
28
  super(that);
@@ -62,28 +68,60 @@ class ReportCard extends _BaseEntity.default {
62
68
  this.that.colour = x;
63
69
  }
64
70
 
71
+ get nested() {
72
+ return this.that.nested;
73
+ }
74
+
75
+ set nested(x) {
76
+ this.that.nested = x;
77
+ }
78
+
79
+ get initCountOfCards() {
80
+ return this.that.initCountOfCards;
81
+ }
82
+
83
+ set initCountOfCards(x) {
84
+ this.that.initCountOfCards = x;
85
+ }
86
+
65
87
  get iconName() {
66
88
  //TODO: right now not syncing the icon name uploaded from app designer.
67
- return _.isNil(this.standardReportCardType) ? null : this.standardReportCardType.iconName;
89
+ return _lodash.default.isNil(this.standardReportCardType) ? null : this.standardReportCardType.iconName;
68
90
  }
69
91
 
70
92
  get cardColor() {
71
- return _.isNil(this.standardReportCardType) ? this.colour : this.standardReportCardType.cardColor;
93
+ return _lodash.default.isNil(this.standardReportCardType) ? this.colour : this.standardReportCardType.cardColor;
72
94
  }
73
95
 
74
96
  get textColor() {
75
- return _.isNil(this.standardReportCardType) ? '#ffffff' : this.standardReportCardType.textColor;
97
+ return _lodash.default.isNil(this.standardReportCardType) ? '#ffffff' : this.standardReportCardType.textColor;
98
+ }
99
+
100
+ getCardId(index = 0) {
101
+ return this.uuid + '#' + index;
102
+ }
103
+
104
+ getCardName(response, index = 0) {
105
+ return _lodash.default.get(response, `reportCards[${index}].name`) || this.name;
106
+ }
107
+
108
+ getCardColor(response, index = 0) {
109
+ return _lodash.default.get(response, `reportCards[${index}].cardColor`) || this.cardColor;
110
+ }
111
+
112
+ getTextColor(response, index = 0) {
113
+ return _lodash.default.get(response, `reportCards[${index}].textColor`) || this.textColor;
76
114
  }
77
115
 
78
116
  static fromResource(resource, entityService) {
79
- const reportCard = _General.default.assignFields(resource, new ReportCard(), ["uuid", "name", "query", "description", "colour", "voided"]);
117
+ const reportCard = _General.default.assignFields(resource, new ReportCard(), ["uuid", "name", "query", "description", "colour", "voided", "nested", "initCountOfCards"]);
80
118
 
81
119
  reportCard.standardReportCardType = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(resource, "standardReportCardUUID"), _StandardReportCardType.default.schema.name);
82
120
  return reportCard;
83
121
  }
84
122
 
85
123
  isStandardTaskType() {
86
- return _.isNil(this.standardReportCardType) ? false : this.standardReportCardType.isTaskType();
124
+ return _lodash.default.isNil(this.standardReportCardType) ? false : this.standardReportCardType.isTaskType();
87
125
  }
88
126
 
89
127
  }
@@ -110,7 +148,18 @@ _defineProperty(ReportCard, "schema", {
110
148
  voided: {
111
149
  type: "bool",
112
150
  default: false
113
- }
151
+ },
152
+ nested: {
153
+ type: "bool",
154
+ default: false,
155
+ optional: true
156
+ },
157
+ initCountOfCards: {
158
+ type: "int",
159
+ default: 1,
160
+ optional: true
161
+ } //Used only by nested ReportCards
162
+
114
163
  }
115
164
  });
116
165
 
package/dist/Schema.js CHANGED
@@ -202,7 +202,7 @@ const entities = [_DashboardFilter.default, _LocaleMapping.default, _Settings.de
202
202
  function createRealmConfig() {
203
203
  return {
204
204
  //order is important, should be arranged according to the dependency
205
- schemaVersion: 181,
205
+ schemaVersion: 182,
206
206
  onMigration: function (oldDB, newDB) {
207
207
  console.log("[AvniModels.Schema]", `Running migration with old schema version: ${oldDB.schemaVersion} and new schema version: ${newDB.schemaVersion}`);
208
208
 
@@ -798,6 +798,13 @@ function createRealmConfig() {
798
798
  rft.entityId = null;
799
799
  });
800
800
  }
801
+
802
+ if (oldDB.schemaVersion < 182) {
803
+ _lodash.default.forEach(newDB.objects(_ReportCard.default.schema.name), rc => {
804
+ rc.nested = false;
805
+ rc.initCountOfCards = 1;
806
+ });
807
+ }
801
808
  }
802
809
  };
803
810
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "openchs-models",
3
3
  "description": "OpenCHS data model to be used by front end clients",
4
- "version": "1.31.19",
4
+ "version": "1.31.20",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",