Skip to content

Commit 1f90dde

Browse files
authored
feat(inline-edit): user should see instance field input (#1172)
* feat(inline-edit): pass in classname and update getDateValue
1 parent e62161a commit 1f90dde

File tree

3 files changed

+50
-6
lines changed

3 files changed

+50
-6
lines changed

src/features/list-view/styles/ListView.scss

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,23 @@
2424
cursor: pointer;
2525
}
2626

27-
.bdl-icon-sort-chevron.bdl-ListView-isSortAsc {
27+
.bdl-icon-sort-chevron {
2828
height: 12px;
2929
margin-left: 2px;
3030
margin-top: 3px;
31-
transform: rotate(180deg);
3231
width: 12px;
3332
}
33+
34+
.bdl-icon-sort-chevron.bdl-ListView-isSortAsc {
35+
transform: rotate(180deg);
36+
}
3437
}
3538

3639
.bdl-ListView-columnCell {
3740
border-top: 1px solid $off-white;
3841
color: $seventy-sixers;
3942
display: flex;
4043
justify-content: flex-start;
41-
padding-top: 16px;
4244

4345
.bdl-ListView-iconRename {
4446
border: none;
@@ -51,4 +53,14 @@
5153
.ReactVirtualized__Grid {
5254
outline: none;
5355
}
56+
57+
.ReactVirtualized__Grid__innerScrollContainer {
58+
/* Currently there is an issue where overflow is hidden for the Grid
59+
which results in dropdowns getting cut off at the bottom of each row
60+
61+
TODO: The correct solution would be to use Portal + Tether. This approach will be attempted during
62+
the Raise the Bar phase.
63+
*/
64+
overflow: visible !important;
65+
}
5466
}

src/features/query-bar/__tests__/ValueField-test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,32 @@ describe('features/query-bar/components/filter/ValueField', () => {
7272
expect(component.prop(valuePropNames[componentName])).toEqual(expectedValue);
7373
});
7474
});
75+
76+
describe('should not show an error for a', () => {
77+
test.each`
78+
valueType | componentName | should
79+
${'multiSelect'} | ${'MultiSelectField'} | ${'MultiSelectField of type multiSelect'}
80+
${'enum'} | ${'SingleSelectField'} | ${'SingleSelectField of type enum'}
81+
${'date'} | ${'DatePicker'} | ${'DatePicker of type date'}
82+
`('$should', ({ componentName, valueType }) => {
83+
const wrapper = getWrapper({ valueType, error: null, selectedValues: [] });
84+
const component = wrapper.find(componentName);
85+
expect(component.prop('error')).toBe(undefined);
86+
});
87+
});
88+
89+
describe('should show an error for a TextInput of ', () => {
90+
const error = <div />;
91+
test.each`
92+
valueType | should
93+
${'string'} | ${'type string'}
94+
${'float'} | ${'type float'}
95+
${'number'} | ${'type number'}
96+
`('$should', ({ valueType }) => {
97+
const wrapper = getWrapper({ valueType, error, selectedValues: [] });
98+
const component = wrapper.find('TextInput');
99+
expect(component.prop('error')).toBe(error);
100+
});
101+
});
75102
});
76103
});

src/features/query-bar/components/filter/ValueField.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @flow
22
import * as React from 'react';
33
import { FormattedMessage } from 'react-intl';
4+
import isNaN from 'lodash/isNaN';
45

56
import DatePicker from '../../../../components/date-picker';
67
import SingleSelectField from '../../../../components/select-field/SingleSelectField';
@@ -13,6 +14,7 @@ import type { ConditionValueType } from '../../flowTypes';
1314
import '../../styles/Condition.scss';
1415

1516
type Props = {
17+
error?: React.Node,
1618
onChange: (value: Array<ConditionValueType>) => void,
1719
selectedValues: Array<ConditionValueType>,
1820
valueOptions: Array<Object>,
@@ -25,8 +27,9 @@ const getDateValue = selectedValues => {
2527
}
2628

2729
const value = selectedValues[0];
28-
if (value instanceof Date) {
29-
return value;
30+
const date = new Date(value);
31+
if (!isNaN(date.valueOf())) {
32+
return date;
3033
}
3134

3235
throw new Error('Expected Date');
@@ -45,7 +48,7 @@ const getStringValue = selectedValues => {
4548
throw new Error('Expected string');
4649
};
4750

48-
const ValueField = ({ onChange, selectedValues, valueOptions, valueType }: Props) => {
51+
const ValueField = ({ error, onChange, selectedValues, valueOptions, valueType }: Props) => {
4952
const value = selectedValues.length > 0 ? selectedValues[0] : '';
5053
const onInputChange = e => {
5154
return e.target.value !== '' ? onChange([e.target.value]) : onChange([]);
@@ -58,6 +61,8 @@ const ValueField = ({ onChange, selectedValues, valueOptions, valueType }: Props
5861
return (
5962
<div className="filter-dropdown-text-field-container">
6063
<TextInput
64+
error={error}
65+
errorPosition="middle-left"
6166
hideLabel
6267
label="Text Input"
6368
name="text"

0 commit comments

Comments
 (0)