openchs-models 1.31.78 → 1.31.79

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.
@@ -7,6 +7,10 @@ exports.default = void 0;
7
7
 
8
8
  var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
9
9
 
10
+ var _Dashboard = _interopRequireDefault(require("./Dashboard"));
11
+
12
+ var _General = _interopRequireDefault(require("./utility/General"));
13
+
10
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
15
 
12
16
  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; }
@@ -16,14 +20,6 @@ class CustomDashboardCache extends _BaseEntity.default {
16
20
  super(that);
17
21
  }
18
22
 
19
- get checksum() {
20
- return this.that.checksum;
21
- }
22
-
23
- set checksum(x) {
24
- this.that.checksum = x;
25
- }
26
-
27
23
  get updatedAt() {
28
24
  return this.that.updatedAt;
29
25
  }
@@ -48,84 +44,49 @@ class CustomDashboardCache extends _BaseEntity.default {
48
44
  this.that.filterApplied = x;
49
45
  }
50
46
 
51
- get filterErrorsJSON() {
52
- return this.that.filterErrorsJSON;
53
- }
54
-
55
- set filterErrorsJSON(x) {
56
- this.that.filterErrorsJSON = x;
57
- }
58
-
59
- get ruleInputJSON() {
60
- return this.that.ruleInputJSON;
61
- }
62
-
63
- set ruleInputJSON(x) {
64
- this.that.ruleInputJSON = x;
47
+ get dashboard() {
48
+ return this.toEntity("dashboard", _Dashboard.default);
65
49
  }
66
50
 
67
- get transformedFiltersJSON() {
68
- return this.that.transformedFiltersJSON;
51
+ set dashboard(x) {
52
+ this.that.dashboard = this.fromObject(x);
69
53
  }
70
54
 
71
- set transformedFiltersJSON(x) {
72
- this.that.transformedFiltersJSON = x;
73
- }
74
-
75
- static create(uuid, checksum, updatedAt, selectedValuesJSON, filterApplied, filterErrorsJSON, ruleInputJSON, transformedFiltersJSON) {
55
+ static create(uuid, updatedAt, selectedValuesJSON = '{}', filterApplied) {
76
56
  const customDashboardCache = new CustomDashboardCache();
77
57
  customDashboardCache.uuid = uuid;
78
- customDashboardCache.checksum = checksum;
79
58
  customDashboardCache.updatedAt = updatedAt;
80
59
  customDashboardCache.selectedValuesJSON = selectedValuesJSON;
81
60
  customDashboardCache.filterApplied = filterApplied;
82
- customDashboardCache.filterErrorsJSON = filterErrorsJSON;
83
- customDashboardCache.ruleInputJSON = ruleInputJSON;
84
- customDashboardCache.transformedFiltersJSON = transformedFiltersJSON;
85
61
  return customDashboardCache;
86
62
  }
87
63
 
88
- static getSelectedValuesFromState(state) {
89
- const filterCache = {
90
- date: state.date,
91
- applied: false,
92
- selectedLocations: state.selectedLocations,
93
- selectedCustomFilters: state.selectedCustomFilters,
94
- selectedGenders: state.selectedGenders
95
- };
96
- return filterCache;
97
- }
98
-
99
- static createEmptyInstance() {
100
- return new CustomDashboardCache();
64
+ static newInstance(dashboard) {
65
+ const customDashboardCache = new CustomDashboardCache();
66
+ customDashboardCache.uuid = _General.default.randomUUID();
67
+ customDashboardCache.dashboard = dashboard;
68
+ customDashboardCache.reset();
69
+ return customDashboardCache;
101
70
  }
102
71
 
103
- getChecksum() {
104
- return this.checksum;
72
+ reset() {
73
+ this.filterApplied = false;
74
+ this.selectedValuesJSON = JSON.stringify({});
75
+ this.updatedAt = new Date();
105
76
  }
106
77
 
107
78
  getSelectedValues() {
108
- return this.selectedValuesJSON && JSON.parse(this.selectedValuesJSON) || {};
79
+ return JSON.parse(this.selectedValuesJSON);
109
80
  }
110
81
 
111
- getFilterErrors() {
112
- return this.filterErrorsJSON && JSON.parse(this.filterErrorsJSON) || {};
113
- }
114
-
115
- getRuleInput() {
116
- return this.ruleInputJSON && JSON.parse(this.ruleInputJSON) || {
117
- ruleInputArray: null
118
- };
119
- }
120
-
121
- getTransformedFilters() {
122
- return this.transformedFiltersJSON && JSON.parse(this.transformedFiltersJSON) || {
123
- date: new Date(),
124
- applied: false,
125
- selectedLocations: [],
126
- selectedCustomFilters: [],
127
- selectedGenders: []
128
- };
82
+ clone() {
83
+ const customDashboardCache = new CustomDashboardCache();
84
+ customDashboardCache.uuid = this.uuid;
85
+ customDashboardCache.dashboard = this.dashboard;
86
+ customDashboardCache.updatedAt = this.updatedAt;
87
+ customDashboardCache.selectedValuesJSON = this.selectedValuesJSON;
88
+ customDashboardCache.filterApplied = this.filterApplied;
89
+ return customDashboardCache;
129
90
  }
130
91
 
131
92
  }
@@ -135,16 +96,10 @@ _defineProperty(CustomDashboardCache, "schema", {
135
96
  primaryKey: "uuid",
136
97
  properties: {
137
98
  uuid: "string",
138
- checksum: "string",
99
+ dashboard: "Dashboard",
139
100
  updatedAt: "date",
140
101
  selectedValuesJSON: "string",
141
- filterApplied: {
142
- type: "bool",
143
- default: false
144
- },
145
- filterErrorsJSON: "string",
146
- ruleInputJSON: "string",
147
- transformedFiltersJSON: "string"
102
+ filterApplied: "bool"
148
103
  }
149
104
  });
150
105
 
@@ -26,6 +26,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
26
26
  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; }
27
27
 
28
28
  class ReportCard extends _BaseEntity.default {
29
+ static newReportCard() {
30
+ const reportCard = new ReportCard();
31
+ reportCard.standardReportCardInputSubjectTypes = [];
32
+ reportCard.standardReportCardInputPrograms = [];
33
+ reportCard.standardReportCardInputEncounterTypes = [];
34
+ return reportCard;
35
+ }
36
+
29
37
  constructor(that = null) {
30
38
  super(that);
31
39
  }
@@ -148,9 +156,18 @@ class ReportCard extends _BaseEntity.default {
148
156
  }
149
157
 
150
158
  static fromResource(resource, entityService) {
151
- const reportCard = _General.default.assignFields(resource, new ReportCard(), ["uuid", "name", "query", "description", "colour", "voided", "nested", "countOfCards"]);
159
+ const reportCard = _General.default.assignFields(resource, ReportCard.newReportCard(), ["uuid", "name", "query", "description", "colour", "voided", "nested", "countOfCards"]);
152
160
 
153
161
  reportCard.standardReportCardType = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(resource, "standardReportCardUUID"), _StandardReportCardType.default.schema.name);
162
+ resource.standardReportCardInputSubjectTypes.forEach(uuid => {
163
+ reportCard.standardReportCardInputSubjectTypes.push(entityService.findByUUID(uuid, _SubjectType.default.schema.name));
164
+ });
165
+ resource.standardReportCardInputPrograms.forEach(uuid => {
166
+ reportCard.standardReportCardInputPrograms.push(entityService.findByUUID(uuid, _Program.default.schema.name));
167
+ });
168
+ resource.standardReportCardInputEncounterTypes.forEach(uuid => {
169
+ reportCard.standardReportCardInputEncounterTypes.push(entityService.findByUUID(uuid, _EncounterType.default.schema.name));
170
+ });
154
171
  return reportCard;
155
172
  }
156
173
 
package/dist/Schema.js CHANGED
@@ -279,7 +279,7 @@ function createRealmConfig() {
279
279
  return doCompact;
280
280
  },
281
281
  //order is important, should be arranged according to the dependency
282
- schemaVersion: 190,
282
+ schemaVersion: 191,
283
283
  onMigration: function (oldDB, newDB) {
284
284
  console.log("[AvniModels.Schema]", `Running migration with old schema version: ${oldDB.schemaVersion} and new schema version: ${newDB.schemaVersion}`);
285
285
  if (oldDB.schemaVersion === VersionWithEmbeddedMigrationProblem) throw new Error(`Update from schema version ${VersionWithEmbeddedMigrationProblem} is not allowed. Please uninstall and install app.`);
@@ -913,6 +913,10 @@ function createRealmConfig() {
913
913
  if (oldDB.schemaVersion < 190) {// PlaceHolder for SubjectType.User changes, so that people with previous version of client
914
914
  // are not able to use fastSync of version 190 and above
915
915
  }
916
+
917
+ if (oldDB.schemaVersion < 191) {
918
+ newDB.delete(newDB.objects("CustomDashboardCache"));
919
+ }
916
920
  }
917
921
  };
918
922
  }
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.78",
4
+ "version": "1.31.79",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",