-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
tel no. validation #10124
Open
SharanRP
wants to merge
9
commits into
openstreetmap:develop
Choose a base branch
from
SharanRP:develop3
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
tel no. validation #10124
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f0bd205
Loader fixed
SharanRP 6a40d86
Loader fixed
SharanRP b347f1b
Revert "Loader fixed"
SharanRP 7b5bf68
Added fractional zoom in url
SharanRP 50473fe
input type=tel fixed
SharanRP 2ed50ad
phone number validation added
SharanRP 34c4c1b
Update 80_app.css
SharanRP e5d1d37
Update validator.js
SharanRP e9c0db9
Update input.js
SharanRP File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,9 @@ export function uiFieldText(field, context) { | |
} | ||
|
||
|
||
|
||
|
||
|
||
function calcLocked() { | ||
// Protect certain fields that have a companion `*:wikidata` value | ||
var isLocked = (field.id === 'brand' || field.id === 'network' || field.id === 'operator' || field.id === 'flag') && | ||
|
@@ -348,7 +351,7 @@ export function uiFieldText(field, context) { | |
|
||
function updatePhonePlaceholder() { | ||
if (input.empty() || !Object.keys(_phoneFormats).length) return; | ||
|
||
change()(); | ||
var extent = combinedEntityExtent(); | ||
var countryCode = extent && countryCoder.iso1A2Code(extent.center()); | ||
var format = countryCode && _phoneFormats[countryCode.toLowerCase()]; | ||
|
@@ -404,16 +407,20 @@ export function uiFieldText(field, context) { | |
} | ||
} | ||
|
||
|
||
function change(onInput) { | ||
return function() { | ||
var t = {}; | ||
var val = utilGetSetValue(input); | ||
if (!onInput) val = context.cleanTagValue(val); | ||
|
||
// don't override multiple values with blank string | ||
if (field.type === 'tel') { | ||
val = val.replace(/^tel:\/\//, ''); // Remove 'tel://' prefix if present | ||
val = val.replace(/^tel:/, ''); // Remove 'tel:' prefix if present | ||
} | ||
|
||
if (!onInput) val = context.cleanTagValue(val); | ||
|
||
if (!val && getVals(_tags).size > 1) return; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably perform the |
||
var displayVal = val; | ||
if (field.type === 'number' && val) { | ||
var numbers = val.split(';'); | ||
|
@@ -431,11 +438,11 @@ export function uiFieldText(field, context) { | |
if (!onInput) utilGetSetValue(input, displayVal); | ||
t[field.key] = val || undefined; | ||
if (field.keys) { | ||
// for multi-key fields with: handle alternative tag keys gracefully | ||
// For multi-key fields: handle alternative tag keys gracefully | ||
// https://github.com/openstreetmap/id-tagging-schema/issues/905 | ||
dispatch.call('change', this, tags => { | ||
if (field.keys.some(key => tags[key])) { | ||
// use exiting key(s) | ||
// Use existing key(s) | ||
field.keys.filter(key => tags[key]).forEach(key => { | ||
tags[key] = val || undefined; | ||
}); | ||
|
@@ -451,7 +458,6 @@ export function uiFieldText(field, context) { | |
}; | ||
} | ||
|
||
|
||
i.entityIDs = function(val) { | ||
if (!arguments.length) return _entityIDs; | ||
_entityIDs = val; | ||
|
@@ -542,3 +548,4 @@ export function uiFieldText(field, context) { | |
|
||
return utilRebind(i, dispatch, 'on'); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these are regular expressions, you could combine these two steps by surrounding the slashes in
(\/\/)?
. (Technically, RFC 3966 doesn’t allow slashes after the colon, but as #9559 (comment) demonstrates, there’s probably enough confusion about that to go ahead and strip out those slashes too.)