1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-01-08 15:06:08 +02:00

Introduce checkbox property type (#439)

* introduce checkbox property type

* treat false as empty string

* Fixed lint issues

* Fixed webapp tests:

Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com>
This commit is contained in:
Michael Kochell 2021-06-02 06:23:52 -04:00 committed by GitHub
parent 225c4bda5b
commit 1d87331391
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 1 deletions

View File

@ -143,6 +143,9 @@ watch-server-single-user:
webapp:
cd webapp; npm run pack
watch-webapp:
cd webapp; npm run watchdev
mac-app: server-mac webapp
rm -rf mac/temp
rm -rf mac/dist

View File

@ -15,6 +15,7 @@ import ValueSelector from '../widgets/valueSelector'
import Label from '../widgets/label'
import EditableDayPicker from '../widgets/editableDayPicker'
import Switch from '../widgets/switch'
import URLProperty from './properties/link/link'
@ -128,6 +129,19 @@ const PropertyValueElement = (props:Props): JSX.Element => {
)
}
if (propertyTemplate.type === 'checkbox') {
return (
<Switch
isOn={Boolean(propertyValue)}
onChanged={(newBool) => {
const newValue = newBool ? 'true' : ''
mutator.changePropertyValue(card, propertyTemplate.id, newValue)
}}
readOnly={readOnly}
/>
)
}
const editableFields: Array<PropertyType> = ['text', 'number', 'email', 'url', 'phone']
if (

View File

@ -172,6 +172,21 @@ exports[`widgets/PropertyMenu should match snapshot 1`] = `
class="noicon"
/>
</div>
<div
class="MenuOption TextOption menu-option"
>
<div
class="noicon"
/>
<div
class="menu-name"
>
Checkbox
</div>
<div
class="noicon"
/>
</div>
<div
class="MenuOption TextOption menu-option"
>

View File

@ -124,6 +124,11 @@ const PropertyMenu = React.memo((props: Props) => {
name={typeDisplayName(intl, 'date')}
onClick={() => props.onTypeChanged('date')}
/>
<Menu.Text
id='checkbox'
name={typeDisplayName(intl, 'checkbox')}
onClick={() => props.onTypeChanged('checkbox')}
/>
<Menu.Text
id='createdTime'
name={typeDisplayName(intl, 'createdTime')}

View File

@ -9,6 +9,7 @@
padding: 2px;
background-color: rgba(var(--body-color), 0.24);
transition: background 200ms ease 0s, box-shadow 200ms ease 0s;
cursor: pointer;
&.on {
background-color: rgb(var(--button-bg));

View File

@ -7,6 +7,7 @@ import './switch.scss'
type Props = {
onChanged: (isOn: boolean) => void
isOn: boolean
readOnly?: boolean
}
// Switch is an on-off style switch / checkbox
@ -16,7 +17,9 @@ function Switch(props: Props): JSX.Element {
<div
className={className}
onClick={() => {
props.onChanged(!props.isOn)
if (!props.readOnly) {
props.onChanged(!props.isOn)
}
}}
>
<div className='octo-switch-inner'/>

View File

@ -16,5 +16,9 @@ const config = merge.merge(commonConfig, {
module.exports = [
merge.merge(config, {
devtool: 'source-map',
output: {
devtoolNamespace: 'focalboard',
},
}),
];