orc-shared 5.10.0-dev.2 → 5.10.0-dev.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/metadata.js +30 -11
- package/dist/actions/requestsApi.js +10 -1
- package/dist/components/AppFrame/About.js +136 -100
- package/dist/components/AppFrame/Anchor.js +45 -21
- package/dist/components/AppFrame/AppFrame.js +53 -31
- package/dist/components/AppFrame/Help.js +35 -15
- package/dist/components/AppFrame/MenuItem.js +148 -114
- package/dist/components/AppFrame/Preferences.js +136 -97
- package/dist/components/AppFrame/Sidebar.js +51 -28
- package/dist/components/AppFrame/Topbar.js +61 -36
- package/dist/components/ColumnWrapper.js +28 -5
- package/dist/components/Culture.js +33 -14
- package/dist/components/DropMenu/Menu.js +79 -45
- package/dist/components/DropMenu/index.js +34 -29
- package/dist/components/Form/Combination.js +45 -16
- package/dist/components/Form/Field.js +57 -38
- package/dist/components/Form/FieldElements.js +0 -11
- package/dist/components/Form/Fieldset.js +47 -19
- package/dist/components/Form/Form.js +22 -9
- package/dist/components/Form/FormElement.js +40 -7
- package/dist/components/Form/Inputs/Button.js +63 -18
- package/dist/components/Form/Inputs/ReadOnly.js +50 -27
- package/dist/components/{AppFrame/ApplicationSelector/Header.js → Form/Inputs/Selector.js} +30 -31
- package/dist/components/Form/Inputs/Text.js +20 -37
- package/dist/components/Form/Inputs/Toggles.js +39 -40
- package/dist/components/Form/Inputs/index.js +2 -13
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +31 -11
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +89 -0
- package/dist/components/MaterialUI/DataDisplay/Table.js +109 -18
- package/dist/components/MaterialUI/DataDisplay/TableProps.js +5 -1
- package/dist/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +198 -0
- package/dist/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +4 -1
- package/dist/components/MaterialUI/Inputs/DatePicker.js +14 -14
- package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
- package/dist/components/MaterialUI/Inputs/Select.js +2 -0
- package/dist/components/MaterialUI/Inputs/SelectProps.js +2 -0
- package/dist/components/MaterialUI/Inputs/Switch.js +17 -1
- package/dist/components/MaterialUI/Inputs/SwitchProps.js +2 -0
- package/dist/components/MaterialUI/Inputs/TimePicker.js +14 -21
- package/dist/components/MaterialUI/hocs/withDeferredTooltip.js +3 -1
- package/dist/components/MaterialUI/muiThemes.js +2 -1
- package/dist/components/Provision.js +1 -1
- package/dist/constants.js +2 -1
- package/dist/content/iconsSheet.svg +740 -116
- package/dist/hocs/withScrollBox.js +27 -12
- package/dist/hooks/useDaysAndMonthsLocalization.js +77 -0
- package/dist/hooks/useInMemoryPaging.js +135 -0
- package/dist/hooks/useMultipleFieldEditState.js +12 -3
- package/dist/reducers/metadata.js +6 -0
- package/dist/schemas/metadata.js +9 -1
- package/dist/selectors/locale.js +1 -0
- package/dist/selectors/metadata.js +14 -11
- package/dist/sharedMessages.js +184 -0
- package/dist/utils/ListHelper.js +271 -0
- package/dist/utils/comparisonHelper.js +185 -0
- package/dist/utils/propertyBagHelper.js +3 -1
- package/dist/utils/timezoneHelper.js +18 -31
- package/package.json +4 -3
- package/src/actions/metadata.js +11 -0
- package/src/actions/metadata.test.js +27 -0
- package/src/actions/requestsApi.js +6 -0
- package/src/components/AppFrame/About.js +97 -117
- package/src/components/AppFrame/About.test.js +128 -90
- package/src/components/AppFrame/Anchor.js +34 -36
- package/src/components/AppFrame/Anchor.test.js +5 -68
- package/src/components/AppFrame/AppFrame.js +31 -40
- package/src/components/AppFrame/AppFrame.test.js +424 -445
- package/src/components/AppFrame/Help.js +23 -20
- package/src/components/AppFrame/Help.test.js +3 -3
- package/src/components/AppFrame/MenuItem.js +106 -126
- package/src/components/AppFrame/MenuItem.test.js +78 -169
- package/src/components/AppFrame/Preferences.js +110 -98
- package/src/components/AppFrame/Preferences.test.js +115 -219
- package/src/components/AppFrame/Sidebar.js +39 -41
- package/src/components/AppFrame/Sidebar.test.js +88 -168
- package/src/components/AppFrame/Topbar.js +59 -52
- package/src/components/AppFrame/Topbar.test.js +31 -39
- package/src/components/ColumnWrapper.js +18 -9
- package/src/components/Culture.js +20 -10
- package/src/components/Culture.test.js +27 -16
- package/src/components/DropMenu/DropMenu.test.js +185 -224
- package/src/components/DropMenu/Menu.js +73 -80
- package/src/components/DropMenu/Menu.test.js +35 -86
- package/src/components/DropMenu/index.js +19 -15
- package/src/components/Form/Combination.js +35 -28
- package/src/components/Form/Combination.test.js +6 -19
- package/src/components/Form/Field.js +53 -66
- package/src/components/Form/Field.test.js +29 -51
- package/src/components/Form/FieldElements.js +0 -14
- package/src/components/Form/FieldElements.test.js +104 -111
- package/src/components/Form/Fieldset.js +42 -37
- package/src/components/Form/Fieldset.test.js +14 -7
- package/src/components/Form/Form.js +11 -7
- package/src/components/Form/Form.test.js +75 -56
- package/src/components/Form/FormElement.js +24 -16
- package/src/components/Form/InputField.test.js +24 -30
- package/src/components/Form/Inputs/Button.js +58 -14
- package/src/components/Form/Inputs/Button.test.js +32 -7
- package/src/components/Form/Inputs/Inputs.test.js +0 -7
- package/src/components/Form/Inputs/ReadOnly.js +34 -28
- package/src/components/Form/Inputs/ReadOnly.test.js +45 -7
- package/src/components/Form/Inputs/Selector.js +22 -0
- package/src/components/Form/Inputs/Selector.test.js +105 -0
- package/src/components/Form/Inputs/Text.js +15 -44
- package/src/components/Form/Inputs/Text.test.js +20 -29
- package/src/components/Form/Inputs/Toggles.js +27 -26
- package/src/components/Form/Inputs/Toggles.test.js +22 -28
- package/src/components/Form/Inputs/index.js +4 -15
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.test.js +1 -4
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +32 -6
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.test.js +3 -1
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +39 -0
- package/src/components/MaterialUI/DataDisplay/Table.js +190 -114
- package/src/components/MaterialUI/DataDisplay/Table.test.js +246 -1
- package/src/components/MaterialUI/DataDisplay/TableProps.js +4 -0
- package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -0
- package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +145 -0
- package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.test.js +457 -0
- package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +5 -1
- package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.test.js +7 -1
- package/src/components/MaterialUI/Inputs/DatePicker.js +19 -20
- package/src/components/MaterialUI/Inputs/DatePicker.test.js +11 -6
- package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
- package/src/components/MaterialUI/Inputs/Select.js +2 -0
- package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
- package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
- package/src/components/MaterialUI/Inputs/Switch.js +22 -1
- package/src/components/MaterialUI/Inputs/Switch.test.js +23 -0
- package/src/components/MaterialUI/Inputs/SwitchProps.js +2 -0
- package/src/components/MaterialUI/Inputs/SwitchProps.test.js +2 -0
- package/src/components/MaterialUI/Inputs/TimePicker.js +10 -19
- package/src/components/MaterialUI/Inputs/TimePicker.test.js +278 -117
- package/src/components/MaterialUI/hocs/withDeferredTooltip.js +4 -1
- package/src/components/MaterialUI/hocs/withDeferredTooltip.test.js +27 -0
- package/src/components/MaterialUI/muiThemes.js +1 -0
- package/src/components/Navigation/Bar.test.js +92 -87
- package/src/components/Provision.js +1 -1
- package/src/components/TaskDetailsModal.test.js +1 -3
- package/src/constants.js +1 -0
- package/src/content/iconsSheet.svg +740 -116
- package/src/hocs/withScrollBox.js +32 -19
- package/src/hocs/withScrollBox.test.js +15 -3
- package/src/hooks/useDaysAndMonthsLocalization.js +79 -0
- package/src/hooks/useDaysAndMonthsLocalization.test.js +107 -0
- package/src/hooks/useInMemoryPaging.js +78 -0
- package/src/hooks/useInMemoryPaging.test.js +515 -0
- package/src/hooks/useMultipleFieldEditState.js +11 -4
- package/src/hooks/useMultipleFieldEditState.test.js +49 -1
- package/src/reducers/metadata.js +6 -1
- package/src/reducers/metadata.test.js +31 -0
- package/src/requests +1 -0
- package/src/schemas/metadata.js +3 -0
- package/src/selectors/locale.js +1 -1
- package/src/selectors/metadata.js +12 -9
- package/src/selectors/metadata.test.js +92 -11
- package/src/sharedMessages.js +184 -0
- package/src/timezones.json +883 -0
- package/src/translations/en-US.json +46 -0
- package/src/translations/fr-CA.json +46 -0
- package/src/utils/ListHelper.js +203 -0
- package/src/utils/ListHelper.test.js +710 -0
- package/src/utils/comparisonHelper.js +135 -0
- package/src/utils/comparisonHelper.test.js +334 -0
- package/src/utils/propertyBagHelper.js +2 -0
- package/src/utils/propertyBagHelper.test.js +6 -0
- package/src/utils/timezoneHelper.js +10 -135
- package/src/utils/timezoneHelper.test.js +7 -7
- package/dist/components/Form/FieldList.js +0 -270
- package/dist/components/Form/Inputs/FieldButtons.js +0 -66
- package/dist/components/Form/Inputs/Number.js +0 -117
- package/dist/components/Form/Inputs/SmallButton.js +0 -91
- package/dist/components/Form/Inputs/Time.js +0 -86
- package/dist/components/Form/Inputs/Translation.js +0 -169
- package/src/components/AppFrame/ApplicationSelector/Header.js +0 -34
- package/src/components/AppFrame/ApplicationSelector/Header.test.js +0 -23
- package/src/components/Form/FieldList.js +0 -210
- package/src/components/Form/FieldList.test.js +0 -558
- package/src/components/Form/Inputs/FieldButtons.js +0 -90
- package/src/components/Form/Inputs/Number.js +0 -60
- package/src/components/Form/Inputs/Number.test.js +0 -435
- package/src/components/Form/Inputs/SmallButton.js +0 -37
- package/src/components/Form/Inputs/SmallButton.test.js +0 -65
- package/src/components/Form/Inputs/Time.js +0 -32
- package/src/components/Form/Inputs/Time.test.js +0 -41
- package/src/components/Form/Inputs/Translation.js +0 -93
- package/src/components/Form/Inputs/Translation.test.js +0 -204
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Immutable from "immutable";
|
|
3
3
|
import { Provider } from "react-redux";
|
|
4
|
+
import { generateClassName } from "../../utils/testUtils";
|
|
4
5
|
import { IntlProvider } from "react-intl";
|
|
5
6
|
import Form from "./FormElement";
|
|
6
7
|
import FieldElements from "./FieldElements";
|
|
7
|
-
import
|
|
8
|
-
import { FormPage,
|
|
8
|
+
import Field from "./Field";
|
|
9
|
+
import { FormPage, FormContext } from "./Form";
|
|
10
|
+
import { StylesProvider } from "@material-ui/core";
|
|
11
|
+
import { TextInput } from "./Inputs/Text";
|
|
9
12
|
|
|
10
13
|
describe("FormPage", () => {
|
|
11
14
|
let state, store, getUpdater, fields, manyFields, values;
|
|
@@ -36,94 +39,110 @@ describe("FormPage", () => {
|
|
|
36
39
|
it("renders a form with a single field", () =>
|
|
37
40
|
expect(
|
|
38
41
|
<Provider store={store}>
|
|
39
|
-
<
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
43
|
+
<IntlProvider locale="en">
|
|
44
|
+
<FormPage formName="testForm" fields={fields} getUpdater={getUpdater} values={values} />
|
|
45
|
+
</IntlProvider>
|
|
46
|
+
</StylesProvider>
|
|
42
47
|
</Provider>,
|
|
43
48
|
"when mounted",
|
|
44
49
|
"to satisfy",
|
|
45
50
|
<Provider store={store}>
|
|
46
|
-
<
|
|
47
|
-
<
|
|
48
|
-
<
|
|
49
|
-
<
|
|
50
|
-
<
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
52
|
+
<IntlProvider locale="en">
|
|
53
|
+
<FormContext.Provider value={{ values, formName: "testForm" }}>
|
|
54
|
+
<div>
|
|
55
|
+
<Form spanWidth={1}>
|
|
56
|
+
<Field>
|
|
57
|
+
<label>A text</label>
|
|
58
|
+
<TextInput value="foo" />
|
|
59
|
+
</Field>
|
|
60
|
+
</Form>
|
|
61
|
+
</div>
|
|
62
|
+
</FormContext.Provider>
|
|
63
|
+
</IntlProvider>
|
|
64
|
+
</StylesProvider>
|
|
58
65
|
</Provider>,
|
|
59
66
|
));
|
|
60
67
|
|
|
61
68
|
it("still respects 'wide' flag", () =>
|
|
62
69
|
expect(
|
|
63
70
|
<Provider store={store}>
|
|
64
|
-
<
|
|
65
|
-
<
|
|
66
|
-
|
|
71
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
72
|
+
<IntlProvider locale="en">
|
|
73
|
+
<FormPage wide fields={fields} getUpdater={getUpdater} values={values} />
|
|
74
|
+
</IntlProvider>
|
|
75
|
+
</StylesProvider>
|
|
67
76
|
</Provider>,
|
|
68
77
|
"when mounted",
|
|
69
78
|
"to satisfy",
|
|
70
79
|
<Provider store={store}>
|
|
71
|
-
<
|
|
72
|
-
<
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
81
|
+
<IntlProvider locale="en">
|
|
82
|
+
<FormContext.Provider value={{ values }}>
|
|
83
|
+
<div>
|
|
84
|
+
<Form spanWidth={1}>
|
|
85
|
+
<FieldElements getUpdater={getUpdater} fields={fields} />
|
|
86
|
+
</Form>
|
|
87
|
+
</div>
|
|
88
|
+
</FormContext.Provider>
|
|
89
|
+
</IntlProvider>
|
|
90
|
+
</StylesProvider>
|
|
80
91
|
</Provider>,
|
|
81
92
|
));
|
|
82
93
|
|
|
83
94
|
it("still respects 'wide' flag with multiple fields", () =>
|
|
84
95
|
expect(
|
|
85
96
|
<Provider store={store}>
|
|
86
|
-
<
|
|
87
|
-
<
|
|
88
|
-
|
|
97
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
98
|
+
<IntlProvider locale="en">
|
|
99
|
+
<FormPage wide cols={[2, 1]} fields={manyFields} getUpdater={getUpdater} values={values} />
|
|
100
|
+
</IntlProvider>
|
|
101
|
+
</StylesProvider>
|
|
89
102
|
</Provider>,
|
|
90
103
|
"when mounted",
|
|
91
104
|
"to satisfy",
|
|
92
105
|
<Provider store={store}>
|
|
93
|
-
<
|
|
94
|
-
<
|
|
95
|
-
<
|
|
96
|
-
<
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
107
|
+
<IntlProvider locale="en">
|
|
108
|
+
<FormContext.Provider value={{ values }}>
|
|
109
|
+
<div>
|
|
110
|
+
<Form spanWidth={1}>
|
|
111
|
+
<FieldElements getUpdater={getUpdater} fields={manyFields} />
|
|
112
|
+
</Form>
|
|
113
|
+
</div>
|
|
114
|
+
</FormContext.Provider>
|
|
115
|
+
</IntlProvider>
|
|
116
|
+
</StylesProvider>
|
|
102
117
|
</Provider>,
|
|
103
118
|
));
|
|
104
119
|
|
|
105
120
|
it("renders a form with a multiple fields", () =>
|
|
106
121
|
expect(
|
|
107
122
|
<Provider store={store}>
|
|
108
|
-
<
|
|
109
|
-
<
|
|
110
|
-
|
|
123
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
124
|
+
<IntlProvider locale="en">
|
|
125
|
+
<FormPage cols={[2, 1]} fields={manyFields} getUpdater={getUpdater} values={values} />
|
|
126
|
+
</IntlProvider>
|
|
127
|
+
</StylesProvider>
|
|
111
128
|
</Provider>,
|
|
112
129
|
"when mounted",
|
|
113
130
|
"to satisfy",
|
|
114
131
|
<Provider store={store}>
|
|
115
|
-
<
|
|
116
|
-
<
|
|
117
|
-
<
|
|
118
|
-
<
|
|
119
|
-
<
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
132
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
133
|
+
<IntlProvider locale="en">
|
|
134
|
+
<FormContext.Provider value={{ values }}>
|
|
135
|
+
<div>
|
|
136
|
+
<Form spanWidth={2}>
|
|
137
|
+
<FieldElements getUpdater={getUpdater} fields={manyFields.slice(0, 5)} />
|
|
138
|
+
</Form>
|
|
139
|
+
<Form spanWidth={1}>
|
|
140
|
+
<FieldElements getUpdater={getUpdater} fields={manyFields.slice(5, 10)} />
|
|
141
|
+
</Form>
|
|
142
|
+
</div>
|
|
143
|
+
</FormContext.Provider>
|
|
144
|
+
</IntlProvider>
|
|
145
|
+
</StylesProvider>
|
|
127
146
|
</Provider>,
|
|
128
147
|
));
|
|
129
148
|
});
|
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
2
|
+
import React from "react";
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
const useStyles = makeStyles(() => ({
|
|
5
|
+
form: {
|
|
6
|
+
boxSizing: "border-box",
|
|
7
|
+
flexBasis: 0,
|
|
8
|
+
flexShrink: 0,
|
|
9
|
+
display: "flex",
|
|
10
|
+
flexDirection: "column",
|
|
11
|
+
padding: 0,
|
|
12
|
+
paddingRight: 20,
|
|
13
|
+
paddingTop: 0,
|
|
14
|
+
fontSize: 12,
|
|
15
|
+
flexGrow: props => props.spanWidth,
|
|
16
|
+
"&:first-child": {
|
|
17
|
+
paddingLeft: 20,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
14
21
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
const Form = ({ spanWidth = 1, children }) => {
|
|
23
|
+
const classes = useStyles({ spanWidth });
|
|
24
|
+
|
|
25
|
+
return <div className={classes.form}>{children}</div>;
|
|
26
|
+
};
|
|
19
27
|
|
|
20
28
|
export default Form;
|
|
@@ -89,7 +89,7 @@ describe("InputField", () => {
|
|
|
89
89
|
it("gives error message if given no type", () =>
|
|
90
90
|
expect(
|
|
91
91
|
<SubjectWrapper store={store} values={{}}>
|
|
92
|
-
<InputField label="A bad field" otherProp />
|
|
92
|
+
<InputField label={{ id: "BadField", defaultMessage: "A bad field" }} otherProp />
|
|
93
93
|
</SubjectWrapper>,
|
|
94
94
|
"when mounted",
|
|
95
95
|
"to satisfy",
|
|
@@ -100,12 +100,7 @@ describe("InputField", () => {
|
|
|
100
100
|
|
|
101
101
|
Object.keys(inputs).forEach(type => {
|
|
102
102
|
describe("input type " + type, () => {
|
|
103
|
-
let Input,
|
|
104
|
-
val,
|
|
105
|
-
emptyVal,
|
|
106
|
-
target,
|
|
107
|
-
options,
|
|
108
|
-
center = false;
|
|
103
|
+
let Input, val, emptyVal, target, options;
|
|
109
104
|
beforeEach(() => {
|
|
110
105
|
Input = inputs[type];
|
|
111
106
|
target = "input";
|
|
@@ -123,16 +118,12 @@ describe("InputField", () => {
|
|
|
123
118
|
val = "thing";
|
|
124
119
|
}
|
|
125
120
|
target = "select";
|
|
126
|
-
} else if (type === "
|
|
121
|
+
} else if (type === "SwitchInput") {
|
|
127
122
|
val = true;
|
|
128
|
-
center = true;
|
|
129
|
-
} else if (type === "TranslationInput") {
|
|
130
|
-
val = { "en-US": "Words", "fr-CA": "Des mots" };
|
|
131
|
-
emptyVal = undefined;
|
|
132
123
|
} else if (type === "DateInput") {
|
|
133
124
|
val = "2014-05-22";
|
|
134
125
|
emptyVal = "";
|
|
135
|
-
} else if (type === "Button"
|
|
126
|
+
} else if (type === "Button") {
|
|
136
127
|
target = "button";
|
|
137
128
|
}
|
|
138
129
|
});
|
|
@@ -143,7 +134,7 @@ describe("InputField", () => {
|
|
|
143
134
|
<InputField
|
|
144
135
|
name="fieldName"
|
|
145
136
|
type={type}
|
|
146
|
-
label={
|
|
137
|
+
label={{ id: "BadField", defaultMessage: "A bad field" }}
|
|
147
138
|
placeholder={{
|
|
148
139
|
id: "foo.bar",
|
|
149
140
|
defaultMessage: "Placeholder",
|
|
@@ -155,7 +146,7 @@ describe("InputField", () => {
|
|
|
155
146
|
"when mounted",
|
|
156
147
|
"to satisfy",
|
|
157
148
|
<PatternWrapper store={store}>
|
|
158
|
-
<Field wasBlurred
|
|
149
|
+
<Field wasBlurred id="fieldName" label={{ id: "BadField", defaultMessage: "A bad field" }}>
|
|
159
150
|
<Input
|
|
160
151
|
id="fieldName"
|
|
161
152
|
data-test-id="field_fieldName"
|
|
@@ -174,7 +165,7 @@ describe("InputField", () => {
|
|
|
174
165
|
<InputField
|
|
175
166
|
name="fieldName"
|
|
176
167
|
type={type}
|
|
177
|
-
label={
|
|
168
|
+
label={{ id: "BadField", defaultMessage: "A bad field" }}
|
|
178
169
|
placeholder={{
|
|
179
170
|
id: "foo.bar",
|
|
180
171
|
defaultMessage: "Placeholder",
|
|
@@ -186,7 +177,7 @@ describe("InputField", () => {
|
|
|
186
177
|
"when mounted",
|
|
187
178
|
"to satisfy",
|
|
188
179
|
<PatternWrapper store={store}>
|
|
189
|
-
<Field
|
|
180
|
+
<Field id="fieldName" label={{ id: "BadField", defaultMessage: "A bad field" }}>
|
|
190
181
|
<Input
|
|
191
182
|
id="fieldName"
|
|
192
183
|
data-test-id="testForm_fieldName"
|
|
@@ -199,7 +190,7 @@ describe("InputField", () => {
|
|
|
199
190
|
</PatternWrapper>,
|
|
200
191
|
));
|
|
201
192
|
|
|
202
|
-
const cannotRequire = ["
|
|
193
|
+
const cannotRequire = ["SwitchInput", "LineLabel", "ReadOnly", "Selector"];
|
|
203
194
|
if (!cannotRequire.includes(type)) {
|
|
204
195
|
it("renders a required field", () =>
|
|
205
196
|
expect(
|
|
@@ -207,12 +198,13 @@ describe("InputField", () => {
|
|
|
207
198
|
<InputField
|
|
208
199
|
name="fieldName"
|
|
209
200
|
type={type}
|
|
210
|
-
label={
|
|
201
|
+
label={{ id: "BadField", defaultMessage: "A bad field" }}
|
|
211
202
|
placeholder={{
|
|
212
203
|
id: "foo.bar",
|
|
213
204
|
defaultMessage: "Placeholder",
|
|
214
205
|
}}
|
|
215
206
|
required={`A ${type} field is a required field`}
|
|
207
|
+
update={() => {}}
|
|
216
208
|
options={options}
|
|
217
209
|
otherProp
|
|
218
210
|
/>
|
|
@@ -224,10 +216,9 @@ describe("InputField", () => {
|
|
|
224
216
|
<SubjectWrapper store={store} values={{ fieldName: val }}>
|
|
225
217
|
<Field
|
|
226
218
|
wasBlurred
|
|
227
|
-
center={center}
|
|
228
219
|
id="fieldName"
|
|
229
|
-
label={`A ${type} field`}
|
|
230
220
|
required={`A ${type} field is a required field`}
|
|
221
|
+
label={{ id: "BadField", defaultMessage: "A bad field" }}
|
|
231
222
|
>
|
|
232
223
|
<Input id="fieldName" value={val} otherProp placeholder="Placeholder" options={options} required />
|
|
233
224
|
</Field>
|
|
@@ -240,7 +231,7 @@ describe("InputField", () => {
|
|
|
240
231
|
<InputField
|
|
241
232
|
name="fieldName"
|
|
242
233
|
type={type}
|
|
243
|
-
label={
|
|
234
|
+
label={{ id: "BadField", defaultMessage: "A bad field" }}
|
|
244
235
|
placeholder={{
|
|
245
236
|
id: "foo.bar",
|
|
246
237
|
defaultMessage: "Placeholder",
|
|
@@ -255,10 +246,9 @@ describe("InputField", () => {
|
|
|
255
246
|
<PatternWrapper store={store}>
|
|
256
247
|
<Field
|
|
257
248
|
wasBlurred
|
|
258
|
-
center={center}
|
|
259
249
|
id="fieldName"
|
|
260
|
-
label={`A ${type} field`}
|
|
261
250
|
required={`A ${type} field is a required field`}
|
|
251
|
+
label={{ id: "BadField", defaultMessage: "A bad field" }}
|
|
262
252
|
invalid
|
|
263
253
|
>
|
|
264
254
|
<Input id="fieldName" value={emptyVal} otherProp placeholder="Placeholder" options={options} required />
|
|
@@ -272,7 +262,7 @@ describe("InputField", () => {
|
|
|
272
262
|
<InputField
|
|
273
263
|
name="fieldName"
|
|
274
264
|
type={type}
|
|
275
|
-
label={
|
|
265
|
+
label={{ id: "BadField", defaultMessage: "A bad field" }}
|
|
276
266
|
placeholder={{
|
|
277
267
|
id: "foo.bar",
|
|
278
268
|
defaultMessage: "Placeholder",
|
|
@@ -287,10 +277,9 @@ describe("InputField", () => {
|
|
|
287
277
|
<PatternWrapper store={store}>
|
|
288
278
|
<Field
|
|
289
279
|
wasBlurred
|
|
290
|
-
center={center}
|
|
291
280
|
id="fieldName"
|
|
292
|
-
label={`A ${type} field`}
|
|
293
281
|
required={`A ${type} field is a required field`}
|
|
282
|
+
label={{ id: "BadField", defaultMessage: "A bad field" }}
|
|
294
283
|
invalid
|
|
295
284
|
>
|
|
296
285
|
<Input
|
|
@@ -310,17 +299,22 @@ describe("InputField", () => {
|
|
|
310
299
|
it("modifies the field name if inside a list", () =>
|
|
311
300
|
expect(
|
|
312
301
|
<SubjectWrapper store={store} values={{ fieldName: val }} index={12}>
|
|
313
|
-
<InputField
|
|
302
|
+
<InputField
|
|
303
|
+
name="fieldName"
|
|
304
|
+
type={type}
|
|
305
|
+
label={{ id: "BadField", defaultMessage: "A bad field" }}
|
|
306
|
+
options={options}
|
|
307
|
+
otherProp
|
|
308
|
+
/>
|
|
314
309
|
</SubjectWrapper>,
|
|
315
310
|
"when mounted",
|
|
316
311
|
"to satisfy",
|
|
317
312
|
<PatternWrapper store={store}>
|
|
318
313
|
<Field
|
|
319
314
|
wasBlurred
|
|
320
|
-
center={center}
|
|
321
315
|
id="fieldName[12]"
|
|
322
316
|
data-test-id="field_fieldName[12]"
|
|
323
|
-
label={
|
|
317
|
+
label={{ id: "BadField", defaultMessage: "A bad field" }}
|
|
324
318
|
>
|
|
325
319
|
<Input id="fieldName[12]" value={val} otherProp options={options} />
|
|
326
320
|
</Field>
|
|
@@ -1,21 +1,65 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
3
|
+
import Button from "@material-ui/core/Button";
|
|
3
4
|
import withId from "../../../hocs/withId";
|
|
4
|
-
import
|
|
5
|
+
import Icon from "../../MaterialUI/DataDisplay/Icon";
|
|
6
|
+
import { FormattedMessage } from "react-intl";
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const useStyles = makeStyles(theme => ({
|
|
9
|
+
positionedButton: {
|
|
10
|
+
width: "max-content",
|
|
11
|
+
position: "relative",
|
|
12
|
+
padding: "6px 14px !important",
|
|
13
|
+
"&:hover": {
|
|
14
|
+
borderColor: "#4fa1f0",
|
|
15
|
+
boxShadow: "0 0 4px #4fa1f0",
|
|
16
|
+
outline: "none",
|
|
17
|
+
backgroundColor: "#f7f7f7 !important",
|
|
18
|
+
},
|
|
19
|
+
"&:disabled": {
|
|
20
|
+
opacity: 0.6,
|
|
21
|
+
backgroundColor: "#f7f7f7 !important",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
buttonIcon: {
|
|
25
|
+
height: "1em",
|
|
26
|
+
width: "1em",
|
|
27
|
+
fill: "currentColor",
|
|
28
|
+
stroke: "currentColor",
|
|
29
|
+
fontSize: "1.23em !important",
|
|
30
|
+
},
|
|
31
|
+
primaryButton: {
|
|
32
|
+
color: `${theme.palette.primary.main} !important`,
|
|
33
|
+
border: `1px solid ${theme.palette.primary.main} !important`,
|
|
34
|
+
backgroundColor: "#fff !important",
|
|
35
|
+
"&:hover": {
|
|
36
|
+
backgroundColor: "#fff !important",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
primaryIcon: {
|
|
40
|
+
color: `${theme.palette.primary.main} !important`,
|
|
41
|
+
},
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
const FormButton = ({ id, icon, buttonText, update, primary, ...props }) => {
|
|
45
|
+
const classes = useStyles();
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Button
|
|
49
|
+
id={id}
|
|
50
|
+
className={`${classes.positionedButton} ${primary ? classes.primaryButton : ""}`}
|
|
51
|
+
onClick={update}
|
|
52
|
+
variant="outlined"
|
|
53
|
+
startIcon={
|
|
54
|
+
icon ? <Icon id={icon} className={`${classes.buttonIcon} ${primary ? classes.primaryIcon : ""}`} /> : null
|
|
55
|
+
}
|
|
56
|
+
{...props}
|
|
57
|
+
>
|
|
58
|
+
{buttonText ? <FormattedMessage {...buttonText} /> : null}
|
|
59
|
+
</Button>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
10
62
|
|
|
11
|
-
export const FormButton = ({
|
|
12
|
-
id,
|
|
13
|
-
icon,
|
|
14
|
-
buttonText,
|
|
15
|
-
update,
|
|
16
|
-
"aria-labelledby": aria, // Not meaningful for buttons
|
|
17
|
-
...props
|
|
18
|
-
}) => <PositionedButton id={id} {...props} onClick={update} icon={icon} label={buttonText} />;
|
|
19
63
|
FormButton.displayName = "FormButton";
|
|
20
64
|
|
|
21
65
|
export default withId("formbutton")(FormButton);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Provider } from "react-redux";
|
|
3
|
-
import {
|
|
3
|
+
import { IntlProvider } from "react-intl";
|
|
4
|
+
import FormButton from "./Button";
|
|
5
|
+
import Button from "@material-ui/core/Button";
|
|
6
|
+
import Icon from "../../MaterialUI/DataDisplay/Icon";
|
|
4
7
|
|
|
5
8
|
describe("FormButton", () => {
|
|
6
9
|
let update;
|
|
@@ -17,7 +20,9 @@ describe("FormButton", () => {
|
|
|
17
20
|
getState: () => ({}),
|
|
18
21
|
}}
|
|
19
22
|
>
|
|
20
|
-
<
|
|
23
|
+
<IntlProvider locale="en">
|
|
24
|
+
<FormButton id="testId" update={update} icon="test-icon" otherProp />
|
|
25
|
+
</IntlProvider>
|
|
21
26
|
</Provider>,
|
|
22
27
|
"when mounted",
|
|
23
28
|
"to satisfy",
|
|
@@ -28,7 +33,7 @@ describe("FormButton", () => {
|
|
|
28
33
|
getState: () => ({}),
|
|
29
34
|
}}
|
|
30
35
|
>
|
|
31
|
-
<
|
|
36
|
+
<Button id="testId" otherProp onClick={update} startIcon={<Icon id="test-icon" />} variant="outlined"></Button>
|
|
32
37
|
</Provider>,
|
|
33
38
|
));
|
|
34
39
|
|
|
@@ -41,7 +46,14 @@ describe("FormButton", () => {
|
|
|
41
46
|
getState: () => ({}),
|
|
42
47
|
}}
|
|
43
48
|
>
|
|
44
|
-
<
|
|
49
|
+
<IntlProvider locale="en">
|
|
50
|
+
<FormButton
|
|
51
|
+
id="testId"
|
|
52
|
+
update={update}
|
|
53
|
+
buttonText={{ id: "PushThis", defaultMessage: "Push this" }}
|
|
54
|
+
otherProp
|
|
55
|
+
/>
|
|
56
|
+
</IntlProvider>
|
|
45
57
|
</Provider>,
|
|
46
58
|
"when mounted",
|
|
47
59
|
"to satisfy",
|
|
@@ -52,7 +64,9 @@ describe("FormButton", () => {
|
|
|
52
64
|
getState: () => ({}),
|
|
53
65
|
}}
|
|
54
66
|
>
|
|
55
|
-
<
|
|
67
|
+
<Button id="testId" otherProp onClick={update} variant="outlined">
|
|
68
|
+
Push this
|
|
69
|
+
</Button>
|
|
56
70
|
</Provider>,
|
|
57
71
|
));
|
|
58
72
|
|
|
@@ -65,7 +79,16 @@ describe("FormButton", () => {
|
|
|
65
79
|
getState: () => ({}),
|
|
66
80
|
}}
|
|
67
81
|
>
|
|
68
|
-
<
|
|
82
|
+
<IntlProvider locale="en">
|
|
83
|
+
<FormButton
|
|
84
|
+
id="testId"
|
|
85
|
+
update={update}
|
|
86
|
+
icon="test-icon"
|
|
87
|
+
buttonText={{ id: "PushThis", defaultMessage: "Push this" }}
|
|
88
|
+
primary
|
|
89
|
+
otherProp
|
|
90
|
+
/>
|
|
91
|
+
</IntlProvider>
|
|
69
92
|
</Provider>,
|
|
70
93
|
"when mounted",
|
|
71
94
|
"to satisfy",
|
|
@@ -76,7 +99,9 @@ describe("FormButton", () => {
|
|
|
76
99
|
getState: () => ({}),
|
|
77
100
|
}}
|
|
78
101
|
>
|
|
79
|
-
<
|
|
102
|
+
<Button id="testId" otherProp onClick={update} startIcon={<Icon id="test-icon" />} variant="outlined">
|
|
103
|
+
Push this
|
|
104
|
+
</Button>
|
|
80
105
|
</Provider>,
|
|
81
106
|
));
|
|
82
107
|
});
|
|
@@ -4,18 +4,11 @@ describe("Input field collection", () => {
|
|
|
4
4
|
it("contains a list of named inputs", () =>
|
|
5
5
|
expect(inputs, "to exhaustively satisfy", {
|
|
6
6
|
Button: expect.it("to be a function"),
|
|
7
|
-
CheckboxInput: expect.it("to be a function"),
|
|
8
7
|
DateInput: expect.it("to be a function"),
|
|
9
|
-
EmailInput: expect.it("to be a function"),
|
|
10
|
-
NumberInput: expect.it("to be a function"),
|
|
11
8
|
MultiSelector: expect.it("to be a function"),
|
|
12
|
-
LineLabel: expect.it("to be a function"),
|
|
13
9
|
ReadOnly: expect.it("to be a function"),
|
|
14
10
|
Selector: expect.it("to be a function"),
|
|
15
|
-
SmallButton: expect.it("to be a function"),
|
|
16
11
|
SwitchInput: expect.it("to be a function"),
|
|
17
12
|
TextInput: expect.it("to be a function"),
|
|
18
|
-
TimeInput: expect.it("to be a function"),
|
|
19
|
-
TranslationInput: expect.it("to be a function"),
|
|
20
13
|
}));
|
|
21
14
|
});
|
|
@@ -1,34 +1,40 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
3
|
+
import { FormattedMessage } from "react-intl";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const useStyles = makeStyles(() => ({
|
|
6
|
+
centerWrapper: {
|
|
7
|
+
minHeight: 30,
|
|
8
|
+
display: "flex",
|
|
9
|
+
alignItems: "center",
|
|
10
|
+
},
|
|
11
|
+
readOnlyBlock: {
|
|
12
|
+
margin: 0,
|
|
13
|
+
},
|
|
14
|
+
label: {
|
|
15
|
+
margin: 0,
|
|
16
|
+
fontSize: 16,
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
10
19
|
|
|
11
|
-
export const
|
|
12
|
-
|
|
13
|
-
`;
|
|
20
|
+
export const ReadOnly = ({ value }) => {
|
|
21
|
+
const classes = useStyles();
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
);
|
|
23
|
+
return (
|
|
24
|
+
<div className={classes.centerWrapper}>
|
|
25
|
+
<p className={classes.readOnlyBlock}>{typeof value === "string" ? value : <FormattedMessage {...value} />}</p>
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
22
29
|
|
|
23
|
-
export const
|
|
24
|
-
|
|
25
|
-
font-size: 16px;
|
|
26
|
-
`;
|
|
30
|
+
export const LineLabel = ({ value }) => {
|
|
31
|
+
const classes = useStyles();
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
return (
|
|
34
|
+
<div className={classes.centerWrapper}>
|
|
35
|
+
<p className={classes.label}>{typeof value === "string" ? value : <FormattedMessage {...value} />}</p>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default ReadOnly;
|