mirror of
https://github.com/mattermost/focalboard.git
synced 2025-01-11 18:13:52 +02:00
Add clear button to value selectors (#823)
* Add clear button to value selectors * Only show the clear button on not-readonly cases * Updating the test snapshots Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
This commit is contained in:
parent
3c41630af5
commit
e481ba7170
@ -30,9 +30,21 @@ exports[`components/cardDetail/CardDetailProperties should match snapshot 1`] =
|
||||
>
|
||||
<span
|
||||
class="Label propColorDefault "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
>
|
||||
Jean-Luc Picard
|
||||
</span>
|
||||
<div
|
||||
class="Button IconButton margin-left delete-value"
|
||||
title="Clear"
|
||||
>
|
||||
<i
|
||||
class="CompassIcon icon-close CloseIcon"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
|
@ -18,6 +18,8 @@ import Label from '../widgets/label'
|
||||
|
||||
import EditableDayPicker from '../widgets/editableDayPicker'
|
||||
import Switch from '../widgets/switch'
|
||||
import IconButton from '../widgets/buttons/iconButton'
|
||||
import CloseIcon from '../widgets/icons/close'
|
||||
|
||||
import UserProperty from './properties/user/user'
|
||||
import MultiSelectProperty from './properties/multiSelect'
|
||||
@ -74,6 +76,8 @@ const PropertyValueElement = (props:Props): JSX.Element => {
|
||||
}
|
||||
}, [])
|
||||
|
||||
const onDeleteValue = useCallback(() => mutator.changePropertyValue(card, propertyTemplate.id, ''), [card, propertyTemplate.id])
|
||||
|
||||
const validateProp = (propType: string, val: string): boolean => {
|
||||
if (val === '') {
|
||||
return true
|
||||
@ -139,7 +143,17 @@ const PropertyValueElement = (props:Props): JSX.Element => {
|
||||
tabIndex={0}
|
||||
onClick={() => setOpen(true)}
|
||||
>
|
||||
<Label color={displayValue ? propertyColorCssClassName : 'empty'}>{finalDisplayValue}</Label>
|
||||
<Label color={displayValue ? propertyColorCssClassName : 'empty'}>
|
||||
<span className='Label-text'>{finalDisplayValue}</span>
|
||||
{displayValue && !props.readOnly &&
|
||||
<IconButton
|
||||
onClick={onDeleteValue}
|
||||
onMouseDown={(e: React.MouseEvent) => e.stopPropagation()}
|
||||
icon={<CloseIcon/>}
|
||||
title='Clear'
|
||||
className='margin-left delete-value'
|
||||
/>}
|
||||
</Label>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -168,6 +182,7 @@ const PropertyValueElement = (props:Props): JSX.Element => {
|
||||
mutator.changePropertyValue(card, propertyTemplate.id, option.id)
|
||||
}
|
||||
}
|
||||
onDeleteValue={onDeleteValue}
|
||||
/>
|
||||
)
|
||||
} else if (propertyTemplate.type === 'person') {
|
||||
|
@ -173,9 +173,21 @@ exports[`components/table/Table extended should match snapshot with CreatedBy 1`
|
||||
>
|
||||
<span
|
||||
class="Label propColorBrown "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
>
|
||||
value 1
|
||||
</span>
|
||||
<div
|
||||
class="Button IconButton margin-left delete-value"
|
||||
title="Clear"
|
||||
>
|
||||
<i
|
||||
class="CompassIcon icon-close CloseIcon"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -188,7 +200,11 @@ exports[`components/table/Table extended should match snapshot with CreatedBy 1`
|
||||
>
|
||||
<span
|
||||
class="Label empty "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -251,9 +267,21 @@ exports[`components/table/Table extended should match snapshot with CreatedBy 1`
|
||||
>
|
||||
<span
|
||||
class="Label propColorBrown "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
>
|
||||
value 1
|
||||
</span>
|
||||
<div
|
||||
class="Button IconButton margin-left delete-value"
|
||||
title="Clear"
|
||||
>
|
||||
<i
|
||||
class="CompassIcon icon-close CloseIcon"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -266,7 +294,11 @@ exports[`components/table/Table extended should match snapshot with CreatedBy 1`
|
||||
>
|
||||
<span
|
||||
class="Label empty "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -467,9 +499,21 @@ exports[`components/table/Table extended should match snapshot with CreatedBy 2`
|
||||
>
|
||||
<span
|
||||
class="Label propColorBrown "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
>
|
||||
value 1
|
||||
</span>
|
||||
<div
|
||||
class="Button IconButton margin-left delete-value"
|
||||
title="Clear"
|
||||
>
|
||||
<i
|
||||
class="CompassIcon icon-close CloseIcon"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -482,7 +526,11 @@ exports[`components/table/Table extended should match snapshot with CreatedBy 2`
|
||||
>
|
||||
<span
|
||||
class="Label empty "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -545,9 +593,21 @@ exports[`components/table/Table extended should match snapshot with CreatedBy 2`
|
||||
>
|
||||
<span
|
||||
class="Label propColorBrown "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
>
|
||||
value 1
|
||||
</span>
|
||||
<div
|
||||
class="Button IconButton margin-left delete-value"
|
||||
title="Clear"
|
||||
>
|
||||
<i
|
||||
class="CompassIcon icon-close CloseIcon"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -560,7 +620,11 @@ exports[`components/table/Table extended should match snapshot with CreatedBy 2`
|
||||
>
|
||||
<span
|
||||
class="Label empty "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -761,9 +825,21 @@ exports[`components/table/Table extended should match snapshot with UpdatedAt 1`
|
||||
>
|
||||
<span
|
||||
class="Label propColorBrown "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
>
|
||||
value 1
|
||||
</span>
|
||||
<div
|
||||
class="Button IconButton margin-left delete-value"
|
||||
title="Clear"
|
||||
>
|
||||
<i
|
||||
class="CompassIcon icon-close CloseIcon"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -776,7 +852,11 @@ exports[`components/table/Table extended should match snapshot with UpdatedAt 1`
|
||||
>
|
||||
<span
|
||||
class="Label empty "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -839,9 +919,21 @@ exports[`components/table/Table extended should match snapshot with UpdatedAt 1`
|
||||
>
|
||||
<span
|
||||
class="Label propColorBrown "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
>
|
||||
value 1
|
||||
</span>
|
||||
<div
|
||||
class="Button IconButton margin-left delete-value"
|
||||
title="Clear"
|
||||
>
|
||||
<i
|
||||
class="CompassIcon icon-close CloseIcon"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -854,7 +946,11 @@ exports[`components/table/Table extended should match snapshot with UpdatedAt 1`
|
||||
>
|
||||
<span
|
||||
class="Label empty "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -1055,9 +1151,21 @@ exports[`components/table/Table extended should match snapshot with UpdatedBy 1`
|
||||
>
|
||||
<span
|
||||
class="Label propColorBrown "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
>
|
||||
value 1
|
||||
</span>
|
||||
<div
|
||||
class="Button IconButton margin-left delete-value"
|
||||
title="Clear"
|
||||
>
|
||||
<i
|
||||
class="CompassIcon icon-close CloseIcon"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -1070,7 +1178,11 @@ exports[`components/table/Table extended should match snapshot with UpdatedBy 1`
|
||||
>
|
||||
<span
|
||||
class="Label empty "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -1133,9 +1245,21 @@ exports[`components/table/Table extended should match snapshot with UpdatedBy 1`
|
||||
>
|
||||
<span
|
||||
class="Label propColorBrown "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
>
|
||||
value 1
|
||||
</span>
|
||||
<div
|
||||
class="Button IconButton margin-left delete-value"
|
||||
title="Clear"
|
||||
>
|
||||
<i
|
||||
class="CompassIcon icon-close CloseIcon"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -1148,7 +1272,11 @@ exports[`components/table/Table extended should match snapshot with UpdatedBy 1`
|
||||
>
|
||||
<span
|
||||
class="Label empty "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -1327,9 +1455,21 @@ exports[`components/table/Table should match snapshot 1`] = `
|
||||
>
|
||||
<span
|
||||
class="Label propColorBrown "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
>
|
||||
value 1
|
||||
</span>
|
||||
<div
|
||||
class="Button IconButton margin-left delete-value"
|
||||
title="Clear"
|
||||
>
|
||||
<i
|
||||
class="CompassIcon icon-close CloseIcon"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -1342,7 +1482,11 @@ exports[`components/table/Table should match snapshot 1`] = `
|
||||
>
|
||||
<span
|
||||
class="Label empty "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -1671,9 +1815,13 @@ exports[`components/table/Table should match snapshot, read-only 1`] = `
|
||||
>
|
||||
<span
|
||||
class="Label propColorBrown "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
>
|
||||
value 1
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -1686,7 +1834,11 @@ exports[`components/table/Table should match snapshot, read-only 1`] = `
|
||||
>
|
||||
<span
|
||||
class="Label empty "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -141,9 +141,21 @@ exports[`components/table/TableRow should match snapshot, display properties 1`]
|
||||
>
|
||||
<span
|
||||
class="Label propColorBrown "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
>
|
||||
value 1
|
||||
</span>
|
||||
<div
|
||||
class="Button IconButton margin-left delete-value"
|
||||
title="Clear"
|
||||
>
|
||||
<i
|
||||
class="CompassIcon icon-close CloseIcon"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -156,7 +168,11 @@ exports[`components/table/TableRow should match snapshot, display properties 1`]
|
||||
>
|
||||
<span
|
||||
class="Label empty "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -305,9 +321,21 @@ exports[`components/table/TableRow should match snapshot, resizing column 1`] =
|
||||
>
|
||||
<span
|
||||
class="Label propColorBrown "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
>
|
||||
value 1
|
||||
</span>
|
||||
<div
|
||||
class="Button IconButton margin-left delete-value"
|
||||
title="Clear"
|
||||
>
|
||||
<i
|
||||
class="CompassIcon icon-close CloseIcon"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@ -320,7 +348,11 @@ exports[`components/table/TableRow should match snapshot, resizing column 1`] =
|
||||
>
|
||||
<span
|
||||
class="Label empty "
|
||||
>
|
||||
<span
|
||||
class="Label-text"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -164,6 +164,14 @@ html {
|
||||
&.empty {
|
||||
color: rgba(var(--body-color), 0.4);
|
||||
}
|
||||
.IconButton.delete-value {
|
||||
width: 16px;
|
||||
min-width: 16px;
|
||||
height: 16px;
|
||||
i {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-- Editable --*/
|
||||
|
@ -19,6 +19,15 @@
|
||||
overflow: hidden;
|
||||
border-radius: var(--default-rad);
|
||||
max-width: 100%;
|
||||
|
||||
.IconButton.delete-value {
|
||||
width: 16px;
|
||||
min-width: 16px;
|
||||
height: 16px;
|
||||
i {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.Label-no-padding {
|
||||
|
@ -57,8 +57,8 @@ const ValueSelectorLabel = React.memo((props: LabelProps): JSX.Element => {
|
||||
onClick={() => onDeleteValue(option)}
|
||||
onMouseDown={(e) => e.stopPropagation()}
|
||||
icon={<CloseIcon/>}
|
||||
title='Close'
|
||||
className='margin-left'
|
||||
title='Clear'
|
||||
className='margin-left delete-value'
|
||||
/>
|
||||
}
|
||||
</Label>
|
||||
|
Loading…
Reference in New Issue
Block a user