mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-31 20:21:36 +02:00
Merge pull request #8077 from mapillary/photo-filtering-url
Persist photo layer filters in the URL
This commit is contained in:
@@ -50,17 +50,35 @@ export function rendererPhotos(context) {
|
||||
return val === _dateFilters[0] ? _fromDate : _toDate;
|
||||
};
|
||||
|
||||
photos.setDateFilter = function(type, val) {
|
||||
photos.setDateFilter = function(type, val, updateUrl) {
|
||||
if (type === _dateFilters[0]) _fromDate = val;
|
||||
if (type === _dateFilters[1]) _toDate = val;
|
||||
dispatch.call('change', this);
|
||||
if (updateUrl) {
|
||||
setUrlFilterValue(type, val);
|
||||
}
|
||||
};
|
||||
|
||||
photos.setUsernameFilter = function(val) {
|
||||
photos.setUsernameFilter = function(val, updateUrl) {
|
||||
_username = val;
|
||||
dispatch.call('change', this);
|
||||
if (updateUrl) {
|
||||
setUrlFilterValue('username', val);
|
||||
}
|
||||
};
|
||||
|
||||
function setUrlFilterValue(type, val) {
|
||||
if (!window.mocha) {
|
||||
var hash = utilStringQs(window.location.hash);
|
||||
if (val) {
|
||||
hash[type] = val;
|
||||
} else {
|
||||
delete hash[type];
|
||||
}
|
||||
window.location.replace('#' + utilQsString(hash, true));
|
||||
}
|
||||
}
|
||||
|
||||
function showsLayer(id) {
|
||||
var layer = context.layers().layer(id);
|
||||
return layer && layer.supported() && layer.enabled();
|
||||
@@ -127,6 +145,15 @@ export function rendererPhotos(context) {
|
||||
if (layer && !layer.enabled()) layer.enabled(true);
|
||||
});
|
||||
}
|
||||
if (hash.fromDate) {
|
||||
this.setDateFilter('fromDate', hash.fromDate, false);
|
||||
}
|
||||
if (hash.toDate) {
|
||||
this.setDateFilter('toDate', hash.toDate, false);
|
||||
}
|
||||
if (hash.username) {
|
||||
this.setUsernameFilter(hash.username, false);
|
||||
}
|
||||
if (hash.photo) {
|
||||
// support opening a photo via a URL parameter, e.g. `photo=mapillary-fztgSDtLpa08ohPZFZjeRQ`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user