Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move recents to advanced select filters; drop rightmost column in forms #3181

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
58ff9c3
NCI-Agency/anet#1964: Move the recents shortcuts to the first list in…
gjvoosten Feb 20, 2020
cd6cf00
NCI-Agency/anet#1964: Move the contents of the extra (third) form col…
gjvoosten Feb 20, 2020
7826e96
NCI-Agency/anet#1964: Update tests
gjvoosten Sep 3, 2020
b125970
Fix test after merge
gjvoosten Sep 17, 2020
c49ee30
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Sep 29, 2020
17f68ae
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Oct 21, 2020
71e9e37
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Oct 29, 2020
9f2d722
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Nov 12, 2020
62d7194
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Nov 12, 2020
0a061c1
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Nov 19, 2020
ecc6c09
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Dec 10, 2020
3eaad33
NCI-Agency/anet#1964: Fix merge
gjvoosten Dec 10, 2020
d7b68fe
NCI-Agency/anet#1964: Fix tests after merge
gjvoosten Dec 10, 2020
ef42a06
NCI-Agency/anet#1964: Make task's shortName unique
gjvoosten Dec 10, 2020
77cd2e4
NCI-Agency/anet#1964: Use the same form width as before
gjvoosten Dec 10, 2020
f3f8ef3
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Dec 22, 2020
72a89b2
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Dec 23, 2020
9f1cf94
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Jan 4, 2021
408cd7b
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Jan 19, 2021
ff4f9b1
Fix tests after merge
gjvoosten Jan 19, 2021
b4d7e37
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Jan 25, 2021
5f974b5
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Jan 26, 2021
59b0951
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Jan 28, 2021
da90fc3
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Feb 1, 2021
5ef338f
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Feb 9, 2021
3d4f164
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Feb 11, 2021
8c02def
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Feb 18, 2021
18844b1
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Feb 24, 2021
71b1e13
Merge branch 'candidate' into GH-1964-drop-third-form-column
gjvoosten Mar 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 10 additions & 57 deletions client/src/components/FieldHelper.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { CompactRow } from "components/Compact"
import LinkTo from "components/LinkTo"
import _cloneDeep from "lodash/cloneDeep"
import _get from "lodash/get"
import PropTypes from "prop-types"
import React, { useCallback, useMemo } from "react"
import {
Button,
Col,
ControlLabel,
FormControl,
Expand Down Expand Up @@ -69,8 +67,7 @@ const Field = ({
extraColElem,
addon,
vertical,
isCompact,
extraAddon
isCompact
}) => {
const id = getFieldId(field)
const widget = useMemo(
Expand All @@ -80,20 +77,20 @@ const Field = ({
) : (
<InputGroup>
{widgetElem}
{extraAddon && <InputGroup.Addon>{extraAddon}</InputGroup.Addon>}
<FieldAddon id={id} addon={addon} />
</InputGroup>
),
[addon, extraAddon, id, widgetElem]
[addon, id, widgetElem]
)
const validationState = getFormGroupValidationState(field, form)
if (label === undefined) {
label = utils.sentenceCase(field.name) // name is a required prop of field
}
// setting label or extraColElem explicitly to null will completely remove these columns!
const widgetWidth =
12 - (label === null ? 0 : 2) - (extraColElem === null ? 0 : 3)
// controlId prop of the FormGroup sets the id of the control element

// backwards-compatible with main form width before; could be 12 to take up all space
const maxWidth = 9
// setting label explicitly to null will completely remove the label column!
const widgetWidth = maxWidth - (label === null ? 0 : 2)

if (isCompact) {
return (
Expand All @@ -110,6 +107,7 @@ const Field = ({
)
}

// controlId prop of the FormGroup sets the id of the control element
return (
<FormGroup id={`fg-${id}`} controlId={id} validationState={validationState}>
{vertical ? (
Expand All @@ -132,10 +130,10 @@ const Field = ({
{getHelpBlock(field, form)}
{children}
</div>
{extraColElem}
</Col>
</>
)}
{extraColElem && <Col sm={3} {...extraColElem.props} />}
</FormGroup>
)
}
Expand All @@ -148,7 +146,6 @@ Field.propTypes = {
extraColElem: PropTypes.object,
addon: PropTypes.object,
vertical: PropTypes.bool,
extraAddon: PropTypes.object,
isCompact: PropTypes.bool
}
Field.defaultProps = {
Expand All @@ -164,7 +161,6 @@ export const InputField = ({
extraColElem,
addon,
vertical,
extraAddon,
...otherProps
}) => {
const widgetElem = useMemo(
Expand All @@ -188,7 +184,6 @@ export const InputField = ({
extraColElem={extraColElem}
addon={addon}
vertical={vertical}
extraAddon={extraAddon}
/>
)
}
Expand All @@ -200,8 +195,7 @@ InputField.propTypes = {
children: PropTypes.any,
extraColElem: PropTypes.object,
addon: PropTypes.object,
vertical: PropTypes.bool,
extraAddon: PropTypes.object
vertical: PropTypes.bool
}

export const InputFieldNoLabel = ({
Expand Down Expand Up @@ -498,44 +492,3 @@ export function handleSingleSelectAddItem(newItem, onChange, curValue) {
export function handleSingleSelectRemoveItem(oldItem, onChange, curValue) {
onChange(null)
}

export const FieldShortcuts = ({
shortcuts,
fieldName,
objectType,
curValue,
onChange,
handleAddItem,
title
}) =>
shortcuts &&
shortcuts.length > 0 && (
<div id={`${fieldName}-shortcut-list`} className="shortcut-list">
<h5>{title}</h5>
{objectType.map(shortcuts, (shortcut, idx) => (
<Button
key={shortcut.uuid}
bsStyle="link"
onClick={() => handleAddItem(shortcut, onChange, curValue)}
>
Add{" "}
<LinkTo
modelType={objectType.resourceName}
model={shortcut}
isLink={false}
forShortcut
/>
</Button>
))}
</div>
)

FieldShortcuts.propTypes = {
shortcuts: PropTypes.arrayOf(PropTypes.shape({ uuid: PropTypes.string })),
fieldName: PropTypes.string.isRequired,
objectType: PropTypes.func.isRequired,
curValue: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
onChange: PropTypes.func,
handleAddItem: PropTypes.func.isRequired,
title: PropTypes.string.isRequired
}
10 changes: 0 additions & 10 deletions client/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,6 @@ fieldset.danger {
width: 10em;
}

.shortcut-list {
margin-top: -4px;
}

.shortcut-list .btn-link {
text-align: left;
white-space: initial;
padding: 0;
}

.btn.btn-link {
overflow: visible;
width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/HopscotchTour.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const reportTour = (currentUser, history) => {
},
{
title: "Recents",
content: `If you've written reports in the past, your recent selections of attendees, ${subLevelTaskShortLabelPlural}, and locations will display to the right in a section called "Recents". You can click on one of the shortcuts to quickly add it to your report.`,
content: `If you've written reports in the past, your recent selections of attendees, ${subLevelTaskShortLabelPlural}, locations and authorization groups will show up in the select pop-up. You can select them to quickly add them to your report.`,
target: "#attendees",
placement: "bottom"
},
Expand Down
Loading