Grab favorites, display them.

Show stuff nested in optional tags.
Fixes #582
This commit is contained in:
Tom MacWright
2013-01-31 14:59:59 -05:00
parent 095ed4b486
commit 5bd95f6e6a
9 changed files with 5328 additions and 770 deletions
+6
View File
@@ -1296,6 +1296,12 @@ a.success-action {
padding: 5px;
}
.preset-fav button.fav {
height: 30px;
margin: 5px;
padding: 0 10px;
}
.preset-input input {
width: 100%;
}
+1
View File
@@ -74,6 +74,7 @@
<script src='js/id/ui/key_reference.js'></script>
<script src='js/id/ui/preset.js'></script>
<script src='js/id/ui/presetsearch.js'></script>
<script src='js/id/ui/presetfavs.js'></script>
<script src='js/id/actions.js'></script>
<script src="js/id/actions/add_midpoint.js"></script>
+3 -3
View File
@@ -8,9 +8,9 @@ iD.presetData = function() {
return presets;
};
presets.search = function(str) {
var edits = _.sortBydata.map(function(d) {
return iD.util.editDistance(d.title, str);
presets.favs = function() {
return data.filter(function(d) {
return d.favorite;
});
};
+12 -1
View File
@@ -32,10 +32,21 @@ iD.ui.inspector = function() {
.preset(preset));
}));
var inspectorpresetfavs = inspectorwrap.append('div')
.attr('class', 'inspector-preset cf')
.call(iD.ui.presetfavs()
.presetData(presetData)
.on('choose', function(preset) {
inspectorpreset.call(iD.ui.preset()
.preset(preset));
inspectorpresetsearch
.select('input')
.property('value', preset.name);
}));
var inspectorpreset = inspectorwrap.append('div')
.attr('class', 'inspector-preset cf');
inspectorwrap.append('h4')
.text(t('edit_tags'));
+30
View File
@@ -0,0 +1,30 @@
iD.ui.presetfavs = function() {
var event = d3.dispatch('choose'),
presetData;
function favs(selection) {
var favData = presetData.favs();
selection.append('div')
.attr('class', 'preset-fav')
.selectAll('button.fav')
.data(favData)
.enter()
.append('button')
.attr('class', 'fav')
.text(function(d) {
return d.name;
})
.on('click', function(d) {
event.choose(d);
});
}
favs.presetData = function(_) {
if (!arguments.length) return presetData;
presetData = _;
return favs;
};
return d3.rebind(favs, event, 'on');
};
-1
View File
@@ -18,7 +18,6 @@ iD.ui.presetsearch = function() {
}
function find(value) {
value = value;
return _.find(viable, function(v) {
return v.name == value;
});
+33 -30
View File
@@ -5,6 +5,7 @@ dirr = os.path.dirname(__file__)
def relative(x):
return os.path.join(dirr, x)
prefs = json.load(open(relative('prefs.json')))
dom1 = parse(relative('./josm.xml'))
items = dom1.getElementsByTagName('item')
@@ -17,6 +18,8 @@ def iswebsite(x):
return re.search('web', x, flags=re.IGNORECASE)
def istel(x):
return re.search('phone|tel|fax', x, flags=re.IGNORECASE)
def isfav(x):
return x in prefs
for item in items:
jitem = {
@@ -24,36 +27,36 @@ for item in items:
"type": item.getAttribute('type').split(','),
"main": []
}
for n in item.childNodes:
if n.nodeType != n.TEXT_NODE and n.nodeType != n.COMMENT_NODE:
if n.tagName == 'text':
txt = n.getAttribute('text')
type = 'text'
if isemail(txt):
type = 'email'
if iswebsite(txt):
type = 'url'
if istel(txt):
type = 'tel'
jitem['main'].append({
'type': type,
'key': n.getAttribute('key'),
'text': n.getAttribute('text')
})
if n.tagName == 'combo':
jitem['main'].append({
'type': 'select',
'key': n.getAttribute('key'),
'text': n.getAttribute('text'),
'values': n.getAttribute('values').split(',')
})
if n.tagName == 'check':
jitem['main'].append({
'type': 'check',
'key': n.getAttribute('key'),
'text': n.getAttribute('text'),
'default': (n.getAttribute('check') == 'true')
})
if isfav(jitem['name']):
jitem['favorite'] = True
for n in item.getElementsByTagName('text'):
txt = n.getAttribute('text')
type = 'text'
if isemail(txt):
type = 'email'
if iswebsite(txt):
type = 'url'
if istel(txt):
type = 'tel'
jitem['main'].append({
'type': type,
'key': n.getAttribute('key'),
'text': n.getAttribute('text')
})
for n in item.getElementsByTagName('combo'):
jitem['main'].append({
'type': 'select',
'key': n.getAttribute('key'),
'text': n.getAttribute('text'),
'values': n.getAttribute('values').split(',')
})
for n in item.getElementsByTagName('check'):
jitem['main'].append({
'type': 'check',
'key': n.getAttribute('key'),
'text': n.getAttribute('text'),
'default': (n.getAttribute('check') == 'true')
})
jsonOutput.append(jitem)
json.dump(jsonOutput, open(relative('presets_josm.json'), 'w'), indent=4)
+3
View File
@@ -0,0 +1,3 @@
[
"Cafe", "Restaurant", "Bus Station", "Hospital", "Bar", "Place of Worship"
]
+5240 -735
View File
File diff suppressed because it is too large Load Diff