Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 703fb73

Browse files
committed
Updates to behaviour of team description popup:
Set min=1 on number inputs. Set maxlengths as per #313. Add cross-browser month input component. Change durationWeek and numberOfResources to number for request. Remove description value from form data when toggled off of form.
1 parent 4b8ede8 commit 703fb73

File tree

7 files changed

+75
-28
lines changed

7 files changed

+75
-28
lines changed

package-lock.json

+31-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"prop-types": "^15.7.2",
7272
"react": "^16.12.0",
7373
"react-avatar": "^3.9.7",
74-
"react-datepicker": "^3.4.1",
74+
"react-datepicker": "^3.8.0",
7575
"react-dom": "^16.12.0",
7676
"react-final-form": "^6.5.2",
7777
"react-final-form-arrays": "^3.1.3",

src/components/FormField/index.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ const FormField = ({ field }) => {
8282
onBlur={input.onBlur}
8383
onFocus={input.onFocus}
8484
className={meta.error && meta.touched ? "error" : ""}
85+
maxLength={field.maxLength}
8586
/>
8687
)}
8788
{field.type === FORM_FIELD_TYPE.DATE && (

src/components/TextArea/index.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function TextArea(props) {
1818
autoFocus={props.autoFocus}
1919
onBlur={props.onBlur}
2020
onFocus={props.onFocus}
21+
maxLength={props.maxLength}
2122
/>
2223
);
2324
}

src/routes/CreateNewTeam/components/SubmitContainer/index.jsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,8 @@ function SubmitContainer({
7878
if (key === "teamName" || key === "teamDescription") {
7979
continue;
8080
}
81-
const position = _.pick(
82-
formData[key],
83-
"numberOfResources",
84-
"durationWeeks",
85-
"startMonth"
81+
const position = _.mapValues(formData[key], (val, key) =>
82+
key === "startMonth" ? val : parseInt(val, 10)
8683
);
8784

8885
position.roleSearchRequestId = key;

src/routes/CreateNewTeam/components/TeamDetailsModal/index.jsx

+38-10
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ import { FORM_FIELD_TYPE } from "constants/";
1212
import { formatPlural } from "utils/format";
1313
import Button from "components/Button";
1414
import "./styles.module.scss";
15+
import DatePicker from "react-datepicker";
1516

1617
const Error = ({ name }) => {
1718
const {
18-
meta: { touched, error },
19-
} = useField(name, { subscription: { touched: true, error: true } });
20-
return touched && error ? <span styleName="error">{error}</span> : null;
19+
meta: { dirty, error },
20+
} = useField(name, { subscription: { dirty: true, error: true } });
21+
return dirty && error ? <span styleName="error">{error}</span> : null;
2122
};
2223

2324
function TeamDetailsModal({ open, onClose, submitForm, addedRoles }) {
@@ -95,10 +96,21 @@ function TeamDetailsModal({ open, onClose, submitForm, addedRoles }) {
9596
return (
9697
<Form
9798
onSubmit={submitForm}
99+
mutators={{
100+
clearField: ([fieldName], state, { changeValue }) => {
101+
changeValue(state, fieldName, () => undefined);
102+
},
103+
}}
98104
initialValues={{ teamName: "My Great Team" }}
99105
validate={validator}
100106
>
101-
{({ handleSubmit, hasValidationErrors }) => {
107+
{({
108+
handleSubmit,
109+
hasValidationErrors,
110+
form: {
111+
mutators: { clearField },
112+
},
113+
}) => {
102114
return (
103115
<BaseCreateModal
104116
open={open}
@@ -123,7 +135,7 @@ function TeamDetailsModal({ open, onClose, submitForm, addedRoles }) {
123135
name: "teamName",
124136
label: "Team Name",
125137
placeholder: "Team Name",
126-
maxLength: 50,
138+
maxLength: 255,
127139
customValidator: true,
128140
}}
129141
/>
@@ -134,13 +146,16 @@ function TeamDetailsModal({ open, onClose, submitForm, addedRoles }) {
134146
name: "teamDescription",
135147
label: "Short description about the team/ project",
136148
placeholder: "Short description about the team/ project",
137-
maxLength: 1000,
149+
maxLength: 600,
138150
}}
139151
/>
140152
)}
141153
<button
142154
styleName="toggle-button toggle-description"
143-
onClick={toggleDescription}
155+
onClick={() => {
156+
clearField("teamDescription");
157+
toggleDescription();
158+
}}
144159
>
145160
<span>{showDescription ? "–" : "+"}</span>
146161
{showDescription ? " Remove Description" : " Add Description"}
@@ -163,6 +178,7 @@ function TeamDetailsModal({ open, onClose, submitForm, addedRoles }) {
163178
component="input"
164179
type="number"
165180
initialValue="3"
181+
min="1"
166182
/>
167183
<Error name={`${id}.numberOfResources`} />
168184
</td>
@@ -172,6 +188,7 @@ function TeamDetailsModal({ open, onClose, submitForm, addedRoles }) {
172188
component="input"
173189
type="number"
174190
initialValue="20"
191+
min="1"
175192
/>
176193
<Error name={`${id}.durationWeeks`} />
177194
</td>
@@ -180,9 +197,20 @@ function TeamDetailsModal({ open, onClose, submitForm, addedRoles }) {
180197
<>
181198
<Field
182199
name={`${id}.startMonth`}
183-
component="input"
184-
type="month"
185-
/>
200+
initialValue={Date.now()}
201+
>
202+
{(props) => (
203+
<DatePicker
204+
name={props.input.name}
205+
selected={props.input.value}
206+
onChange={props.input.onChange}
207+
dateFormat="MMM, yyyy"
208+
showMonthYearPicker
209+
showPopperArrow={false}
210+
onBlur={props.input.onBlur}
211+
/>
212+
)}
213+
</Field>
186214
<Error name={`${id}.startMonth`} />
187215
</>
188216
) : (

src/styles/main.vendor.scss

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
@import "~react-redux-toastr/src/styles/index";
55
@import "~react-responsive-modal/styles";
66
@import "~react-loader-spinner/dist/loader/css/react-spinner-loader.css";
7+
@import "~react-datepicker/dist/react-datepicker.css";
78

89
// toast-ui.editor styles
910
@import "~codemirror/lib/codemirror.css";

0 commit comments

Comments
 (0)