Various improvements

This commit is contained in:
Edward Betts 2022-04-08 10:42:02 +01:00
parent d0ddd5204c
commit 3b9ea473e4

View file

@ -303,7 +303,7 @@
v-bind:key="isa.qid" v-bind:key="isa.qid"
v-for="isa in item_type_hits" v-for="isa in item_type_hits"
href="#" href="#"
@click.prevent="item_type_filters.includes(isa) || item_type_filters.push(isa)" @click.prevent="add_item_type_filter(isa)"
> >
{{ isa.label }} ({{ isa.qid }}) {{ isa.label }} ({{ isa.qid }})
</a> </a>
@ -458,12 +458,33 @@
<br>{{ wd_item.aliases.join("; ") }} <br>{{ wd_item.aliases.join("; ") }}
</span> </span>
<br><strong>item coordinates</strong>
<span v-for="marker in wd_item.markers">
<br><a target="_blank" :href="marker_osm_url(marker)" @click.stop>
{{ marker[0].toFixed(5) }},
{{ marker[1].toFixed(5) }}
<i class="fa fa-map-o"></i></a>
</span>
<br><strong>item type</strong> <br><strong>item type</strong>
<span v-bind:key="`isa-${wd_item.qid}-${isa.qid}`" v-for="isa in wd_item.isa_list"> <span v-bind:key="`isa-${wd_item.qid}-${isa.qid}`" v-for="isa in wd_item.isa_list">
<br><a :href="qid_url(isa.qid)" target="_blank">{{isa.label}}</a> ({{isa.qid}}) <br><a :href="qid_url(isa.qid)" target="_blank">{{isa.label}}</a> ({{isa.qid}})
<a :href="'/isa/' + isa.qid" target="_blank"><i class="fa fa-pencil-square-o"></i></a> <a :href="'/isa/' + isa.qid" target="_blank"><i class="fa fa-pencil-square-o"></i></a>
</span> </span>
<span v-if="wd_item.wikipedia.length > 0">
<br>
<strong>
Wikipedia
<i class="fa fa-external-link"></i>
</strong>
<br>
<span v-for="wp in wd_item.wikipedia">
<a :href="wikipedia_link(wp.lang, wp.title)" target="_blank">{{wp.lang}}</a>
&nbsp;
</span>
</span>
<span v-if="wd_item.street_address.length"> <span v-if="wd_item.street_address.length">
<br><strong>street address</strong> <br><strong>street address</strong>
<br>{{wd_item.street_address[0]}} <br>{{wd_item.street_address[0]}}
@ -524,6 +545,15 @@
</a> </a>
</span> </span>
<span v-if="wd_item.commons !== undefined">
<br><strong>Images on Commons</strong>
<br><a
:href="`https://commons.wikimedia.org/wiki/${wd_item.commons.replaceAll(' ', '_')}`"
target="_blank">
{{wd_item.commons}} <i class="fa fa-external-link"></i>
</a>
</span>
</div></div> </div></div>
</div> </div>
@ -548,7 +578,7 @@
<div v-if="current_item.nearby && !current_item.nearby.length"> <div v-if="current_item.nearby && !current_item.nearby.length">
<strong>No OSM matches found nearby</strong> <strong>No OSM matches found nearby</strong>
<div class="mt-2" v-if="current_item.tag_or_key_list.length"> <div class="mt-2" v-if="current_item.tag_or_key_list && current_item.tag_or_key_list.length">
<p>The OSM tags/keys used as the search criteria to find matching <p>The OSM tags/keys used as the search criteria to find matching
OSM objects are listed below, along with the Wikidata item that was OSM objects are listed below, along with the Wikidata item that was
the source.</p> the source.</p>
@ -766,6 +796,8 @@ export default {
startLon: Number, startLon: Number,
startZoom: Number, startZoom: Number,
startRadius: Number, startRadius: Number,
startItem: String,
startItemTypeFilter: Array,
username: String, username: String,
startMode: String, startMode: String,
q: String, q: String,
@ -994,6 +1026,22 @@ export default {
} }
}, },
methods: { methods: {
wikipedia_link(lang, title) {
var norm_title = title.replaceAll(" ", "_");
return `https://${lang}.wikipedia.org/wiki/${norm_title}`;
},
marker_osm_url(marker) {
var lat = marker[0].toFixed(5);
var lon = marker[1].toFixed(5);
return `https://www.openstreetmap.org/?mlat=${lat}&mlon=${lon}#map=18/${lat}/${lon}`
},
add_item_type_filter(isa) {
if (this.item_type_filters.includes(isa)) {
return;
}
this.item_type_filters.push(isa);
this.update_map_path();
},
api_call(endpoint, options) { api_call(endpoint, options) {
var url = `${this.api_base_url}/api/1/${endpoint}`; var url = `${this.api_base_url}/api/1/${endpoint}`;
return axios.get(url, options).catch(this.show_api_error_modal); return axios.get(url, options).catch(this.show_api_error_modal);
@ -1216,14 +1264,19 @@ export default {
this.isa_ticked = Object.keys(this.isa_labels); this.isa_ticked = Object.keys(this.isa_labels);
}, },
build_map_path() { build_map_path() {
if (this.current_item) {
return `/item/${this.current_qid}`;
}
var zoom = this.map.getZoom(); var zoom = this.map.getZoom();
var c = this.map.getCenter(); var c = this.map.getCenter();
var lat = c.lat.toFixed(5); var lat = c.lat.toFixed(5);
var lng = c.lng.toFixed(5); var lng = c.lng.toFixed(5);
var path = `/map/${zoom}/${lat}/${lng}`; var path = `/map/${zoom}/${lat}/${lng}`;
if (this.current_item) {
path += `?item=${this.current_qid}`; if (this.item_type_filters.length) {
path += "?isa=" + this.item_type_filters.map((t) => t.qid).join(";");
} }
return path; return path;
}, },
@ -1755,6 +1808,11 @@ export default {
this.zoom = this.startZoom; this.zoom = this.startZoom;
this.mode = this.startMode; this.mode = this.startMode;
this.changeset_comment = this.defaultComment || '+wikidata'; this.changeset_comment = this.defaultComment || '+wikidata';
console.log(this.startItemTypeFilter);
if (this.startItemTypeFilter.length) {
this.show_item_type_filter = true;
}
this.item_type_filters = this.startItemTypeFilter;
}, },
mounted() { mounted() {
@ -1764,7 +1822,6 @@ export default {
zoom: this.zoom || 16, zoom: this.zoom || 16,
}; };
var map = L.map("map", options); var map = L.map("map", options);
var osm_url = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"; var osm_url = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";
var tile_url = "https://tile-c.openstreetmap.fr/hot/{z}/{x}/{y}.png"; var tile_url = "https://tile-c.openstreetmap.fr/hot/{z}/{x}/{y}.png";
@ -1788,14 +1845,14 @@ export default {
this.search_text = this.q.trim(); this.search_text = this.q.trim();
this.run_search(); this.run_search();
} else { } else {
this.detail_qid = this.qid_from_url(); this.detail_qid = this.startItem;
if (this.detail_qid) { if (this.detail_qid) {
this.load_wikidata_items(bounds); this.load_wikidata_items(bounds);
} else { } else {
this.auto_load(bounds); this.auto_load(bounds);
}
this.update_map_path(); this.update_map_path();
} }
}
window.onpopstate = this.onpopstate; window.onpopstate = this.onpopstate;
}); });