-
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
Allow checkbox fields to support custom strings #2235
Merged
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d973580
Add to .gitignore: .DS_Store, node_modules
bhousel e3e2ea6
Checkmark fields now support custom string options
bhousel 8380981
Pretend oneway field is a oneway_yes field if `junction=roundabout` i…
bhousel 191c700
Handle empty selectedIDs..
bhousel 5fdbd6f
Instead of using context.selectedIDs(), define a check.entity setter …
bhousel 126f334
eliminate warning: 'context' is defined but never used
bhousel 1c3d0da
Replace all matches, not just the first one..
bhousel 40810da
Correctly trim whitespace in semicolon-separated multivalues #2236
bhousel 10bd86c
Check single source for implied onewayness #2220
bhousel 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.DS_Store | ||
node_modules | ||
dist/iD.js | ||
dist/iD.min.js | ||
dist/iD.css | ||
|
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
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
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 |
---|---|---|
@@ -1,5 +1,12 @@ | ||
{ | ||
"key": "oneway", | ||
"type": "check", | ||
"label": "One Way" | ||
"label": "One Way", | ||
"strings": { | ||
"options": { | ||
"undefined": "Assumed to be No", | ||
"yes": "Yes", | ||
"no": "No" | ||
} | ||
} | ||
} |
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
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
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
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
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 |
---|---|---|
@@ -1,13 +1,34 @@ | ||
iD.ui.preset.check = | ||
iD.ui.preset.defaultcheck = function(field) { | ||
iD.ui.preset.defaultcheck = function(field, context) { | ||
var event = d3.dispatch('change'), | ||
values = field.type === 'check' ? | ||
[undefined, 'yes', 'no'] : | ||
[undefined, 'yes'], | ||
value, | ||
box, | ||
text, | ||
label; | ||
options = field.strings && field.strings.options, | ||
values = [], | ||
texts = [], | ||
value, box, text, label; | ||
|
||
if (options) { | ||
for (var k in options) { | ||
values.push(k === 'undefined' ? undefined : k); | ||
texts.push(field.t('check.' + k, { 'default': options[k] })); | ||
} | ||
} else { | ||
values = [undefined, 'yes']; | ||
texts = [t('inspector.unknown'), t('inspector.check.yes')]; | ||
if (field.type === 'check') { | ||
values.push('no'); | ||
texts.push(t('inspector.check.no')); | ||
} | ||
} | ||
|
||
// hack: pretend oneway field is a oneway_yes field if `junction=roundabout` is set. | ||
if (field.id === 'oneway') { | ||
var ids = context.selectedIDs(), | ||
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. Instead of using |
||
way = ids.length && context.entity(ids[0]); | ||
if (way && way.tags.junction === 'roundabout') { | ||
texts.shift(); | ||
texts.unshift(t('presets.fields.oneway_yes.check.undefined', { 'default': 'Assumed to be Yes' })); | ||
} | ||
} | ||
|
||
var check = function(selection) { | ||
selection.classed('checkselect', 'true'); | ||
|
@@ -24,7 +45,7 @@ iD.ui.preset.defaultcheck = function(field) { | |
.attr('id', 'preset-input-' + field.id); | ||
|
||
enter.append('span') | ||
.text(t('inspector.unknown')) | ||
.text(texts[0]) | ||
.attr('class', 'value'); | ||
|
||
box = label.select('input') | ||
|
@@ -42,8 +63,7 @@ iD.ui.preset.defaultcheck = function(field) { | |
value = tags[field.key]; | ||
box.property('indeterminate', field.type === 'check' && !value); | ||
box.property('checked', value === 'yes'); | ||
text.text(value ? t('inspector.check.' + value, {default: value}) : | ||
field.type === 'check' ? t('inspector.unknown') : t('inspector.check.no')); | ||
text.text(texts[values.indexOf(value)]); | ||
label.classed('set', !!value); | ||
}; | ||
|
||
|
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.
This is likely to be reached too early in initialization to use
field.t
ort
-- I think it happens before the user's locale preference is set, so it will always return the English translation.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.
Eh, never mind. Wasn't thinking straight.