@beinformed/ui 1.27.5 → 1.28.0
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/CHANGELOG.md +17 -1
- package/esm/constants/LayoutHintConfig.js +0 -9
- package/esm/constants/LayoutHintConfig.js.map +1 -1
- package/esm/constants/LayoutHints.js +0 -4
- package/esm/constants/LayoutHints.js.map +1 -1
- package/esm/constants/Settings.js +0 -4
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeModel.js +1 -0
- package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeOptionModel.js +2 -2
- package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/esm/models/attributes/DatetimeAttributeModel.js +3 -29
- package/esm/models/attributes/DatetimeAttributeModel.js.map +1 -1
- package/esm/react-client/Init.js +2 -2
- package/esm/react-client/Init.js.map +1 -1
- package/esm/react-client/client.js +80 -52
- package/esm/react-client/client.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js +7 -0
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIReducer.js +1 -0
- package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/esm/redux/_modularui/types.js.map +1 -1
- package/esm/redux/actions/Form.js +2 -2
- package/esm/redux/actions/Form.js.map +1 -1
- package/esm/redux/actions/FormAttributeSet.js +2 -2
- package/esm/redux/actions/FormAttributeSet.js.map +1 -1
- package/esm/redux/actions/FormAttributeSetRepeatable.js +4 -4
- package/esm/redux/actions/FormAttributeSetRepeatable.js.map +1 -1
- package/esm/redux/actions/FormAutosave.js +2 -2
- package/esm/redux/actions/FormAutosave.js.map +1 -1
- package/esm/redux/actions/FormValidations.js +2 -2
- package/esm/redux/actions/FormValidations.js.map +1 -1
- package/esm/redux/connectors/Form.js.map +1 -1
- package/esm/redux/connectors/FormAttributeSet.js.map +1 -1
- package/esm/redux/store/configureStore.js +4 -4
- package/esm/redux/store/configureStore.js.map +1 -1
- package/esm/redux/types.js.map +1 -1
- package/lib/constants/LayoutHintConfig.js +0 -9
- package/lib/constants/LayoutHintConfig.js.flow +0 -9
- package/lib/constants/LayoutHintConfig.js.map +1 -1
- package/lib/constants/LayoutHints.js +2 -7
- package/lib/constants/LayoutHints.js.flow +0 -4
- package/lib/constants/LayoutHints.js.map +1 -1
- package/lib/constants/Settings.js +0 -4
- package/lib/constants/Settings.js.flow +0 -6
- package/lib/constants/Settings.js.map +1 -1
- package/lib/hooks/__tests__/useForm.spec.js.flow +4 -4
- package/lib/hooks/useForm.js.flow +5 -5
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeModel.js +1 -0
- package/lib/models/attributes/ChoiceAttributeModel.js.flow +1 -0
- package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionModel.js +2 -2
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.flow +2 -2
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/lib/models/attributes/DatetimeAttributeModel.js +3 -29
- package/lib/models/attributes/DatetimeAttributeModel.js.flow +7 -41
- package/lib/models/attributes/DatetimeAttributeModel.js.map +1 -1
- package/lib/models/attributes/__tests__/DateAttributeModel.spec.js.flow +1 -35
- package/lib/models/attributes/__tests__/DatetimeAttributeModel.spec.js.flow +158 -216
- package/lib/models/attributes/__tests__/TimestampModel.spec.js.flow +0 -5
- package/lib/react-client/Init.js +2 -2
- package/lib/react-client/Init.js.flow +3 -3
- package/lib/react-client/Init.js.map +1 -1
- package/lib/react-client/client.js +83 -53
- package/lib/react-client/client.js.flow +106 -67
- package/lib/react-client/client.js.map +1 -1
- package/lib/redux/_modularui/ModularUIActions.js +9 -1
- package/lib/redux/_modularui/ModularUIActions.js.flow +8 -0
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIReducer.js +1 -0
- package/lib/redux/_modularui/ModularUIReducer.js.flow +1 -0
- package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/lib/redux/_modularui/types.js.flow +5 -0
- package/lib/redux/_modularui/types.js.map +1 -1
- package/lib/redux/actions/Form.js +1 -1
- package/lib/redux/actions/Form.js.flow +4 -4
- package/lib/redux/actions/Form.js.map +1 -1
- package/lib/redux/actions/FormAttributeSet.js +1 -1
- package/lib/redux/actions/FormAttributeSet.js.flow +3 -2
- package/lib/redux/actions/FormAttributeSet.js.map +1 -1
- package/lib/redux/actions/FormAttributeSetRepeatable.js +3 -3
- package/lib/redux/actions/FormAttributeSetRepeatable.js.flow +8 -8
- package/lib/redux/actions/FormAttributeSetRepeatable.js.map +1 -1
- package/lib/redux/actions/FormAutosave.js +1 -1
- package/lib/redux/actions/FormAutosave.js.flow +2 -2
- package/lib/redux/actions/FormAutosave.js.map +1 -1
- package/lib/redux/actions/FormValidations.js +1 -1
- package/lib/redux/actions/FormValidations.js.flow +2 -2
- package/lib/redux/actions/FormValidations.js.map +1 -1
- package/lib/redux/actions/__tests__/Form.spec.js.flow +1 -1
- package/lib/redux/connectors/Form.js.flow +2 -5
- package/lib/redux/connectors/Form.js.map +1 -1
- package/lib/redux/connectors/FormAttributeSet.js.flow +5 -5
- package/lib/redux/connectors/FormAttributeSet.js.map +1 -1
- package/lib/redux/store/configureStore.js +4 -4
- package/lib/redux/store/configureStore.js.flow +5 -5
- package/lib/redux/store/configureStore.js.map +1 -1
- package/lib/redux/types.js.flow +2 -0
- package/lib/redux/types.js.map +1 -1
- package/package.json +17 -19
- package/src/constants/LayoutHintConfig.js +0 -9
- package/src/constants/LayoutHints.js +0 -4
- package/src/constants/Settings.js +0 -6
- package/src/hooks/__tests__/useForm.spec.js +4 -4
- package/src/hooks/useForm.js +5 -5
- package/src/models/attributes/ChoiceAttributeModel.js +1 -0
- package/src/models/attributes/ChoiceAttributeOptionModel.js +2 -2
- package/src/models/attributes/DatetimeAttributeModel.js +7 -41
- package/src/models/attributes/__tests__/DateAttributeModel.spec.js +1 -35
- package/src/models/attributes/__tests__/DatetimeAttributeModel.spec.js +158 -216
- package/src/models/attributes/__tests__/TimestampModel.spec.js +0 -5
- package/src/react-client/Init.js +3 -3
- package/src/react-client/client.js +106 -67
- package/src/redux/_modularui/ModularUIActions.js +8 -0
- package/src/redux/_modularui/ModularUIReducer.js +1 -0
- package/src/redux/_modularui/types.js +5 -0
- package/src/redux/actions/Form.js +4 -4
- package/src/redux/actions/FormAttributeSet.js +3 -2
- package/src/redux/actions/FormAttributeSetRepeatable.js +8 -8
- package/src/redux/actions/FormAutosave.js +2 -2
- package/src/redux/actions/FormValidations.js +2 -2
- package/src/redux/actions/__tests__/Form.spec.js +1 -1
- package/src/redux/connectors/Form.js +2 -5
- package/src/redux/connectors/FormAttributeSet.js +5 -5
- package/src/redux/store/configureStore.js +5 -5
- package/src/redux/types.js +2 -0
- package/types/constants/LayoutHintConfig.d.ts +8 -23
- package/types/constants/LayoutHints.d.ts +0 -4
- package/types/models/actions/ActionCollection.d.ts +1 -1
- package/types/models/attributes/DatetimeAttributeModel.d.ts +8 -2
- package/types/redux/_modularui/types.d.ts +4 -0
- package/types/redux/types.d.ts +1 -1
|
@@ -1,226 +1,168 @@
|
|
|
1
1
|
import DatetimeAttributeModel from "../DatetimeAttributeModel";
|
|
2
|
-
import { setSettings } from "../../../constants/Settings";
|
|
3
2
|
import { ATTRIBUTE_WIDTH } from "../../../constants";
|
|
4
3
|
|
|
5
4
|
describe("datetimeAttributeModel", () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
expect(attribute.format).toBe("yyyy-MM-dd'T'HH:mm:ss");
|
|
20
|
-
expect(attribute.getInputValue()).toBe("");
|
|
21
|
-
expect(attribute.inputvalue).toBe("");
|
|
22
|
-
expect(attribute.readonlyvalue).toBe("");
|
|
23
|
-
|
|
24
|
-
attribute.addConstraints();
|
|
25
|
-
expect(attribute.constraintCollection).toHaveLength(1);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("should be able to update", () => {
|
|
29
|
-
const attribute = new DatetimeAttributeModel(
|
|
30
|
-
{},
|
|
31
|
-
{
|
|
32
|
-
type: "datetime",
|
|
33
|
-
format: "dd-MM-yyyy HH:mm",
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
attribute.update("18-08-2016 13:45");
|
|
38
|
-
expect(attribute.getInputValue()).toBe("18-08-2016 13:45");
|
|
39
|
-
expect(attribute.getInitialInputValue("2016-08-18T13:45:23")).toBe(
|
|
40
|
-
"18-08-2016 13:45"
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
expect(attribute.readonlyvalue).toBe("18-08-2016 13:45");
|
|
44
|
-
|
|
45
|
-
attribute.update(null);
|
|
46
|
-
expect(attribute.getInputValue()).toBe("");
|
|
47
|
-
|
|
48
|
-
attribute.update("");
|
|
49
|
-
expect(attribute.value).toBeNull();
|
|
50
|
-
|
|
51
|
-
attribute.update("aaaa");
|
|
52
|
-
expect(attribute.value).toBe("Invalid Date");
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("should be able to handle min and max date in only date format and renders in format", () => {
|
|
56
|
-
const attribute = new DatetimeAttributeModel(
|
|
57
|
-
{},
|
|
58
|
-
{
|
|
59
|
-
type: "datetime",
|
|
60
|
-
format: "dd-MM-yyyy HH:mm",
|
|
61
|
-
mindate: "2010-10-01T00:00:00",
|
|
62
|
-
maxdate: "2010-10-31T23:59:59",
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
attribute.update("18-08-2016 13:45");
|
|
67
|
-
|
|
68
|
-
expect(attribute.isValid).toBe(false);
|
|
69
|
-
expect(attribute.formatValue(attribute.mindate)).toBe("01-10-2010 00:00");
|
|
70
|
-
expect(attribute.formatValue(attribute.maxdate)).toBe("31-10-2010 23:59");
|
|
71
|
-
});
|
|
5
|
+
it("should be able to create an empty DatetimeAttribute object", () => {
|
|
6
|
+
const attribute = new DatetimeAttributeModel({}, { type: "datetime" });
|
|
7
|
+
|
|
8
|
+
expect(attribute).toBeInstanceOf(DatetimeAttributeModel);
|
|
9
|
+
|
|
10
|
+
expect(attribute.type).toBe("datetime");
|
|
11
|
+
expect(attribute.format).toBe("yyyy-MM-dd'T'HH:mm:ss");
|
|
12
|
+
expect(attribute.getInputValue()).toBe("");
|
|
13
|
+
expect(attribute.inputvalue).toBe("");
|
|
14
|
+
expect(attribute.readonlyvalue).toBe("");
|
|
15
|
+
|
|
16
|
+
attribute.addConstraints();
|
|
17
|
+
expect(attribute.constraintCollection).toHaveLength(1);
|
|
72
18
|
});
|
|
73
19
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
20
|
+
it("should be able to update", () => {
|
|
21
|
+
const attribute = new DatetimeAttributeModel(
|
|
22
|
+
{},
|
|
23
|
+
{
|
|
24
|
+
type: "datetime",
|
|
25
|
+
format: "dd-MM-yyyy HH:mm",
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
attribute.update("18-08-2016 13:45");
|
|
30
|
+
expect(attribute.getInputValue()).toBe("18-08-2016 13:45");
|
|
31
|
+
expect(attribute.getInitialInputValue("2016-08-18T13:45:23")).toBe(
|
|
32
|
+
"18-08-2016 13:45"
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
expect(attribute.readonlyvalue).toBe("18-08-2016 13:45");
|
|
36
|
+
|
|
37
|
+
attribute.update(null);
|
|
38
|
+
expect(attribute.getInputValue()).toBe("");
|
|
39
|
+
|
|
40
|
+
attribute.update("");
|
|
41
|
+
expect(attribute.value).toBeNull();
|
|
42
|
+
|
|
43
|
+
attribute.update("aaaa");
|
|
44
|
+
expect(attribute.value).toBe("Invalid Date");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should be able to handle min and max date in only date format and renders in format", () => {
|
|
48
|
+
const attribute = new DatetimeAttributeModel(
|
|
49
|
+
{},
|
|
50
|
+
{
|
|
51
|
+
type: "datetime",
|
|
52
|
+
format: "dd-MM-yyyy HH:mm",
|
|
53
|
+
mindate: "2010-10-01T00:00:00",
|
|
54
|
+
maxdate: "2010-10-31T23:59:59",
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
attribute.update("18-08-2016 13:45");
|
|
59
|
+
|
|
60
|
+
expect(attribute.isValid).toBe(false);
|
|
61
|
+
expect(attribute.formatValue(attribute.mindate)).toBe("01-10-2010 00:00");
|
|
62
|
+
expect(attribute.formatValue(attribute.maxdate)).toBe("31-10-2010 23:59");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should return AttributeWidth for dates", () => {
|
|
66
|
+
const attribute = new DatetimeAttributeModel(
|
|
67
|
+
{},
|
|
68
|
+
{
|
|
69
|
+
type: "date",
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
expect(attribute.readonlyWidth).toBe(ATTRIBUTE_WIDTH.SMALL);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("should return AttributeWidth for times", () => {
|
|
76
|
+
const attribute = new DatetimeAttributeModel(
|
|
77
|
+
{},
|
|
78
|
+
{
|
|
79
|
+
type: "time",
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
expect(attribute.readonlyWidth).toBe(ATTRIBUTE_WIDTH.SMALL);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("should return AttributeWidth for datetime", () => {
|
|
86
|
+
const attribute = new DatetimeAttributeModel(
|
|
87
|
+
{},
|
|
88
|
+
{
|
|
89
|
+
type: "datetime",
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
expect(attribute.readonlyWidth).toBe(ATTRIBUTE_WIDTH.MEDIUM);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("can validate datetime with datetime format", () => {
|
|
96
|
+
const datetimeFormat = new DatetimeAttributeModel(
|
|
97
|
+
{},
|
|
98
|
+
{
|
|
99
|
+
type: "datetime",
|
|
100
|
+
format: "dd-MM-yyyy HH:mm",
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
expect(datetimeFormat.validate("19-10-2010 1:45")).toBe(true);
|
|
105
|
+
expect(datetimeFormat.validate("19-10-2010 13:45")).toBe(true);
|
|
106
|
+
|
|
107
|
+
expect(datetimeFormat.validate("19-10-2010")).toBe(false);
|
|
108
|
+
expect(datetimeFormat.validate("13:45")).toBe(false);
|
|
109
|
+
expect(datetimeFormat.validate("19-10-2010 1:45 am")).toBe(false);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("can validate datetime with only date format", () => {
|
|
113
|
+
const dateFormat = new DatetimeAttributeModel(
|
|
114
|
+
{},
|
|
115
|
+
{
|
|
116
|
+
type: "datetime",
|
|
117
|
+
format: "dd-MM-yyyy",
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
expect(dateFormat.validate("19-10-2010")).toBe(true);
|
|
122
|
+
|
|
123
|
+
expect(dateFormat.validate("19-10-2010 1:45")).toBe(false);
|
|
124
|
+
expect(dateFormat.validate("13:45")).toBe(false);
|
|
125
|
+
expect(dateFormat.validate("19-10-2010 1:45 am")).toBe(false);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("can validate datetime with datetime am/pm format", () => {
|
|
129
|
+
const datetimeAmPmFormat = new DatetimeAttributeModel(
|
|
130
|
+
{},
|
|
131
|
+
{
|
|
132
|
+
type: "datetime",
|
|
133
|
+
format: "dd-MM-yyyy hh:mm a",
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
expect(datetimeAmPmFormat.validate("19-10-2010 1:45 am")).toBe(true);
|
|
138
|
+
expect(datetimeAmPmFormat.validate("19-10-2010 1:45 pm")).toBe(true);
|
|
139
|
+
|
|
140
|
+
expect(datetimeAmPmFormat.validate("19-10-2010 1:45")).toBe(false);
|
|
141
|
+
expect(datetimeAmPmFormat.validate("19-10-2010 13:45")).toBe(false);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("can handle old datetime format with ms", () => {
|
|
145
|
+
const attribute = new DatetimeAttributeModel(
|
|
146
|
+
{ value: "2031-12-21T17:41:21.000" },
|
|
147
|
+
{
|
|
148
|
+
type: "datetime",
|
|
149
|
+
format: "dd-MM-yyyy HH:mm",
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
expect(attribute.readonlyvalue).toBe("21-12-2031 17:41");
|
|
204
154
|
});
|
|
205
155
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
type: "datetime",
|
|
218
|
-
format: "dd-MM-yyyy HH:mm",
|
|
219
|
-
formatlabel: "dd-MM-yyyy HH:mm",
|
|
220
|
-
}
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
expect(attribute.placeholder).toBe("dd-MM-yyyy");
|
|
224
|
-
});
|
|
156
|
+
it("returns date part of formatlabel as placeholder if attribute has date and time", () => {
|
|
157
|
+
const attribute = new DatetimeAttributeModel(
|
|
158
|
+
{},
|
|
159
|
+
{
|
|
160
|
+
type: "datetime",
|
|
161
|
+
format: "dd-MM-yyyy HH:mm",
|
|
162
|
+
formatlabel: "dd-MM-yyyy HH:mm",
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
expect(attribute.placeholder).toBe("dd-MM-yyyy");
|
|
225
167
|
});
|
|
226
168
|
});
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import DatetimeAttributeModel from "../DatetimeAttributeModel";
|
|
2
|
-
import { setSettings } from "../../../constants/Settings";
|
|
3
|
-
|
|
4
2
|
describe("timestampAttributeModel", () => {
|
|
5
|
-
beforeAll(() => {
|
|
6
|
-
setSettings({ DATE_INPUT_FORMAT: "dd-MM-yyyy" });
|
|
7
|
-
});
|
|
8
3
|
it("should be able to create an empty TimestampAttribute object", () => {
|
|
9
4
|
const attribute = new DatetimeAttributeModel({}, { type: "timestamp" });
|
|
10
5
|
|
package/lib/react-client/Init.js
CHANGED
|
@@ -16,7 +16,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
16
16
|
const Init = _ref => {
|
|
17
17
|
let {
|
|
18
18
|
store,
|
|
19
|
-
|
|
19
|
+
routerHistory,
|
|
20
20
|
contextPath,
|
|
21
21
|
theme,
|
|
22
22
|
children,
|
|
@@ -30,7 +30,7 @@ const Init = _ref => {
|
|
|
30
30
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ErrorBoundary.default, {
|
|
31
31
|
FallbackComponent: ErrorFallbackComponent,
|
|
32
32
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouter.Router, {
|
|
33
|
-
history:
|
|
33
|
+
history: routerHistory,
|
|
34
34
|
basename: contextPath,
|
|
35
35
|
children: children
|
|
36
36
|
})
|
|
@@ -14,7 +14,7 @@ import type { Props as FallbackProps } from "../react/ErrorBoundaryFallback";
|
|
|
14
14
|
|
|
15
15
|
export type Props = {
|
|
16
16
|
+store: ReduxStore,
|
|
17
|
-
+
|
|
17
|
+
+routerHistory: RouterHistory,
|
|
18
18
|
+contextPath: string,
|
|
19
19
|
+theme?: Theme | Array<Theme>,
|
|
20
20
|
+children: ?Node,
|
|
@@ -25,7 +25,7 @@ export type Props = {
|
|
|
25
25
|
*/
|
|
26
26
|
const Init = ({
|
|
27
27
|
store,
|
|
28
|
-
|
|
28
|
+
routerHistory,
|
|
29
29
|
contextPath,
|
|
30
30
|
theme,
|
|
31
31
|
children,
|
|
@@ -35,7 +35,7 @@ const Init = ({
|
|
|
35
35
|
<ThemeProvider theme={theme}>
|
|
36
36
|
<HelmetProvider>
|
|
37
37
|
<ErrorBoundary FallbackComponent={ErrorFallbackComponent}>
|
|
38
|
-
<Router history={
|
|
38
|
+
<Router history={routerHistory} basename={contextPath}>
|
|
39
39
|
{children}
|
|
40
40
|
</Router>
|
|
41
41
|
</ErrorBoundary>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Init.js","names":["Init","store","
|
|
1
|
+
{"version":3,"file":"Init.js","names":["Init","store","routerHistory","contextPath","theme","children","ErrorFallbackComponent","displayName"],"sources":["../../src/react-client/Init.js"],"sourcesContent":["// @flow\nimport { Provider } from \"react-redux\";\nimport { HelmetProvider } from \"react-helmet-async\";\nimport { Router } from \"react-router\";\n\nimport ThemeProvider from \"../react-theme/ThemeProvider\";\nimport ErrorBoundary from \"../react/ErrorBoundary\";\n\nimport type { ComponentType, Node } from \"react\";\nimport type { RouterHistory } from \"react-router\";\nimport type { Theme } from \"../react-theme/types\";\nimport type { ReduxStore } from \"../redux/types\";\nimport type { Props as FallbackProps } from \"../react/ErrorBoundaryFallback\";\n\nexport type Props = {\n +store: ReduxStore,\n +routerHistory: RouterHistory,\n +contextPath: string,\n +theme?: Theme | Array<Theme>,\n +children: ?Node,\n +ErrorFallbackComponent?: ComponentType<FallbackProps>,\n};\n\n/**\n */\nconst Init = ({\n store,\n routerHistory,\n contextPath,\n theme,\n children,\n ErrorFallbackComponent,\n}: Props): Node => (\n <Provider store={store}>\n <ThemeProvider theme={theme}>\n <HelmetProvider>\n <ErrorBoundary FallbackComponent={ErrorFallbackComponent}>\n <Router history={routerHistory} basename={contextPath}>\n {children}\n </Router>\n </ErrorBoundary>\n </HelmetProvider>\n </ThemeProvider>\n </Provider>\n);\n\nInit.displayName = \"BI.Init\";\n\nexport default Init;\n"],"mappings":";;;;;;;AACA;AACA;AACA;AAEA;AACA;AAAmD;AAiBnD;AACA;AACA,MAAMA,IAAI,GAAG;EAAA,IAAC;IACZC,KAAK;IACLC,aAAa;IACbC,WAAW;IACXC,KAAK;IACLC,QAAQ;IACRC;EACK,CAAC;EAAA,oBACN,qBAAC,oBAAQ;IAAC,KAAK,EAAEL,KAAM;IAAA,uBACrB,qBAAC,sBAAa;MAAC,KAAK,EAAEG,KAAM;MAAA,uBAC1B,qBAAC,gCAAc;QAAA,uBACb,qBAAC,sBAAa;UAAC,iBAAiB,EAAEE,sBAAuB;UAAA,uBACvD,qBAAC,mBAAM;YAAC,OAAO,EAAEJ,aAAc;YAAC,QAAQ,EAAEC,WAAY;YAAA,UACnDE;UAAQ;QACF;MACK;IACD;EACH,EACP;AAAA,CACZ;AAEDL,IAAI,CAACO,WAAW,GAAG,SAAS;AAAC,eAEdP,IAAI;AAAA"}
|
|
@@ -4,10 +4,8 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = void 0;
|
|
7
|
+
exports.setupClient = exports.setUnhandledRejectionEvent = exports.default = exports.addContentLoadedEvent = void 0;
|
|
8
8
|
var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
|
|
9
|
-
var _elementClosest = _interopRequireDefault(require("element-closest"));
|
|
10
|
-
require("focus-visible");
|
|
11
9
|
var _reactDom = require("react-dom");
|
|
12
10
|
var _objects = require("../utils/helpers/objects");
|
|
13
11
|
var _setimmediate = _interopRequireDefault(require("setimmediate"));
|
|
@@ -25,16 +23,9 @@ var _exceptions = require("../exceptions");
|
|
|
25
23
|
var _Init = _interopRequireDefault(require("./Init"));
|
|
26
24
|
var _beforeRenderHooks = require("../redux/store/beforeRenderHooks");
|
|
27
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
28
|
-
/* polyfills needed for ie11 */
|
|
29
|
-
(0, _elementClosest.default)(window);
|
|
30
|
-
|
|
31
|
-
/* polyfill for focus-visible */
|
|
32
|
-
|
|
33
26
|
/*
|
|
34
27
|
* deserialize serialized data from the server to provide a smooth dehydration.
|
|
35
28
|
*/
|
|
36
|
-
/**
|
|
37
|
-
*/
|
|
38
29
|
const parseDataToJSON = data => {
|
|
39
30
|
try {
|
|
40
31
|
return JSON.parse(data);
|
|
@@ -42,22 +33,42 @@ const parseDataToJSON = data => {
|
|
|
42
33
|
throw new _exceptions.JsonParseException(`Error parsing content ${data}`);
|
|
43
34
|
}
|
|
44
35
|
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Mount the webapplication to the DOM, used client side when JavaScript is enabled.
|
|
48
|
-
*/
|
|
49
|
-
const client = props => {
|
|
36
|
+
const getDataFromServer = () => {
|
|
50
37
|
var _context;
|
|
51
|
-
if (typeof window.contextPath === "undefined") {
|
|
52
|
-
throw new Error("Missing contextPath on window object");
|
|
53
|
-
}
|
|
54
38
|
const dataElement = document.querySelector('script[type="application/json"][data-app-state="app-json"]');
|
|
55
39
|
if (!dataElement) {
|
|
56
40
|
throw new Error("Error loading state, json not found");
|
|
57
41
|
} else if ((0, _trim.default)(_context = dataElement.textContent).call(_context) === "") {
|
|
58
|
-
return;
|
|
42
|
+
return {};
|
|
59
43
|
}
|
|
60
|
-
|
|
44
|
+
return parseDataToJSON(dataElement.textContent);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
*/
|
|
49
|
+
const setUnhandledRejectionEvent = store => {
|
|
50
|
+
window.onunhandledrejection = event => {
|
|
51
|
+
if (event.detail) {
|
|
52
|
+
return (0, _setimmediate.default)(() => {
|
|
53
|
+
const errorMessage = event.detail.reason.message.toString();
|
|
54
|
+
store.dispatch((0, _Notification.showXHRErrorNotification)(errorMessage));
|
|
55
|
+
throw event.detail.reason;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return event;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*/
|
|
64
|
+
exports.setUnhandledRejectionEvent = setUnhandledRejectionEvent;
|
|
65
|
+
const setupClient = function () {
|
|
66
|
+
let customReducers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
67
|
+
let beforeRenderHooks = arguments.length > 1 ? arguments[1] : undefined;
|
|
68
|
+
if (typeof window.contextPath === "undefined") {
|
|
69
|
+
throw new Error("Missing contextPath on window object");
|
|
70
|
+
}
|
|
71
|
+
const data = getDataFromServer();
|
|
61
72
|
|
|
62
73
|
// remove all resources from cache
|
|
63
74
|
_Cache.default.clear("^res:");
|
|
@@ -67,9 +78,9 @@ const client = props => {
|
|
|
67
78
|
basename: (0, _Settings.getBasePath)()
|
|
68
79
|
});
|
|
69
80
|
const {
|
|
70
|
-
|
|
81
|
+
routerHistory,
|
|
71
82
|
store
|
|
72
|
-
} = (0, _configureStore.default)(browserHistory,
|
|
83
|
+
} = (0, _configureStore.default)(browserHistory, customReducers, (0, _rehydrate.default)(data));
|
|
73
84
|
(0, _Preferences.setAllContentInDataSetting)(store.getState());
|
|
74
85
|
(0, _Preferences.setLoginPreferences)(store.getState());
|
|
75
86
|
|
|
@@ -80,7 +91,7 @@ const client = props => {
|
|
|
80
91
|
}
|
|
81
92
|
});
|
|
82
93
|
if ((0, _objects.has)(data, "error.name")) {
|
|
83
|
-
const error = new _exceptions.FetchException(data
|
|
94
|
+
const error = new _exceptions.FetchException(data?.error?.response);
|
|
84
95
|
store.dispatch((0, _Error.handleError)(error));
|
|
85
96
|
}
|
|
86
97
|
if (_Cache.default.getItem("auth")) {
|
|
@@ -88,54 +99,73 @@ const client = props => {
|
|
|
88
99
|
}
|
|
89
100
|
|
|
90
101
|
// listen to history change and update the redux router store
|
|
91
|
-
|
|
102
|
+
routerHistory.listen((location, action) => {
|
|
92
103
|
store.dispatch((0, _RouterActions.locationChange)(location, action));
|
|
93
104
|
});
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
*/
|
|
97
|
-
window.onunhandledrejection = event => {
|
|
98
|
-
if (event.detail) {
|
|
99
|
-
return (0, _setimmediate.default)(() => {
|
|
100
|
-
const errorMessage = event.detail.reason.message.toString();
|
|
101
|
-
store.dispatch((0, _Notification.showXHRErrorNotification)(errorMessage));
|
|
102
|
-
throw event.detail.reason;
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
return event;
|
|
106
|
-
};
|
|
105
|
+
setUnhandledRejectionEvent(store);
|
|
107
106
|
if (document.body) {
|
|
108
107
|
document.body.className = "js";
|
|
109
108
|
}
|
|
110
|
-
if (
|
|
111
|
-
(0, _beforeRenderHooks.handleBeforeRenderHooks)(
|
|
109
|
+
if (beforeRenderHooks) {
|
|
110
|
+
(0, _beforeRenderHooks.handleBeforeRenderHooks)(beforeRenderHooks, {
|
|
112
111
|
store
|
|
113
112
|
});
|
|
114
113
|
}
|
|
115
|
-
|
|
114
|
+
return {
|
|
115
|
+
store,
|
|
116
|
+
routerHistory
|
|
117
|
+
};
|
|
116
118
|
};
|
|
117
119
|
|
|
118
120
|
/**
|
|
119
121
|
*/
|
|
120
|
-
|
|
122
|
+
exports.setupClient = setupClient;
|
|
123
|
+
const addContentLoadedEvent = (store, routerHistory, theme, render, ErrorFallbackComponent, mount) => {
|
|
121
124
|
window.addEventListener("DOMContentLoaded", () => {
|
|
122
125
|
const applicationNode = document.querySelector("#application");
|
|
123
|
-
if (applicationNode) {
|
|
124
|
-
const isSSR = applicationNode.querySelector(".application");
|
|
125
|
-
const mount = isSSR ? _reactDom.hydrate : _reactDom.render;
|
|
126
|
-
mount( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Init.default, {
|
|
127
|
-
store: store,
|
|
128
|
-
history: history,
|
|
129
|
-
contextPath: window.contextPath,
|
|
130
|
-
theme: theme,
|
|
131
|
-
ErrorFallbackComponent: ErrorFallbackComponent,
|
|
132
|
-
children: render()
|
|
133
|
-
}), applicationNode);
|
|
134
|
-
} else {
|
|
126
|
+
if (!applicationNode) {
|
|
135
127
|
throw new Error("No DOM element with id application found to attach client to");
|
|
136
128
|
}
|
|
129
|
+
mount(applicationNode, /*#__PURE__*/(0, _jsxRuntime.jsx)(_Init.default, {
|
|
130
|
+
store: store,
|
|
131
|
+
routerHistory: routerHistory,
|
|
132
|
+
contextPath: window.contextPath,
|
|
133
|
+
theme: theme,
|
|
134
|
+
ErrorFallbackComponent: ErrorFallbackComponent,
|
|
135
|
+
children: render()
|
|
136
|
+
}));
|
|
137
137
|
});
|
|
138
138
|
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
*/
|
|
142
|
+
exports.addContentLoadedEvent = addContentLoadedEvent;
|
|
143
|
+
const mountClient = (applicationNode, initComponent) => {
|
|
144
|
+
const isSSR = applicationNode.querySelector(".application");
|
|
145
|
+
if (isSSR) {
|
|
146
|
+
(0, _reactDom.hydrate)(initComponent, applicationNode);
|
|
147
|
+
} else {
|
|
148
|
+
(0, _reactDom.render)(initComponent, applicationNode);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.
|
|
154
|
+
*/
|
|
155
|
+
const client = _ref => {
|
|
156
|
+
let {
|
|
157
|
+
customReducers,
|
|
158
|
+
theme,
|
|
159
|
+
render,
|
|
160
|
+
beforeRenderHooks,
|
|
161
|
+
ErrorFallbackComponent
|
|
162
|
+
} = _ref;
|
|
163
|
+
const {
|
|
164
|
+
store,
|
|
165
|
+
routerHistory
|
|
166
|
+
} = setupClient(customReducers, beforeRenderHooks);
|
|
167
|
+
addContentLoadedEvent(store, routerHistory, theme, render, ErrorFallbackComponent, mountClient);
|
|
168
|
+
};
|
|
139
169
|
var _default = client;
|
|
140
170
|
exports.default = _default;
|
|
141
171
|
//# sourceMappingURL=client.js.map
|