@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
|
@@ -66,8 +66,8 @@ class ChoiceAttributeOptionModel
|
|
|
66
66
|
const option = new ChoiceAttributeOptionModel();
|
|
67
67
|
|
|
68
68
|
option.code = listitem.id.toString();
|
|
69
|
-
option.attributeCollection = listitem.attributeCollection;
|
|
70
|
-
option.links = listitem.links;
|
|
69
|
+
option.attributeCollection = listitem.attributeCollection.clone();
|
|
70
|
+
option.links = listitem.links.clone();
|
|
71
71
|
|
|
72
72
|
return option;
|
|
73
73
|
}
|
|
@@ -17,14 +17,9 @@ import DatetimeFormatConstraint from "./input-constraints/DatetimeFormatConstrai
|
|
|
17
17
|
import DateBoundaryConstraint from "./input-constraints/DateBoundaryConstraint";
|
|
18
18
|
|
|
19
19
|
import { ATTRIBUTE_WIDTH, ISO_DATE_FORMAT } from "../../constants";
|
|
20
|
-
import { getSetting } from "../../constants/Settings";
|
|
21
|
-
import { IGNORE_FORMAT_SETTING } from "../../constants/LayoutHints";
|
|
22
20
|
|
|
23
21
|
import type { FormErrorAnchor, IConstraintModel } from "../types";
|
|
24
22
|
|
|
25
|
-
// date format of default
|
|
26
|
-
const PRODUCT_DEFAULT_DATE_FORMAT = "dd-MM-yyyy";
|
|
27
|
-
|
|
28
23
|
/**
|
|
29
24
|
*/
|
|
30
25
|
class DatetimeAttributeModel extends StringAttributeModel {
|
|
@@ -239,22 +234,9 @@ class DatetimeAttributeModel extends StringAttributeModel {
|
|
|
239
234
|
return "";
|
|
240
235
|
}
|
|
241
236
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
const dateInputFormatSetting = getSetting("DATE_INPUT_FORMAT", "");
|
|
246
|
-
if (dateInputFormatSetting) {
|
|
247
|
-
return dateInputFormatSetting;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
let format = this.format;
|
|
252
|
-
|
|
253
|
-
let dateFormat = this.hasTime
|
|
254
|
-
? format.replace(this.timeInputFormat, "").trim()
|
|
255
|
-
: format;
|
|
256
|
-
|
|
257
|
-
return dateFormat;
|
|
237
|
+
return this.hasTime
|
|
238
|
+
? this.format.replace(this.timeInputFormat, "").trim()
|
|
239
|
+
: this.format;
|
|
258
240
|
}
|
|
259
241
|
|
|
260
242
|
/**
|
|
@@ -264,35 +246,19 @@ class DatetimeAttributeModel extends StringAttributeModel {
|
|
|
264
246
|
return "";
|
|
265
247
|
}
|
|
266
248
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
? format.replace(this.timeInputFormat, "").trim()
|
|
271
|
-
: format;
|
|
272
|
-
|
|
273
|
-
const readonlyFormatSetting = getSetting("DATE_READONLY_FORMAT", "");
|
|
274
|
-
|
|
275
|
-
if (dateFormat === PRODUCT_DEFAULT_DATE_FORMAT && readonlyFormatSetting) {
|
|
276
|
-
dateFormat = readonlyFormatSetting;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return dateFormat;
|
|
249
|
+
return this.hasTime
|
|
250
|
+
? this.format.replace(this.timeInputFormat, "").trim()
|
|
251
|
+
: this.format;
|
|
280
252
|
}
|
|
281
253
|
|
|
282
254
|
/**
|
|
283
|
-
* return attribute placeholder or
|
|
255
|
+
* return attribute placeholder or return formatlabel without time input format from contributions
|
|
284
256
|
*/
|
|
285
257
|
get placeholder(): string {
|
|
286
258
|
if (this._placeholder !== "") {
|
|
287
259
|
return this._placeholder;
|
|
288
260
|
}
|
|
289
261
|
|
|
290
|
-
const dateInputFormatSetting = getSetting("DATE_INPUT_FORMAT", "");
|
|
291
|
-
|
|
292
|
-
if (dateInputFormatSetting) {
|
|
293
|
-
return dateInputFormatSetting.toLowerCase();
|
|
294
|
-
}
|
|
295
|
-
|
|
296
262
|
const formatLabel = this.getContribution("formatlabel", "");
|
|
297
263
|
|
|
298
264
|
if (this.hasDate && this.hasTime && formatLabel.includes(" ")) {
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import DatetimeAttributeModel from "../DatetimeAttributeModel";
|
|
2
|
-
import { setSettings } from "../../../constants/Settings";
|
|
3
2
|
|
|
4
3
|
describe("dateAttributeModel", () => {
|
|
5
4
|
describe("with date related settings set", () => {
|
|
6
|
-
beforeAll(() => {
|
|
7
|
-
setSettings({ DATE_INPUT_FORMAT: "dd-MM-yyyy" });
|
|
8
|
-
setSettings({ DATE_READONLY_FORMAT: "dd-MM-yyyy" });
|
|
9
|
-
});
|
|
10
5
|
it("should be able to create an empty Attribute object", () => {
|
|
11
6
|
const attribute = new DatetimeAttributeModel();
|
|
12
7
|
|
|
@@ -51,7 +46,7 @@ describe("dateAttributeModel", () => {
|
|
|
51
46
|
|
|
52
47
|
it("can set input", () => {
|
|
53
48
|
const attribute = new DatetimeAttributeModel({});
|
|
54
|
-
attribute.inputvalue = "
|
|
49
|
+
attribute.inputvalue = "2010-12-10";
|
|
55
50
|
|
|
56
51
|
expect(attribute.readonlyvalue).toBe("2010-12-10");
|
|
57
52
|
|
|
@@ -65,36 +60,7 @@ describe("dateAttributeModel", () => {
|
|
|
65
60
|
});
|
|
66
61
|
});
|
|
67
62
|
|
|
68
|
-
describe("with non default date related settings configured", () => {
|
|
69
|
-
beforeAll(() => {
|
|
70
|
-
setSettings({ DATE_INPUT_FORMAT: "MM/dd/yyyy" });
|
|
71
|
-
setSettings({ DATE_READONLY_FORMAT: "mm/dd/yyyy" });
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("returns the right date formats", () => {
|
|
75
|
-
const attribute = new DatetimeAttributeModel(
|
|
76
|
-
{},
|
|
77
|
-
{
|
|
78
|
-
label: "Date of birth",
|
|
79
|
-
type: "date",
|
|
80
|
-
format: "dd-MM-yyyy",
|
|
81
|
-
formatlabel: "dd-mm-yyyy",
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
// expect date input and readonly format to match the settings
|
|
86
|
-
expect(attribute.format).toBe("dd-MM-yyyy");
|
|
87
|
-
expect(attribute.dateInputFormat).toBe("MM/dd/yyyy");
|
|
88
|
-
expect(attribute.dateReadonlyFormat).toBe("mm/dd/yyyy");
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
63
|
describe("without date input and date readonly settings defined", () => {
|
|
93
|
-
beforeAll(() => {
|
|
94
|
-
// explicitly clear setting
|
|
95
|
-
setSettings({ DATE_INPUT_FORMAT: "" });
|
|
96
|
-
setSettings({ DATE_READONLY_FORMAT: "" });
|
|
97
|
-
});
|
|
98
64
|
it("should be able to return contributions format as date input format", () => {
|
|
99
65
|
const attribute = new DatetimeAttributeModel(
|
|
100
66
|
{},
|
|
@@ -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/src/react-client/Init.js
CHANGED
|
@@ -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>
|