openchs-models 1.33.43 → 1.33.45

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.
package/dist/Schema.js CHANGED
@@ -181,7 +181,7 @@ function createRealmConfig() {
181
181
  return doCompact;
182
182
  },
183
183
  //order is important, should be arranged according to the dependency
184
- schemaVersion: 210,
184
+ schemaVersion: 211,
185
185
  onMigration: function (oldDB, newDB) {
186
186
  console.log("[AvniModels.Schema]", `Running migration with old schema version: ${oldDB.schemaVersion} and new schema version: ${newDB.schemaVersion}`);
187
187
  if (oldDB.schemaVersion === VersionWithEmbeddedMigrationProblem) throw new Error(`Update from schema version ${VersionWithEmbeddedMigrationProblem} is not allowed. Please uninstall and install app.`);
@@ -76,6 +76,39 @@ class Form extends _BaseEntity.default {
76
76
  set taskScheduleRule(x) {
77
77
  this.that.taskScheduleRule = x;
78
78
  }
79
+ get shareRule() {
80
+ return this.that.shareRule;
81
+ }
82
+ set shareRule(x) {
83
+ this.that.shareRule = x;
84
+ }
85
+ get shareTemplateS3Key() {
86
+ return this.that.shareTemplateS3Key;
87
+ }
88
+ set shareTemplateS3Key(x) {
89
+ this.that.shareTemplateS3Key = x;
90
+ }
91
+ get shareTranslations() {
92
+ return this.that.shareTranslations;
93
+ }
94
+ set shareTranslations(x) {
95
+ this.that.shareTranslations = x;
96
+ }
97
+ hasShareRule() {
98
+ return !_lodash.default.isEmpty(_lodash.default.trim(this.shareRule));
99
+ }
100
+ hasShareTemplate() {
101
+ return !_lodash.default.isEmpty(_lodash.default.trim(this.shareTemplateS3Key));
102
+ }
103
+ getShareTranslations() {
104
+ if (!this.shareTranslations) return {};
105
+ try {
106
+ const parsed = JSON.parse(this.shareTranslations);
107
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
108
+ } catch (e) {
109
+ return {};
110
+ }
111
+ }
79
112
  static safeInstance() {
80
113
  const form = new Form();
81
114
  form.formElementGroups = [];
@@ -88,7 +121,11 @@ class Form extends _BaseEntity.default {
88
121
  return this;
89
122
  }
90
123
  static fromResource(resource, entityService) {
91
- return _General.default.assignFields(resource, new Form(), ["uuid", "name", "formType", "decisionRule", "editFormRule", "visitScheduleRule", "taskScheduleRule", "validationRule", "checklistsRule", "taskScheduleRule"]);
124
+ const form = _General.default.assignFields(resource, new Form(), ["uuid", "name", "formType", "decisionRule", "editFormRule", "visitScheduleRule", "taskScheduleRule", "validationRule", "checklistsRule", "taskScheduleRule", "shareRule", "shareTemplateS3Key"]);
125
+ if (resource && "shareTranslations" in resource) {
126
+ form.shareTranslations = resource.shareTranslations && typeof resource.shareTranslations === "object" ? JSON.stringify(resource.shareTranslations) : null;
127
+ }
128
+ return form;
92
129
  }
93
130
  static associateChild(child, childEntityClass, childResource, entityService) {
94
131
  let form = _BaseEntity.default.getParentEntity(entityService, childEntityClass, childResource, "formUUID", Form.schema.name);
@@ -300,6 +337,18 @@ _defineProperty(Form, "schema", {
300
337
  taskScheduleRule: {
301
338
  type: "string",
302
339
  optional: true
340
+ },
341
+ shareRule: {
342
+ type: "string",
343
+ optional: true
344
+ },
345
+ shareTemplateS3Key: {
346
+ type: "string",
347
+ optional: true
348
+ },
349
+ shareTranslations: {
350
+ type: "string",
351
+ optional: true
303
352
  }
304
353
  }
305
354
  });
@@ -202,7 +202,7 @@ class FormElement extends _BaseEntity.default {
202
202
  return yearDifference <= 2000;
203
203
  }
204
204
  getAnswers() {
205
- const allAnswers = this.concept.getAnswers();
205
+ const allAnswers = this.concept.getAnswers().filter(ca => !ca.concept.voided);
206
206
  if (!_lodash.default.isEmpty(this.answersToShow)) {
207
207
  return _lodash.default.filter(allAnswers, allConceptAnswer => _lodash.default.includes(this.answersToShow, allConceptAnswer.concept.name));
208
208
  } else {
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.33.43",
4
+ "version": "1.33.45",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",