Added phone number field (#286)

* Added phone number field

* Removed phone number validation since its a complicated problem to solve for now

* Added the missing case for phone
This commit is contained in:
Bharat 2021-04-27 16:04:58 +05:30 committed by GitHub
parent 0ed20e499f
commit 97b446f609
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 7 deletions

View file

@ -3,7 +3,7 @@
import React, {useState} from 'react'
import {IPropertyOption, IPropertyTemplate} from '../blocks/board'
import {IPropertyOption, IPropertyTemplate, PropertyType} from '../blocks/board'
import {Card} from '../blocks/card'
import mutator from '../mutator'
import {OctoUtils} from '../octoUtils'
@ -38,14 +38,16 @@ const PropertyValueElement = (props:Props): JSX.Element => {
return !isNaN(parseInt(val, 10))
case 'email': {
const emailRegexp = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
return emailRegexp.test(val.toLowerCase())
return emailRegexp.test(val)
}
case 'url': {
const urlRegexp = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www\.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w\-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[.!/\\\w]*))?)/
return urlRegexp.test(val.toLowerCase())
return urlRegexp.test(val)
}
case 'text':
return true
case 'phone':
return true
default:
return false
}
@ -97,11 +99,10 @@ const PropertyValueElement = (props:Props): JSX.Element => {
)
}
const editableFields: Array<PropertyType> = ['text', 'number', 'email', 'url', 'phone']
if (
propertyTemplate.type === 'text' ||
propertyTemplate.type === 'number' ||
propertyTemplate.type === 'email' ||
propertyTemplate.type === 'url'
editableFields.includes(propertyTemplate.type)
) {
if (!readOnly) {
return (

View file

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

View file

@ -103,6 +103,11 @@ const PropertyMenu = React.memo((props: Props) => {
name={typeDisplayName(intl, 'email')}
onClick={() => props.onTypeChanged('email')}
/>
<Menu.Text
id='phone'
name={typeDisplayName(intl, 'phone')}
onClick={() => props.onTypeChanged('phone')}
/>
<Menu.Text
id='url'
name={typeDisplayName(intl, 'url')}