Skip to content

Commit b9a9274

Browse files
committed
Revert "Remove OSM related UI components"
This reverts commit c16df75.
1 parent 9204831 commit b9a9274

4 files changed

Lines changed: 468 additions & 0 deletions

File tree

modules/ui/inspector.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { select as d3_select } from 'd3-selection';
33

44
import { uiEntityEditor } from './entity_editor';
55
import { uiPresetList } from './preset_list';
6+
import { uiViewOnOSM } from './view_on_osm';
67

78

89
export function uiInspector(context) {
@@ -94,6 +95,18 @@ export function uiInspector(context) {
9495
.call(entityEditor);
9596
}
9697

98+
var footer = selection.selectAll('.footer')
99+
.data([0]);
100+
101+
footer = footer.enter()
102+
.append('div')
103+
.attr('class', 'footer')
104+
.merge(footer);
105+
106+
footer
107+
.call(uiViewOnOSM(context)
108+
.what(context.hasEntity(_entityIDs.length === 1 && _entityIDs[0]))
109+
);
97110
}
98111

99112
inspector.showList = function(presets) {

modules/ui/panels/history.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { t, localizer } from '../../core/localizer';
2+
import { svgIcon } from '../../svg';
23

34

45
export function uiPanelHistory(context) {
@@ -28,6 +29,27 @@ export function uiPanelHistory(context) {
2829
.append('span')
2930
.attr('class', 'user-name')
3031
.text(userName);
32+
33+
var links = selection
34+
.append('div')
35+
.attr('class', 'links');
36+
37+
if (osm) {
38+
links
39+
.append('a')
40+
.attr('class', 'user-osm-link')
41+
.attr('href', osm.userURL(userName))
42+
.attr('target', '_blank')
43+
.call(t.append('info_panels.history.profile_link'));
44+
}
45+
46+
links
47+
.append('a')
48+
.attr('class', 'user-hdyc-link')
49+
.attr('href', 'https://hdyc.neis-one.org/?' + userName)
50+
.attr('target', '_blank')
51+
.attr('tabindex', -1)
52+
.text('HDYC');
3153
}
3254

3355

@@ -144,6 +166,16 @@ export function uiPanelHistory(context) {
144166
.call(displayUser, note.comments[0].user);
145167
}
146168

169+
if (osm) {
170+
selection
171+
.append('a')
172+
.attr('class', 'view-history-on-osm')
173+
.attr('target', '_blank')
174+
.attr('href', osm.noteURL(note))
175+
.call(svgIcon('#iD-icon-out-link', 'inline'))
176+
.append('span')
177+
.call(t.append('info_panels.history.note_link_text'));
178+
}
147179
}
148180

149181

@@ -155,6 +187,26 @@ export function uiPanelHistory(context) {
155187
return;
156188
}
157189

190+
var links = selection
191+
.append('div')
192+
.attr('class', 'links');
193+
194+
if (osm) {
195+
links
196+
.append('a')
197+
.attr('class', 'view-history-on-osm')
198+
.attr('href', osm.historyURL(entity))
199+
.attr('target', '_blank')
200+
.call(t.append('info_panels.history.history_link'));
201+
}
202+
links
203+
.append('a')
204+
.attr('class', 'pewu-history-viewer-link')
205+
.attr('href', 'https://pewu.github.io/osm-history/#/' + entity.type + '/' + entity.osmId())
206+
.attr('target', '_blank')
207+
.attr('tabindex', -1)
208+
.text('PeWu');
209+
158210
var list = selection
159211
.append('ul');
160212

modules/ui/sections/data_layers.js

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export function uiSectionDataLayers(context) {
3333
.append('div')
3434
.attr('class', 'data-layer-container')
3535
.merge(container)
36+
.call(drawOsmItems)
37+
.call(drawQAItems)
3638
.call(drawCustomDataItems)
3739
.call(drawVectorItems) // Beta - Detroit mapping challenge
3840
.call(drawPanelItems);
@@ -65,6 +67,117 @@ export function uiSectionDataLayers(context) {
6567
setLayer(which, !showsLayer(which));
6668
}
6769

70+
function drawOsmItems(selection) {
71+
var osmKeys = ['osm', 'notes'];
72+
var osmLayers = layers.all().filter(function(obj) { return osmKeys.indexOf(obj.id) !== -1; });
73+
74+
var ul = selection
75+
.selectAll('.layer-list-osm')
76+
.data([0]);
77+
78+
ul = ul.enter()
79+
.append('ul')
80+
.attr('class', 'layer-list layer-list-osm')
81+
.merge(ul);
82+
83+
var li = ul.selectAll('.list-item')
84+
.data(osmLayers);
85+
86+
li.exit()
87+
.remove();
88+
89+
var liEnter = li.enter()
90+
.append('li')
91+
.attr('class', function(d) { return 'list-item list-item-' + d.id; });
92+
93+
var labelEnter = liEnter
94+
.append('label')
95+
.each(function(d) {
96+
if (d.id === 'osm') {
97+
d3_select(this)
98+
.call(uiTooltip()
99+
.title(() => t.append('map_data.layers.' + d.id + '.tooltip'))
100+
.keys([uiCmd('⌥' + t('area_fill.wireframe.key'))])
101+
.placement('bottom')
102+
);
103+
} else {
104+
d3_select(this)
105+
.call(uiTooltip()
106+
.title(() => t.append('map_data.layers.' + d.id + '.tooltip'))
107+
.placement('bottom')
108+
);
109+
}
110+
});
111+
112+
labelEnter
113+
.append('input')
114+
.attr('type', 'checkbox')
115+
.on('change', function(d3_event, d) { toggleLayer(d.id); });
116+
117+
labelEnter
118+
.append('span')
119+
.html(function(d) { return t.html('map_data.layers.' + d.id + '.title'); });
120+
121+
122+
// Update
123+
li
124+
.merge(liEnter)
125+
.classed('active', function (d) { return d.layer.enabled(); })
126+
.selectAll('input')
127+
.property('checked', function (d) { return d.layer.enabled(); });
128+
}
129+
130+
function drawQAItems(selection) {
131+
var qaKeys = ['keepRight', 'improveOSM', 'osmose'];
132+
var qaLayers = layers.all().filter(function(obj) { return qaKeys.indexOf(obj.id) !== -1; });
133+
134+
var ul = selection
135+
.selectAll('.layer-list-qa')
136+
.data([0]);
137+
138+
ul = ul.enter()
139+
.append('ul')
140+
.attr('class', 'layer-list layer-list-qa')
141+
.merge(ul);
142+
143+
var li = ul.selectAll('.list-item')
144+
.data(qaLayers);
145+
146+
li.exit()
147+
.remove();
148+
149+
var liEnter = li.enter()
150+
.append('li')
151+
.attr('class', function(d) { return 'list-item list-item-' + d.id; });
152+
153+
var labelEnter = liEnter
154+
.append('label')
155+
.each(function(d) {
156+
d3_select(this)
157+
.call(uiTooltip()
158+
.title(() => t.append('map_data.layers.' + d.id + '.tooltip'))
159+
.placement('bottom')
160+
);
161+
});
162+
163+
labelEnter
164+
.append('input')
165+
.attr('type', 'checkbox')
166+
.on('change', function(d3_event, d) { toggleLayer(d.id); });
167+
168+
labelEnter
169+
.append('span')
170+
.each(function(d) { t.append('map_data.layers.' + d.id + '.title')(d3_select(this)); });
171+
172+
173+
// Update
174+
li
175+
.merge(liEnter)
176+
.classed('active', function (d) { return d.layer.enabled(); })
177+
.selectAll('input')
178+
.property('checked', function (d) { return d.layer.enabled(); });
179+
}
180+
68181
// Beta feature - sample vector layers to support Detroit Mapping Challenge
69182
// https://github.com/osmus/detroit-mapping-challenge
70183
function drawVectorItems(selection) {

0 commit comments

Comments
 (0)