@beinformed/ui 1.65.3 → 1.65.5

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/esm/hooks/__tests__/UseModularUIModel.spec.js.flow +3 -5
  3. package/esm/hooks/useList.js +7 -6
  4. package/esm/hooks/useList.js.flow +7 -6
  5. package/esm/hooks/useList.js.map +1 -1
  6. package/esm/models/concepts/ConceptIndexModel.js +3 -2
  7. package/esm/models/concepts/ConceptIndexModel.js.flow +5 -4
  8. package/esm/models/concepts/ConceptIndexModel.js.map +1 -1
  9. package/esm/models/content/ContentIndexModel.js +7 -1
  10. package/esm/models/content/ContentIndexModel.js.flow +8 -3
  11. package/esm/models/content/ContentIndexModel.js.map +1 -1
  12. package/esm/models/content/ContentModel.js +3 -2
  13. package/esm/models/content/ContentModel.js.flow +4 -3
  14. package/esm/models/content/ContentModel.js.map +1 -1
  15. package/esm/models/content/ContentTOCModel.js +6 -2
  16. package/esm/models/content/ContentTOCModel.js.flow +6 -2
  17. package/esm/models/content/ContentTOCModel.js.map +1 -1
  18. package/esm/models/filters/AssignmentFilterModel.js +54 -26
  19. package/esm/models/filters/AssignmentFilterModel.js.flow +68 -37
  20. package/esm/models/filters/AssignmentFilterModel.js.map +1 -1
  21. package/esm/models/filters/BaseFilterModel.js +0 -110
  22. package/esm/models/filters/BaseFilterModel.js.flow +2 -133
  23. package/esm/models/filters/BaseFilterModel.js.map +1 -1
  24. package/esm/models/filters/ConceptIndexFilterModel.js +2 -2
  25. package/esm/models/filters/ConceptIndexFilterModel.js.flow +2 -2
  26. package/esm/models/filters/ConceptIndexFilterModel.js.map +1 -1
  27. package/esm/models/filters/FilterModel.js +117 -2
  28. package/esm/models/filters/FilterModel.js.flow +146 -1
  29. package/esm/models/filters/FilterModel.js.map +1 -1
  30. package/esm/models/filters/RangeFilterModel.js +2 -2
  31. package/esm/models/filters/RangeFilterModel.js.flow +2 -2
  32. package/esm/models/filters/RangeFilterModel.js.map +1 -1
  33. package/esm/models/types.js.flow +1 -3
  34. package/esm/models/types.js.map +1 -1
  35. package/lib/hooks/useList.js +7 -6
  36. package/lib/hooks/useList.js.map +1 -1
  37. package/lib/models/concepts/ConceptIndexModel.js +3 -2
  38. package/lib/models/concepts/ConceptIndexModel.js.map +1 -1
  39. package/lib/models/content/ContentIndexModel.js +6 -1
  40. package/lib/models/content/ContentIndexModel.js.map +1 -1
  41. package/lib/models/content/ContentModel.js +3 -2
  42. package/lib/models/content/ContentModel.js.map +1 -1
  43. package/lib/models/content/ContentTOCModel.js +6 -2
  44. package/lib/models/content/ContentTOCModel.js.map +1 -1
  45. package/lib/models/filters/AssignmentFilterModel.js +54 -26
  46. package/lib/models/filters/AssignmentFilterModel.js.map +1 -1
  47. package/lib/models/filters/BaseFilterModel.js +0 -109
  48. package/lib/models/filters/BaseFilterModel.js.map +1 -1
  49. package/lib/models/filters/ConceptIndexFilterModel.js +2 -2
  50. package/lib/models/filters/ConceptIndexFilterModel.js.map +1 -1
  51. package/lib/models/filters/FilterModel.js +117 -1
  52. package/lib/models/filters/FilterModel.js.map +1 -1
  53. package/lib/models/filters/RangeFilterModel.js +2 -2
  54. package/lib/models/filters/RangeFilterModel.js.map +1 -1
  55. package/lib/models/types.js.map +1 -1
  56. package/package.json +1 -1
  57. package/src/hooks/__tests__/UseModularUIModel.spec.js +3 -5
  58. package/src/hooks/useList.js +7 -6
  59. package/src/models/concepts/ConceptIndexModel.js +5 -4
  60. package/src/models/content/ContentIndexModel.js +8 -3
  61. package/src/models/content/ContentModel.js +4 -3
  62. package/src/models/content/ContentTOCModel.js +6 -2
  63. package/src/models/filters/AssignmentFilterModel.js +68 -37
  64. package/src/models/filters/BaseFilterModel.js +2 -133
  65. package/src/models/filters/ConceptIndexFilterModel.js +2 -2
  66. package/src/models/filters/FilterModel.js +146 -1
  67. package/src/models/filters/RangeFilterModel.js +2 -2
  68. package/src/models/types.js +1 -3
@@ -5,9 +5,125 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
8
9
  var _BaseFilterModel = _interopRequireDefault(require("../filters/BaseFilterModel"));
10
+ var _createAttribute = _interopRequireDefault(require("../attributes/_createAttribute"));
11
+ var _exceptions = require("../../exceptions");
9
12
  /**
10
13
  */
11
- class FilterModel extends _BaseFilterModel.default {}
14
+ class FilterModel extends _BaseFilterModel.default {
15
+ /**
16
+ */
17
+ constructor(data, contributions, modelOptions) {
18
+ super(data, contributions, modelOptions);
19
+ (0, _defineProperty2.default)(this, "_attribute", null);
20
+ this._attribute = this.createAttribute(this.type, this.param, this.data, this.contributions);
21
+ }
22
+
23
+ /**
24
+ * Create attribute through the attribute factory. Create type based on filter key without the filter suffix
25
+ */
26
+ createAttribute(type, param, data, contributions) {
27
+ if (type === "assignment") {
28
+ return null;
29
+ }
30
+ return (0, _createAttribute.default)(param, data, {
31
+ ...contributions,
32
+ type: type
33
+ }, this.modelOptions);
34
+ }
35
+
36
+ /**
37
+ * Get attribute of filter
38
+ */
39
+ get attribute() {
40
+ if (!this._attribute) {
41
+ throw new _exceptions.IllegalStateException(`Missing filter attribute on filter model: ${this.label}`);
42
+ }
43
+ return this._attribute;
44
+ }
45
+
46
+ /**
47
+ * Retrieve the parameters with it's value for this filter
48
+ */
49
+ get params() {
50
+ if (!this.param) {
51
+ return [];
52
+ }
53
+ return [{
54
+ name: this.param,
55
+ value: this.attribute?.value
56
+ }];
57
+ }
58
+
59
+ /**
60
+ * Getting the value of the filter
61
+ */
62
+ get value() {
63
+ return this.attribute?.value;
64
+ }
65
+
66
+ /**
67
+ * Getting the inputvalue of the filter
68
+ */
69
+ get inputvalue() {
70
+ return this.attribute?.inputvalue;
71
+ }
72
+
73
+ /**
74
+ * Indicates if the filter has a value.
75
+ */
76
+ hasValue() {
77
+ return this.value !== null && this.value !== "";
78
+ }
79
+
80
+ /**
81
+ * Reset the value of this filter to undefined
82
+ */
83
+ reset() {
84
+ if (this.attribute) {
85
+ this.attribute.reset();
86
+ }
87
+ return this;
88
+ }
89
+
90
+ /**
91
+ * Update this filter with input name and value
92
+ */
93
+ update(attribute, value) {
94
+ if (this.attribute) {
95
+ this.attribute.update(value);
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Inidiates if filter is active
101
+ */
102
+ isActive() {
103
+ return this.attribute?.initvalue !== null;
104
+ }
105
+
106
+ /**
107
+ * Inidiates if filter is valid
108
+ */
109
+ get isValid() {
110
+ return this.attribute?.isValid || true;
111
+ }
112
+
113
+ /**
114
+ */
115
+ get readonlyvalue() {
116
+ if (this.attribute) {
117
+ return this.attribute.readonlyvalue;
118
+ }
119
+ return "";
120
+ }
121
+
122
+ /**
123
+ */
124
+ get formdata() {
125
+ return this.attribute.formdata ?? null;
126
+ }
127
+ }
12
128
  exports.default = FilterModel;
13
129
  //# sourceMappingURL=FilterModel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FilterModel.js","names":["_BaseFilterModel","_interopRequireDefault","require","FilterModel","BaseFilterModel","exports","default"],"sources":["../../../src/models/filters/FilterModel.js"],"sourcesContent":["// @flow\nimport BaseFilterModel from \"../filters/BaseFilterModel\";\n\n/**\n */\nexport default class FilterModel extends BaseFilterModel {}\n"],"mappings":";;;;;;;AACA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA;AACA;AACe,MAAMC,WAAW,SAASC,wBAAe,CAAC;AAAEC,OAAA,CAAAC,OAAA,GAAAH,WAAA","ignoreList":[]}
1
+ {"version":3,"file":"FilterModel.js","names":["_BaseFilterModel","_interopRequireDefault","require","_createAttribute","_exceptions","FilterModel","BaseFilterModel","constructor","data","contributions","modelOptions","_defineProperty2","default","_attribute","createAttribute","type","param","attribute","IllegalStateException","label","params","name","value","inputvalue","hasValue","reset","update","isActive","initvalue","isValid","readonlyvalue","formdata","exports"],"sources":["../../../src/models/filters/FilterModel.js"],"sourcesContent":["// @flow\nimport BaseFilterModel from \"../filters/BaseFilterModel\";\nimport createAttribute from \"../attributes/_createAttribute\";\nimport { IllegalStateException } from \"../../exceptions\";\n\nimport type { AttributeType, FilterType, ModelOptions } from \"../types\";\n\n/**\n */\nexport default class FilterModel extends BaseFilterModel {\n _attribute: AttributeType | null = null;\n\n /**\n */\n constructor(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(data, contributions, modelOptions);\n\n this._attribute = this.createAttribute(\n this.type,\n this.param,\n this.data,\n this.contributions,\n );\n }\n\n /**\n * Create attribute through the attribute factory. Create type based on filter key without the filter suffix\n */\n createAttribute(\n type: string,\n param: string,\n data: Object,\n contributions: Object,\n ): AttributeType | null {\n if (type === \"assignment\") {\n return null;\n }\n\n return createAttribute(\n param,\n data,\n {\n ...contributions,\n type: type,\n },\n this.modelOptions,\n );\n }\n\n /**\n * Get attribute of filter\n */\n get attribute(): AttributeType {\n if (!this._attribute) {\n throw new IllegalStateException(\n `Missing filter attribute on filter model: ${this.label}`,\n );\n }\n return this._attribute;\n }\n\n /**\n * Retrieve the parameters with it's value for this filter\n */\n get params(): Array<{ name: string, value: ?string }> {\n if (!this.param) {\n return [];\n }\n\n return [\n {\n name: this.param,\n value: this.attribute?.value,\n },\n ];\n }\n\n /**\n * Getting the value of the filter\n */\n get value(): string | null {\n return this.attribute?.value;\n }\n\n /**\n * Getting the inputvalue of the filter\n */\n get inputvalue(): string {\n return this.attribute?.inputvalue;\n }\n\n /**\n * Indicates if the filter has a value.\n */\n hasValue(): boolean {\n return this.value !== null && this.value !== \"\";\n }\n\n /**\n * Reset the value of this filter to undefined\n */\n reset(): FilterType {\n if (this.attribute) {\n this.attribute.reset();\n }\n\n return this;\n }\n\n /**\n * Update this filter with input name and value\n */\n update(attribute: AttributeType, value: string) {\n if (this.attribute) {\n this.attribute.update(value);\n }\n }\n\n /**\n * Inidiates if filter is active\n */\n isActive(): boolean {\n return this.attribute?.initvalue !== null;\n }\n\n /**\n * Inidiates if filter is valid\n */\n get isValid(): boolean {\n return this.attribute?.isValid || true;\n }\n\n /**\n */\n get readonlyvalue(): string {\n if (this.attribute) {\n return this.attribute.readonlyvalue;\n }\n return \"\";\n }\n\n /**\n */\n get formdata(): { [string]: any } | null {\n return this.attribute.formdata ?? null;\n }\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAIA;AACA;AACe,MAAMG,WAAW,SAASC,wBAAe,CAAC;EAGvD;AACF;EACEC,WAAWA,CACTC,IAAY,EACZC,aAAqB,EACrBC,YAA2B,EAC3B;IACA,KAAK,CAACF,IAAI,EAAEC,aAAa,EAAEC,YAAY,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA,sBATR,IAAI;IAWrC,IAAI,CAACC,UAAU,GAAG,IAAI,CAACC,eAAe,CACpC,IAAI,CAACC,IAAI,EACT,IAAI,CAACC,KAAK,EACV,IAAI,CAACR,IAAI,EACT,IAAI,CAACC,aACP,CAAC;EACH;;EAEA;AACF;AACA;EACEK,eAAeA,CACbC,IAAY,EACZC,KAAa,EACbR,IAAY,EACZC,aAAqB,EACC;IACtB,IAAIM,IAAI,KAAK,YAAY,EAAE;MACzB,OAAO,IAAI;IACb;IAEA,OAAO,IAAAD,wBAAe,EACpBE,KAAK,EACLR,IAAI,EACJ;MACE,GAAGC,aAAa;MAChBM,IAAI,EAAEA;IACR,CAAC,EACD,IAAI,CAACL,YACP,CAAC;EACH;;EAEA;AACF;AACA;EACE,IAAIO,SAASA,CAAA,EAAkB;IAC7B,IAAI,CAAC,IAAI,CAACJ,UAAU,EAAE;MACpB,MAAM,IAAIK,iCAAqB,CAC7B,6CAA6C,IAAI,CAACC,KAAK,EACzD,CAAC;IACH;IACA,OAAO,IAAI,CAACN,UAAU;EACxB;;EAEA;AACF;AACA;EACE,IAAIO,MAAMA,CAAA,EAA4C;IACpD,IAAI,CAAC,IAAI,CAACJ,KAAK,EAAE;MACf,OAAO,EAAE;IACX;IAEA,OAAO,CACL;MACEK,IAAI,EAAE,IAAI,CAACL,KAAK;MAChBM,KAAK,EAAE,IAAI,CAACL,SAAS,EAAEK;IACzB,CAAC,CACF;EACH;;EAEA;AACF;AACA;EACE,IAAIA,KAAKA,CAAA,EAAkB;IACzB,OAAO,IAAI,CAACL,SAAS,EAAEK,KAAK;EAC9B;;EAEA;AACF;AACA;EACE,IAAIC,UAAUA,CAAA,EAAW;IACvB,OAAO,IAAI,CAACN,SAAS,EAAEM,UAAU;EACnC;;EAEA;AACF;AACA;EACEC,QAAQA,CAAA,EAAY;IAClB,OAAO,IAAI,CAACF,KAAK,KAAK,IAAI,IAAI,IAAI,CAACA,KAAK,KAAK,EAAE;EACjD;;EAEA;AACF;AACA;EACEG,KAAKA,CAAA,EAAe;IAClB,IAAI,IAAI,CAACR,SAAS,EAAE;MAClB,IAAI,CAACA,SAAS,CAACQ,KAAK,CAAC,CAAC;IACxB;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;AACA;EACEC,MAAMA,CAACT,SAAwB,EAAEK,KAAa,EAAE;IAC9C,IAAI,IAAI,CAACL,SAAS,EAAE;MAClB,IAAI,CAACA,SAAS,CAACS,MAAM,CAACJ,KAAK,CAAC;IAC9B;EACF;;EAEA;AACF;AACA;EACEK,QAAQA,CAAA,EAAY;IAClB,OAAO,IAAI,CAACV,SAAS,EAAEW,SAAS,KAAK,IAAI;EAC3C;;EAEA;AACF;AACA;EACE,IAAIC,OAAOA,CAAA,EAAY;IACrB,OAAO,IAAI,CAACZ,SAAS,EAAEY,OAAO,IAAI,IAAI;EACxC;;EAEA;AACF;EACE,IAAIC,aAAaA,CAAA,EAAW;IAC1B,IAAI,IAAI,CAACb,SAAS,EAAE;MAClB,OAAO,IAAI,CAACA,SAAS,CAACa,aAAa;IACrC;IACA,OAAO,EAAE;EACX;;EAEA;AACF;EACE,IAAIC,QAAQA,CAAA,EAA6B;IACvC,OAAO,IAAI,CAACd,SAAS,CAACc,QAAQ,IAAI,IAAI;EACxC;AACF;AAACC,OAAA,CAAApB,OAAA,GAAAP,WAAA","ignoreList":[]}
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
9
- var _BaseFilterModel = _interopRequireDefault(require("../filters/BaseFilterModel"));
9
+ var _FilterModel = _interopRequireDefault(require("../filters/FilterModel"));
10
10
  var _CompositeAttributeModel = _interopRequireDefault(require("../attributes/CompositeAttributeModel"));
11
11
  /**
12
12
  * Range filter, for instance a date range filter or a number range filter
13
13
  */
14
- class RangeFilterModel extends _BaseFilterModel.default {
14
+ class RangeFilterModel extends _FilterModel.default {
15
15
  /**
16
16
  */
17
17
  update(attribute, value) {
@@ -1 +1 @@
1
- {"version":3,"file":"RangeFilterModel.js","names":["_BaseFilterModel","_interopRequireDefault","require","_CompositeAttributeModel","RangeFilterModel","BaseFilterModel","update","attribute","value","CompositeAttributeModel","params","_context","_map","default","children","call","child","param","data","name","exports"],"sources":["../../../src/models/filters/RangeFilterModel.js"],"sourcesContent":["// @flow\nimport BaseFilterModel from \"../filters/BaseFilterModel\";\n\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\nimport type { AttributeType } from \"../types\";\n\n/**\n * Range filter, for instance a date range filter or a number range filter\n */\nexport default class RangeFilterModel extends BaseFilterModel {\n /**\n */\n update(attribute: AttributeType, value: string) {\n if (this.attribute instanceof CompositeAttributeModel) {\n this.attribute.update(value, attribute);\n } else if (this.attribute !== null) {\n this.attribute.update(value);\n }\n }\n\n /**\n */\n get params(): Array<{ name: string, value: ?string }> {\n if (this.attribute instanceof CompositeAttributeModel) {\n return this.attribute.children.map((child) => {\n const { param } = this.data[child.name];\n return {\n name: param,\n value: child.value,\n };\n });\n }\n\n return [];\n }\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,wBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAGA;AACA;AACA;AACe,MAAME,gBAAgB,SAASC,wBAAe,CAAC;EAC5D;AACF;EACEC,MAAMA,CAACC,SAAwB,EAAEC,KAAa,EAAE;IAC9C,IAAI,IAAI,CAACD,SAAS,YAAYE,gCAAuB,EAAE;MACrD,IAAI,CAACF,SAAS,CAACD,MAAM,CAACE,KAAK,EAAED,SAAS,CAAC;IACzC,CAAC,MAAM,IAAI,IAAI,CAACA,SAAS,KAAK,IAAI,EAAE;MAClC,IAAI,CAACA,SAAS,CAACD,MAAM,CAACE,KAAK,CAAC;IAC9B;EACF;;EAEA;AACF;EACE,IAAIE,MAAMA,CAAA,EAA4C;IACpD,IAAI,IAAI,CAACH,SAAS,YAAYE,gCAAuB,EAAE;MAAA,IAAAE,QAAA;MACrD,OAAO,IAAAC,IAAA,CAAAC,OAAA,EAAAF,QAAA,OAAI,CAACJ,SAAS,CAACO,QAAQ,EAAAC,IAAA,CAAAJ,QAAA,EAAMK,KAAK,IAAK;QAC5C,MAAM;UAAEC;QAAM,CAAC,GAAG,IAAI,CAACC,IAAI,CAACF,KAAK,CAACG,IAAI,CAAC;QACvC,OAAO;UACLA,IAAI,EAAEF,KAAK;UACXT,KAAK,EAAEQ,KAAK,CAACR;QACf,CAAC;MACH,CAAC,CAAC;IACJ;IAEA,OAAO,EAAE;EACX;AACF;AAACY,OAAA,CAAAP,OAAA,GAAAT,gBAAA","ignoreList":[]}
1
+ {"version":3,"file":"RangeFilterModel.js","names":["_FilterModel","_interopRequireDefault","require","_CompositeAttributeModel","RangeFilterModel","FilterModel","update","attribute","value","CompositeAttributeModel","params","_context","_map","default","children","call","child","param","data","name","exports"],"sources":["../../../src/models/filters/RangeFilterModel.js"],"sourcesContent":["// @flow\nimport FilterModel from \"../filters/FilterModel\";\n\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\nimport type { AttributeType } from \"../types\";\n\n/**\n * Range filter, for instance a date range filter or a number range filter\n */\nexport default class RangeFilterModel extends FilterModel {\n /**\n */\n update(attribute: AttributeType, value: string) {\n if (this.attribute instanceof CompositeAttributeModel) {\n this.attribute.update(value, attribute);\n } else if (this.attribute !== null) {\n this.attribute.update(value);\n }\n }\n\n /**\n */\n get params(): Array<{ name: string, value: ?string }> {\n if (this.attribute instanceof CompositeAttributeModel) {\n return this.attribute.children.map((child) => {\n const { param } = this.data[child.name];\n return {\n name: param,\n value: child.value,\n };\n });\n }\n\n return [];\n }\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,wBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAGA;AACA;AACA;AACe,MAAME,gBAAgB,SAASC,oBAAW,CAAC;EACxD;AACF;EACEC,MAAMA,CAACC,SAAwB,EAAEC,KAAa,EAAE;IAC9C,IAAI,IAAI,CAACD,SAAS,YAAYE,gCAAuB,EAAE;MACrD,IAAI,CAACF,SAAS,CAACD,MAAM,CAACE,KAAK,EAAED,SAAS,CAAC;IACzC,CAAC,MAAM,IAAI,IAAI,CAACA,SAAS,KAAK,IAAI,EAAE;MAClC,IAAI,CAACA,SAAS,CAACD,MAAM,CAACE,KAAK,CAAC;IAC9B;EACF;;EAEA;AACF;EACE,IAAIE,MAAMA,CAAA,EAA4C;IACpD,IAAI,IAAI,CAACH,SAAS,YAAYE,gCAAuB,EAAE;MAAA,IAAAE,QAAA;MACrD,OAAO,IAAAC,IAAA,CAAAC,OAAA,EAAAF,QAAA,OAAI,CAACJ,SAAS,CAACO,QAAQ,EAAAC,IAAA,CAAAJ,QAAA,EAAMK,KAAK,IAAK;QAC5C,MAAM;UAAEC;QAAM,CAAC,GAAG,IAAI,CAACC,IAAI,CAACF,KAAK,CAACG,IAAI,CAAC;QACvC,OAAO;UACLA,IAAI,EAAEF,KAAK;UACXT,KAAK,EAAEQ,KAAK,CAACR;QACf,CAAC;MACH,CAAC,CAAC;IACJ;IAEA,OAAO,EAAE;EACX;AACF;AAACY,OAAA,CAAAP,OAAA,GAAAT,gBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/models/types.js"],"sourcesContent":["// @flow\nimport type ApplicationModel from \"./application/ApplicationModel\";\nimport type BooleanAttributeModel from \"./attributes/BooleanAttributeModel\";\nimport type CaptchaAttributeModel from \"./attributes/CaptchaAttributeModel\";\nimport type ChoiceAttributeModel from \"./attributes/ChoiceAttributeModel\";\nimport type CompositeAttributeModel from \"./attributes/CompositeAttributeModel\";\nimport type DatetimeAttributeModel from \"./attributes/DatetimeAttributeModel\";\nimport type HelptextAttributeModel from \"./attributes/HelptextAttributeModel\";\nimport type LabelAttributeModel from \"./attributes/LabelAttributeModel\";\nimport type MemoAttributeModel from \"./attributes/MemoAttributeModel\";\nimport type MoneyAttributeModel from \"./attributes/MoneyAttributeModel\";\nimport type NumberAttributeModel from \"./attributes/NumberAttributeModel\";\nimport type PasswordAttributeModel from \"./attributes/PasswordAttributeModel\";\nimport type StringAttributeModel from \"./attributes/StringAttributeModel\";\nimport type UploadAttributeModel from \"./attributes/UploadAttributeModel\";\nimport type XMLAttributeModel from \"./attributes/XMLAttributeModel\";\nimport type CaseViewModel from \"./caseview/CaseViewModel\";\nimport type BusinessScenarioModel from \"./concepts/BusinessScenarioModel\";\nimport type ConceptDetailModel from \"./concepts/ConceptDetailModel\";\nimport type ConceptIndexModel from \"./concepts/ConceptIndexModel\";\nimport type ConceptTypeDetailModel from \"./concepts/ConceptTypeDetailModel\";\nimport type ContentIndexModel from \"./content/ContentIndexModel\";\nimport type ContentModel from \"./content/ContentModel\";\nimport type SectionModel from \"./content/SectionModel\";\nimport type ContentTOCModel from \"./content/ContentTOCModel\";\nimport type ContentTypeModel from \"./content/ContentTypeModel\";\nimport type DetailModel from \"./detail/DetailModel\";\nimport type AssignmentFilterModel from \"./filters/AssignmentFilterModel\";\nimport type FilterModel from \"./filters/FilterModel\";\nimport type RangeFilterModel from \"./filters/RangeFilterModel\";\nimport type ConceptIndexFilterModel from \"./filters/ConceptIndexFilterModel\";\nimport type FormModel from \"./form/FormModel\";\nimport type ListDetailModel from \"./list/ListDetailModel\";\nimport type ListModel from \"./list/ListModel\";\nimport type ModelCatalogModel from \"./modelcatalog/ModelCatalogModel\";\nimport type GroupingPanelModel from \"./panels/GroupingPanelModel\";\nimport type CaseSearchModel from \"./search/CaseSearchModel\";\nimport type TabModel from \"./tab/TabModel\";\nimport type TaskGroupModel from \"./taskgroup/TaskGroupModel\";\nimport type UserModel from \"./user/UserModel\";\nimport type UserServicesModel from \"./user/UserServicesModel\";\nimport type LinkModel from \"./links/LinkModel\";\nimport type LookupOptionsModel from \"./lookup/LookupOptionsModel\";\nimport type BaseFilterModel from \"./filters/BaseFilterModel\";\nimport type AttributeCollection from \"./attributes/AttributeCollection\";\nimport type AttributeModel from \"./attributes/AttributeModel\";\nimport type LayoutHintCollection from \"./layouthint/LayoutHintCollection\";\nimport type ErrorResponse from \"./error/ErrorResponse\";\n\nexport type ModularUIModel =\n | ApplicationModel\n | CaseSearchModel\n | CaseViewModel\n | ListDetailModel\n | DetailModel\n | FormModel\n | GroupingPanelModel\n | ListModel\n | TabModel\n | TaskGroupModel\n | UserModel\n | UserServicesModel\n | ModelCatalogModel\n | ConceptIndexModel\n | ConceptDetailModel\n | BusinessScenarioModel\n | ConceptTypeDetailModel\n | ContentIndexModel\n | ContentTOCModel\n | ContentModel\n | ContentTypeModel\n | LookupOptionsModel;\n\nexport type AttributeType =\n | BooleanAttributeModel\n | CaptchaAttributeModel\n | ChoiceAttributeModel\n | DatetimeAttributeModel\n | HelptextAttributeModel\n | LabelAttributeModel\n | MemoAttributeModel\n | MoneyAttributeModel\n | NumberAttributeModel\n | PasswordAttributeModel\n | CompositeAttributeModel\n | StringAttributeModel\n | UploadAttributeModel\n | XMLAttributeModel;\n\nexport type RangeChildAttributeType =\n | NumberAttributeModel\n | DatetimeAttributeModel;\n\nexport type FilterType =\n | BaseFilterModel\n | FilterModel\n | AssignmentFilterModel\n | RangeFilterModel\n | ConceptIndexFilterModel;\n\nexport type FormErrorAnchor = {\n id: string,\n properties?: {\n [propertyName: string]: string | number,\n },\n anchor?: {\n objectid: string,\n elementid?: string,\n _links?: Object,\n index?: number,\n \"index-identifier\"?: string,\n },\n layouthint: LayoutHintCollection,\n message: string,\n param?: {\n name: string,\n },\n};\n\nexport type labelsJSON = {\n _id: string,\n label: string,\n value: string,\n};\n\nexport type propertyJSON = {\n _id: string,\n type: string,\n mandatory: string,\n label: string,\n value: string,\n};\n\nexport type textfragmentJSON = {\n label: string,\n text: string,\n type: string,\n};\n\nexport interface IConstraintModel {\n +id: string;\n +defaultMessage: string;\n +parameters: Object;\n +isMandatoryConstraint: boolean;\n validate(value: any): boolean;\n hasValidation(): boolean;\n}\n\nexport interface ILayoutHintRule {\n process(attribute: AttributeModel, attributes: AttributeCollection): void;\n}\n\nexport interface IModelWithChildModels {\n getInitialChildModelLinks(): Array<LinkModel>;\n setChildModels(\n models: Array<ModularUIModel>,\n errors: Array<ErrorResponse>,\n ): void;\n}\n\nexport type AuthenticationType = {\n name: string,\n authentication: string,\n redirectUri?: string,\n isPrimary: boolean,\n};\n\nexport type FileEntryType = {\n name: string,\n size?: number,\n progress: number,\n error?: string,\n token?: string,\n};\n\nexport type FilesType = {\n [filename: string]: FileEntryType,\n};\n\nexport type FiletypeConstraintsType = Array<{|\n extensions: Array<string>,\n mimeTypes: Array<string>,\n|}>;\n\nexport type FilesizeConstraintsType = {\n fileSize: ?number,\n maxTotalFileSize: ?number,\n isMaxTotal: boolean,\n};\n\nexport type PropertyData = { type: string, label: string, value: string };\nexport type TextFragmentData = {\n type: string,\n label: string,\n text: string | { id?: string, message: string, properties?: Object },\n};\nexport type SectionData = {\n id: string,\n type: string,\n label?: string,\n number?: string,\n body: string | { id?: string, message: string, properties?: Object },\n _links: { self: { href: string } },\n childSections?: Array<SectionData>,\n sections?: Array<SectionData>,\n subSections: Array<SectionData>,\n};\n\nexport type PropertyElement = {\n propertyElement: {\n label: string,\n layouthint: Array<string>,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElement = {\n textFragmentElement: {\n label: string,\n layouthint: Array<string>,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElement = {\n contentElement: {\n label: string,\n layouthint: Array<string>,\n sections: Array<SectionData>,\n },\n};\n\nexport type PropertyElementMapped = {\n propertyElement: {\n label: string,\n layouthint: LayoutHintCollection,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElementMapped = {\n textFragmentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElementMapped = {\n contentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n sections: Array<SectionModel>,\n },\n};\n\nexport type ContentAll = Array<\n PropertyElementMapped | TextFragmentElementMapped | ContentElementMapped,\n>;\n\nexport type ContentData = {\n header: {\n label?: string,\n description?: { id?: string, message: string, properties?: Object },\n },\n label?: string,\n elements: Array<PropertyElement | TextFragmentElement | ContentElement>,\n};\n\nexport type SectionFragment = {\n text: string,\n startOffset: number,\n endOffset: number,\n};\n\nexport type ModelOptions = {\n origin?: ?string,\n contextPath?: ?string,\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/models/types.js"],"sourcesContent":["// @flow\nimport type ApplicationModel from \"./application/ApplicationModel\";\nimport type BooleanAttributeModel from \"./attributes/BooleanAttributeModel\";\nimport type CaptchaAttributeModel from \"./attributes/CaptchaAttributeModel\";\nimport type ChoiceAttributeModel from \"./attributes/ChoiceAttributeModel\";\nimport type CompositeAttributeModel from \"./attributes/CompositeAttributeModel\";\nimport type DatetimeAttributeModel from \"./attributes/DatetimeAttributeModel\";\nimport type HelptextAttributeModel from \"./attributes/HelptextAttributeModel\";\nimport type LabelAttributeModel from \"./attributes/LabelAttributeModel\";\nimport type MemoAttributeModel from \"./attributes/MemoAttributeModel\";\nimport type MoneyAttributeModel from \"./attributes/MoneyAttributeModel\";\nimport type NumberAttributeModel from \"./attributes/NumberAttributeModel\";\nimport type PasswordAttributeModel from \"./attributes/PasswordAttributeModel\";\nimport type StringAttributeModel from \"./attributes/StringAttributeModel\";\nimport type UploadAttributeModel from \"./attributes/UploadAttributeModel\";\nimport type XMLAttributeModel from \"./attributes/XMLAttributeModel\";\nimport type CaseViewModel from \"./caseview/CaseViewModel\";\nimport type BusinessScenarioModel from \"./concepts/BusinessScenarioModel\";\nimport type ConceptDetailModel from \"./concepts/ConceptDetailModel\";\nimport type ConceptIndexModel from \"./concepts/ConceptIndexModel\";\nimport type ConceptTypeDetailModel from \"./concepts/ConceptTypeDetailModel\";\nimport type ContentIndexModel from \"./content/ContentIndexModel\";\nimport type ContentModel from \"./content/ContentModel\";\nimport type SectionModel from \"./content/SectionModel\";\nimport type ContentTOCModel from \"./content/ContentTOCModel\";\nimport type ContentTypeModel from \"./content/ContentTypeModel\";\nimport type DetailModel from \"./detail/DetailModel\";\nimport type AssignmentFilterModel from \"./filters/AssignmentFilterModel\";\nimport type FilterModel from \"./filters/FilterModel\";\nimport type RangeFilterModel from \"./filters/RangeFilterModel\";\nimport type ConceptIndexFilterModel from \"./filters/ConceptIndexFilterModel\";\nimport type FormModel from \"./form/FormModel\";\nimport type ListDetailModel from \"./list/ListDetailModel\";\nimport type ListModel from \"./list/ListModel\";\nimport type ModelCatalogModel from \"./modelcatalog/ModelCatalogModel\";\nimport type GroupingPanelModel from \"./panels/GroupingPanelModel\";\nimport type CaseSearchModel from \"./search/CaseSearchModel\";\nimport type TabModel from \"./tab/TabModel\";\nimport type TaskGroupModel from \"./taskgroup/TaskGroupModel\";\nimport type UserModel from \"./user/UserModel\";\nimport type UserServicesModel from \"./user/UserServicesModel\";\nimport type LinkModel from \"./links/LinkModel\";\nimport type LookupOptionsModel from \"./lookup/LookupOptionsModel\";\nimport type AttributeCollection from \"./attributes/AttributeCollection\";\nimport type AttributeModel from \"./attributes/AttributeModel\";\nimport type LayoutHintCollection from \"./layouthint/LayoutHintCollection\";\nimport type ErrorResponse from \"./error/ErrorResponse\";\n\nexport type ModularUIModel =\n | ApplicationModel\n | CaseSearchModel\n | CaseViewModel\n | ListDetailModel\n | DetailModel\n | FormModel\n | GroupingPanelModel\n | ListModel\n | TabModel\n | TaskGroupModel\n | UserModel\n | UserServicesModel\n | ModelCatalogModel\n | ConceptIndexModel\n | ConceptDetailModel\n | BusinessScenarioModel\n | ConceptTypeDetailModel\n | ContentIndexModel\n | ContentTOCModel\n | ContentModel\n | ContentTypeModel\n | LookupOptionsModel;\n\nexport type AttributeType =\n | BooleanAttributeModel\n | CaptchaAttributeModel\n | ChoiceAttributeModel\n | DatetimeAttributeModel\n | HelptextAttributeModel\n | LabelAttributeModel\n | MemoAttributeModel\n | MoneyAttributeModel\n | NumberAttributeModel\n | PasswordAttributeModel\n | CompositeAttributeModel\n | StringAttributeModel\n | UploadAttributeModel\n | XMLAttributeModel;\n\nexport type RangeChildAttributeType =\n | NumberAttributeModel\n | DatetimeAttributeModel;\n\nexport type FilterType =\n | AssignmentFilterModel\n | FilterModel\n | RangeFilterModel\n | ConceptIndexFilterModel;\n\nexport type FormErrorAnchor = {\n id: string,\n properties?: {\n [propertyName: string]: string | number,\n },\n anchor?: {\n objectid: string,\n elementid?: string,\n _links?: Object,\n index?: number,\n \"index-identifier\"?: string,\n },\n layouthint: LayoutHintCollection,\n message: string,\n param?: {\n name: string,\n },\n};\n\nexport type labelsJSON = {\n _id: string,\n label: string,\n value: string,\n};\n\nexport type propertyJSON = {\n _id: string,\n type: string,\n mandatory: string,\n label: string,\n value: string,\n};\n\nexport type textfragmentJSON = {\n label: string,\n text: string,\n type: string,\n};\n\nexport interface IConstraintModel {\n +id: string;\n +defaultMessage: string;\n +parameters: Object;\n +isMandatoryConstraint: boolean;\n validate(value: any): boolean;\n hasValidation(): boolean;\n}\n\nexport interface ILayoutHintRule {\n process(attribute: AttributeModel, attributes: AttributeCollection): void;\n}\n\nexport interface IModelWithChildModels {\n getInitialChildModelLinks(): Array<LinkModel>;\n setChildModels(\n models: Array<ModularUIModel>,\n errors: Array<ErrorResponse>,\n ): void;\n}\n\nexport type AuthenticationType = {\n name: string,\n authentication: string,\n redirectUri?: string,\n isPrimary: boolean,\n};\n\nexport type FileEntryType = {\n name: string,\n size?: number,\n progress: number,\n error?: string,\n token?: string,\n};\n\nexport type FilesType = {\n [filename: string]: FileEntryType,\n};\n\nexport type FiletypeConstraintsType = Array<{|\n extensions: Array<string>,\n mimeTypes: Array<string>,\n|}>;\n\nexport type FilesizeConstraintsType = {\n fileSize: ?number,\n maxTotalFileSize: ?number,\n isMaxTotal: boolean,\n};\n\nexport type PropertyData = { type: string, label: string, value: string };\nexport type TextFragmentData = {\n type: string,\n label: string,\n text: string | { id?: string, message: string, properties?: Object },\n};\nexport type SectionData = {\n id: string,\n type: string,\n label?: string,\n number?: string,\n body: string | { id?: string, message: string, properties?: Object },\n _links: { self: { href: string } },\n childSections?: Array<SectionData>,\n sections?: Array<SectionData>,\n subSections: Array<SectionData>,\n};\n\nexport type PropertyElement = {\n propertyElement: {\n label: string,\n layouthint: Array<string>,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElement = {\n textFragmentElement: {\n label: string,\n layouthint: Array<string>,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElement = {\n contentElement: {\n label: string,\n layouthint: Array<string>,\n sections: Array<SectionData>,\n },\n};\n\nexport type PropertyElementMapped = {\n propertyElement: {\n label: string,\n layouthint: LayoutHintCollection,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElementMapped = {\n textFragmentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElementMapped = {\n contentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n sections: Array<SectionModel>,\n },\n};\n\nexport type ContentAll = Array<\n PropertyElementMapped | TextFragmentElementMapped | ContentElementMapped,\n>;\n\nexport type ContentData = {\n header: {\n label?: string,\n description?: { id?: string, message: string, properties?: Object },\n },\n label?: string,\n elements: Array<PropertyElement | TextFragmentElement | ContentElement>,\n};\n\nexport type SectionFragment = {\n text: string,\n startOffset: number,\n endOffset: number,\n};\n\nexport type ModelOptions = {\n origin?: ?string,\n contextPath?: ?string,\n};\n"],"mappings":"","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.65.3",
3
+ "version": "1.65.5",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "https://support.beinformed.com",
@@ -135,12 +135,10 @@ describe("modularui hooks", () => {
135
135
 
136
136
  // eslint-disable-next-line jest/expect-expect
137
137
  it("useList", () => {
138
- assertTargetModel(
139
- () => useList("/tab/list"),
140
- "list",
141
- "/tab/list",
138
+ assertTargetModel(() => useList("/tab/list"), "list", "/tab/list", [
142
139
  ListModel,
143
- );
140
+ CaseSearchModel,
141
+ ]);
144
142
  });
145
143
 
146
144
  // eslint-disable-next-line jest/expect-expect
@@ -5,6 +5,7 @@ import { HTTP_METHODS } from "../constants/Constants";
5
5
  import { loadModularUI } from "../redux";
6
6
  import DetailModel from "../models/detail/DetailModel";
7
7
  import ListModel from "../models/list/ListModel";
8
+ import CaseSearchModel from "../models/search/CaseSearchModel";
8
9
  import ListDetailModel from "../models/list/ListDetailModel";
9
10
  import Href from "../models/href/Href";
10
11
 
@@ -22,8 +23,8 @@ export const useList = (
22
23
  options?: HookOptions,
23
24
  ): ListModel | null =>
24
25
  useModularUIBasic("list", href, {
25
- expectedModels: ["List"],
26
- targetModel: ListModel,
26
+ expectedModels: ["List", "CaseSearch"],
27
+ targetModel: [ListModel, CaseSearchModel],
27
28
  ...options,
28
29
  });
29
30
 
@@ -34,8 +35,8 @@ export const useListOrDetail = (
34
35
  options?: HookOptions,
35
36
  ): ListModel | DetailModel | null =>
36
37
  useModularUIBasic("list", href, {
37
- expectedModels: ["List", "Detail"],
38
- targetModel: [ListModel, DetailModel],
38
+ expectedModels: ["List", "CaseSearch", "Detail"],
39
+ targetModel: [ListModel, CaseSearchModel, DetailModel],
39
40
  ...options,
40
41
  });
41
42
 
@@ -70,7 +71,7 @@ export const useListNavigation = (): ListNavigationHook => {
70
71
  loadModularUI(list.connectKey, listHref, {
71
72
  method: HTTP_METHODS.POST,
72
73
  data: list.formdata,
73
- targetModel: ListModel,
74
+ targetModel: [ListModel, CaseSearchModel],
74
75
  }),
75
76
  );
76
77
  } else {
@@ -78,7 +79,7 @@ export const useListNavigation = (): ListNavigationHook => {
78
79
  dispatch(
79
80
  loadModularUI(list.connectKey, listHref, {
80
81
  method: HTTP_METHODS.GET,
81
- targetModel: ListModel,
82
+ targetModel: [ListModel, CaseSearchModel],
82
83
  }),
83
84
  );
84
85
  }
@@ -129,14 +129,15 @@ export default class ConceptIndexModel extends ResourceModel {
129
129
  /**
130
130
  * Retrieve modelcatalog.js of content toc
131
131
  */
132
- get entryDate(): string | null {
132
+ get entryDate(): ISO_DATE | null {
133
133
  const timeversionFilter = this.filterCollection.getFilterByAttributeKey(
134
134
  TIMEVERSION_FILTER_NAME,
135
135
  );
136
- if (timeversionFilter && timeversionFilter.attribute) {
137
- return timeversionFilter.attribute.value;
138
- }
139
136
 
137
+ const date = timeversionFilter?.value;
138
+ if (typeof date === "string") {
139
+ return date;
140
+ }
140
141
  return null;
141
142
  }
142
143
 
@@ -6,10 +6,11 @@ import ContentLinkModel from "./ContentLinkModel";
6
6
  import Href from "../href/Href";
7
7
  import ChoiceAttributeModel from "../attributes/ChoiceAttributeModel";
8
8
 
9
- import type { FilterType, ModularUIModel } from "../types";
9
+ import type { ModularUIModel } from "../types";
10
10
  import type { ModularUIResponse } from "../../modularui";
11
11
  import type LinkModel from "../links/LinkModel";
12
12
  import type ErrorResponse from "../error/ErrorResponse";
13
+ import ConceptIndexFilterModel from "../filters/ConceptIndexFilterModel";
13
14
 
14
15
  /**
15
16
  * Get Index of concepts, to filter model catalog
@@ -109,8 +110,12 @@ export default class ContentIndexModel extends ResourceModel {
109
110
  /**
110
111
  * Get index filter
111
112
  */
112
- get indexfilter(): FilterType | null {
113
- return this._filterCollection.getFilterByAttributeKey("index");
113
+ get indexfilter(): ConceptIndexFilterModel | null {
114
+ const indexFilter = this._filterCollection.getFilterByAttributeKey("index");
115
+ if (indexFilter instanceof ConceptIndexFilterModel) {
116
+ return indexFilter;
117
+ }
118
+ return null;
114
119
  }
115
120
 
116
121
  /**
@@ -110,10 +110,11 @@ export default class ContentModel extends ResourceModel {
110
110
  const entryDateFilter = this.filterCollection?.getFilterByAttributeKey(
111
111
  TIMEVERSION_FILTER_NAME,
112
112
  );
113
- if (entryDateFilter && entryDateFilter.attribute) {
114
- return entryDateFilter.attribute.value;
115
- }
116
113
 
114
+ const date = entryDateFilter?.value;
115
+ if (typeof date === "string") {
116
+ return date;
117
+ }
117
118
  return null;
118
119
  }
119
120
 
@@ -220,7 +220,11 @@ export default class ContentTOCModel extends ResourceModel {
220
220
  TIMEVERSION_FILTER_NAME,
221
221
  );
222
222
 
223
- return timeversionFilter?.attribute?.value ?? null;
223
+ const date = timeversionFilter?.value;
224
+ if (typeof date === "string") {
225
+ return date;
226
+ }
227
+ return null;
224
228
  }
225
229
 
226
230
  /**
@@ -228,6 +232,6 @@ export default class ContentTOCModel extends ResourceModel {
228
232
  get isCompleteSource(): boolean {
229
233
  const completeFilter =
230
234
  this.filterCollection.getFilterByAttributeKey("complete");
231
- return completeFilter?.attribute?.value === "true";
235
+ return completeFilter?.value === "true";
232
236
  }
233
237
  }
@@ -3,13 +3,14 @@ import BaseFilterModel from "../filters/BaseFilterModel";
3
3
 
4
4
  import type { AttributeType, ModelOptions } from "../types";
5
5
  import { IllegalStateException } from "../../exceptions";
6
+ import createAttribute from "../attributes/_createAttribute";
6
7
  /**
7
8
  * Assignment filter consists of two filters: assignment type and user filter
8
9
  */
9
10
  export default class AssignmentFilterModel extends BaseFilterModel {
10
11
  _listKey: string;
11
- _assignmenttype: ?AttributeType;
12
- _user: ?AttributeType;
12
+ _assignmenttype: AttributeType;
13
+ _user: AttributeType;
13
14
 
14
15
  /**
15
16
  * Construct an assignment filter
@@ -31,29 +32,16 @@ export default class AssignmentFilterModel extends BaseFilterModel {
31
32
  return this.data.name;
32
33
  }
33
34
 
34
- /**
35
- * Getting key of the list these filters apply to
36
- */
37
- get listkey(): string {
38
- return this._listKey;
39
- }
40
-
41
- /**
42
- * Set key of list this filter belongs to
43
- */
44
- set listkey(key: string) {
45
- this._listKey = key;
46
- }
47
-
48
35
  /**
49
36
  */
50
37
  get contextid(): string {
51
38
  return this.getContribution("contextid", "");
52
39
  }
40
+
53
41
  /**
54
42
  * Creates an assignmenttype model when assignmenttype json is present
55
43
  */
56
- createAssignmentTypeModel(): ?AttributeType {
44
+ createAssignmentTypeModel(): AttributeType {
57
45
  const key = `${this.contextid}ASSIGNMENTTYPE`;
58
46
  const assignmentTypeData = this.data[key];
59
47
 
@@ -71,22 +59,23 @@ export default class AssignmentFilterModel extends BaseFilterModel {
71
59
 
72
60
  const assignmentTypeContributions = {
73
61
  ...this.contributions[key],
62
+ type: "choice",
74
63
  enumerated: true,
75
64
  optionMode: assignmentTypeData._links ? "lookup" : "static",
76
65
  };
77
66
 
78
- return this.createAttribute(
79
- "choice",
67
+ return createAttribute(
80
68
  assignmentTypeData.name || assignmentTypeData.param,
81
69
  assignmentTypeData,
82
70
  assignmentTypeContributions,
71
+ this.modelOptions,
83
72
  );
84
73
  }
85
74
 
86
75
  /**
87
76
  * Creates an assignmenttype model when userkey json is present
88
77
  */
89
- createUserModel(): ?AttributeType {
78
+ createUserModel(): AttributeType {
90
79
  const key = `${this.contextid}USERKEY`;
91
80
  const userData = this.data[key];
92
81
 
@@ -98,28 +87,30 @@ export default class AssignmentFilterModel extends BaseFilterModel {
98
87
 
99
88
  const userContributions = {
100
89
  ...this.contributions[key],
90
+ type: "choice",
91
+ enumerated: true,
101
92
  optionMode: userData._links ? "lookup" : "static",
102
93
  };
103
94
 
104
- return this.createAttribute(
105
- "choice",
95
+ return createAttribute(
106
96
  userData.name || userData.param,
107
97
  userData,
108
98
  userContributions,
99
+ this.modelOptions,
109
100
  );
110
101
  }
111
102
 
112
103
  /**
113
104
  * The assignment filter consists of two part. This method return the assignment type attribute
114
105
  */
115
- get assignmenttype(): ?AttributeType {
106
+ get assignmenttype(): AttributeType {
116
107
  return this._assignmenttype;
117
108
  }
118
109
 
119
110
  /**
120
111
  * The assignment filter consists of two part. This method return the user identifier attribute
121
112
  */
122
- get user(): ?AttributeType {
113
+ get user(): AttributeType {
123
114
  return this._user;
124
115
  }
125
116
 
@@ -127,20 +118,45 @@ export default class AssignmentFilterModel extends BaseFilterModel {
127
118
  * Getting the parameters of this filter
128
119
  */
129
120
  get params(): Array<{ name: string, value: ?string }> {
130
- if (this.assignmenttype && this.user) {
131
- return [
132
- {
133
- name: this.assignmenttype.name,
134
- value: this.assignmenttype.value,
135
- },
136
- {
137
- name: this.user.name,
138
- value: this.user.value,
139
- },
140
- ];
141
- }
121
+ return [
122
+ {
123
+ name: this.assignmenttype.name,
124
+ value: this.assignmenttype.value,
125
+ },
126
+ {
127
+ name: this.user.name,
128
+ value: this.user.value,
129
+ },
130
+ ];
131
+ }
142
132
 
143
- return [];
133
+ /**
134
+ */
135
+ get value(): { [string]: any } {
136
+ return {
137
+ [this.assignmenttype.name]: this.assignmenttype.value,
138
+ [this.user.name]: this.user.value,
139
+ };
140
+ }
141
+
142
+ /**
143
+ */
144
+ get inputvalue(): { [string]: any } {
145
+ return {
146
+ [this.assignmenttype.name]: this.assignmenttype.inputvalue,
147
+ [this.user.name]: this.user.inputvalue,
148
+ };
149
+ }
150
+
151
+ /**
152
+ * Indicates if the filter has a value.
153
+ */
154
+ hasValue(): boolean {
155
+ return (
156
+ (this.assignmenttype.value !== null &&
157
+ this.assignmenttype.value !== "") ||
158
+ (this.user.value !== null && this.user.value !== "")
159
+ );
144
160
  }
145
161
 
146
162
  /**
@@ -192,4 +208,19 @@ export default class AssignmentFilterModel extends BaseFilterModel {
192
208
  this.user.isValid
193
209
  );
194
210
  }
211
+
212
+ /**
213
+ */
214
+ get readonlyvalue(): { [string]: string } {
215
+ return {
216
+ [this.assignmenttype.name]: this.assignmenttype.readonlyvalue,
217
+ [this.user.name]: this.user.readonlyvalue,
218
+ };
219
+ }
220
+
221
+ /**
222
+ */
223
+ get formdata(): { [string]: any } | null {
224
+ return this.value;
225
+ }
195
226
  }