openchs-models 1.31.62 → 1.31.64

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.
@@ -298,6 +298,11 @@ class FormElement extends _BaseEntity.default {
298
298
  return _lodash.default.isNil(repeatable) ? false : repeatable.getValue();
299
299
  }
300
300
 
301
+ get disableManualActions() {
302
+ const disableManualActions = this.recordByKey("disableManualActions");
303
+ return _lodash.default.isNil(disableManualActions) ? false : disableManualActions.getValue();
304
+ }
305
+
301
306
  get datePickerMode() {
302
307
  const datePickerMode = this.recordByKey("datePickerMode");
303
308
  return _lodash.default.isNil(datePickerMode) ? null : datePickerMode.getValue();
@@ -398,6 +403,10 @@ class FormElement extends _BaseEntity.default {
398
403
  return _lodash.default.find(this.formElementGroup.getFormElements(), fe => fe.uuid === this.groupUuid);
399
404
  }
400
405
 
406
+ isRepeatableQuestionGroup() {
407
+ return this.concept.isQuestionGroup() && this.repeatable;
408
+ }
409
+
401
410
  clone() {
402
411
  const formElement = this.newFormElement();
403
412
  formElement.uuid = this.uuid;
package/dist/index.js CHANGED
@@ -783,6 +783,12 @@ Object.defineProperty(exports, "DashboardCacheFilter", {
783
783
  return _DashboardCacheFilter.default;
784
784
  }
785
785
  });
786
+ Object.defineProperty(exports, "JSONStringify", {
787
+ enumerable: true,
788
+ get: function () {
789
+ return _JsonStringify.JSONStringify;
790
+ }
791
+ });
786
792
 
787
793
  var _AbstractEncounter = _interopRequireDefault(require("./AbstractEncounter"));
788
794
 
@@ -1034,6 +1040,8 @@ var _AgeUtil = _interopRequireDefault(require("./utility/AgeUtil"));
1034
1040
 
1035
1041
  var _DashboardCacheFilter = _interopRequireDefault(require("./application/DashboardCacheFilter"));
1036
1042
 
1043
+ var _JsonStringify = require("./utility/JsonStringify");
1044
+
1037
1045
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
1038
1046
 
1039
1047
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.JSONStringify = void 0;
7
+
8
+ var _lodash = _interopRequireDefault(require("lodash"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ //initial code from : https://javascript.plainenglish.io/create-your-own-implementation-of-json-stringify-simiplied-version-8ab6746cdd1
13
+ const isArray = function (value) {
14
+ return Array.isArray(value) && typeof value === 'object';
15
+ };
16
+
17
+ const isObject = function (value) {
18
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
19
+ };
20
+
21
+ const isString = function (value) {
22
+ return typeof value === 'string';
23
+ };
24
+
25
+ const isBoolean = function (value) {
26
+ return typeof value === 'boolean';
27
+ };
28
+
29
+ const isNumber = function (value) {
30
+ return typeof value === 'number';
31
+ }; // Common check for number, string and boolean value
32
+
33
+
34
+ const restOfDataTypes = function (value) {
35
+ return isNumber(value) || isString(value) || isBoolean(value);
36
+ }; // This function will be used to remove extra comma from the arrays and object
37
+
38
+
39
+ const removeComma = function (str) {
40
+ const tempArr = str.split('');
41
+ tempArr.pop();
42
+ return tempArr.join('');
43
+ };
44
+
45
+ const duckCheckNativeRealmCollection = function (obj) {
46
+ return typeof obj === "object" && !_lodash.default.isNil(_lodash.default.get(obj, "removeAllListeners")) && !_lodash.default.isNil(_lodash.default.get(obj, "snapshot"));
47
+ };
48
+
49
+ function duckCheckForError(obj) {
50
+ return obj.stack && obj.message;
51
+ }
52
+
53
+ const JSONStringifyInternal = function (obj, depth, objectMap, arrayWidth, objectKey) {
54
+ if (depth === 0) return "BELOW_DEPTH"; // Boolean and Number behave in a same way and String we need to add extra quotes
55
+
56
+ if (restOfDataTypes(obj)) {
57
+ const passQuotes = isString(obj) ? `"` : '';
58
+ return `${passQuotes}${obj}${passQuotes}`;
59
+ } // Recursive function call for Arrays to handle nested arrays
60
+
61
+
62
+ if (isArray(obj)) {
63
+ let arrStr = '';
64
+ obj.forEach((eachValue, index) => {
65
+ if (index === arrayWidth) arrStr += "....";
66
+ if (index >= arrayWidth) return;
67
+ arrStr += JSONStringifyInternal(eachValue, depth - 1, objectMap, arrayWidth);
68
+ arrStr += ',';
69
+ });
70
+ return `[` + removeComma(arrStr) + `]`;
71
+ }
72
+
73
+ if (duckCheckNativeRealmCollection(obj, objectKey)) {
74
+ return "<realm-collection>";
75
+ } // Recursive function call for Object to handle nested Object
76
+
77
+
78
+ if (isObject(obj) && _lodash.default.isNil(objectMap.get(obj))) {
79
+ objectMap.set(obj, true);
80
+ let objStr = '';
81
+ const objKeys = Object.keys(obj);
82
+ objKeys.forEach(eachKey => {
83
+ const eachValue = obj[eachKey];
84
+ objStr += `"${eachKey}":${JSONStringifyInternal(eachValue, depth - 1, objectMap, arrayWidth, eachKey)},`;
85
+ });
86
+
87
+ if (duckCheckForError(obj)) {
88
+ objStr += `message:${obj.message},`;
89
+ objStr += `stack:${obj.stack},`;
90
+ }
91
+
92
+ return `{` + removeComma(objStr) + `}`;
93
+ } else if (!_lodash.default.isNil(objectMap.get(obj))) {
94
+ return "<object_repeated>";
95
+ } else {
96
+ return obj;
97
+ }
98
+ }; // This class is not meant for production purposes, it is to be used for developer assistance like logging.
99
+ // It supports recursive object structure, native realm collection, restricting array width (number of elements that can be stringified), and object tree depth
100
+
101
+
102
+ const JSONStringify = function (obj, objectTreeDepth = 3, arrayWidth = 4) {
103
+ const objectMap = new Map();
104
+ return JSONStringifyInternal(obj, objectTreeDepth, objectMap, arrayWidth);
105
+ };
106
+
107
+ exports.JSONStringify = JSONStringify;
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.62",
4
+ "version": "1.31.64",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",