mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 13:38:26 +02:00
added photo age filter
This commit is contained in:
@@ -886,6 +886,13 @@ en:
|
||||
username_filter:
|
||||
title: "Username"
|
||||
tooltip: "Show only photos by this user"
|
||||
max_age_filter:
|
||||
year: "Last year"
|
||||
month: "Last month"
|
||||
week: "Last week"
|
||||
all: "Show all"
|
||||
title: "Photo age"
|
||||
tooltip: "Select maximum photo age"
|
||||
feature:
|
||||
points:
|
||||
description: Points
|
||||
|
||||
@@ -13,6 +13,7 @@ export function rendererPhotos(context) {
|
||||
var _dateFilters = ['fromDate', 'toDate'];
|
||||
var _fromDate;
|
||||
var _toDate;
|
||||
var _maxPhotoAge;
|
||||
var _usernames;
|
||||
|
||||
function photos() {}
|
||||
@@ -46,6 +47,10 @@ export function rendererPhotos(context) {
|
||||
return _dateFilters;
|
||||
};
|
||||
|
||||
photos.maxPhotoAge = function() {
|
||||
return _maxPhotoAge;
|
||||
};
|
||||
|
||||
photos.dateFilterValue = function(val) {
|
||||
return val === _dateFilters[0] ? _fromDate : _toDate;
|
||||
};
|
||||
@@ -80,6 +85,22 @@ export function rendererPhotos(context) {
|
||||
}
|
||||
};
|
||||
|
||||
photos.setMaxPhotoAge = function(maxPhotoAge){
|
||||
if(maxPhotoAge != -1){
|
||||
var fromDate = new Date();
|
||||
fromDate.setDate(fromDate.getDate() - maxPhotoAge);
|
||||
var dd = String(fromDate.getDate()).padStart(2, '0');
|
||||
var mm = String(fromDate.getMonth() + 1).padStart(2, '0');
|
||||
var yyyy = fromDate.getFullYear();
|
||||
|
||||
fromDate = mm + '/' + dd + '/' + yyyy;
|
||||
photos.setDateFilter('fromDate', fromDate)
|
||||
_maxPhotoAge = maxPhotoAge;
|
||||
}
|
||||
else
|
||||
photos.setDateFilter('fromDate', null)
|
||||
}
|
||||
|
||||
photos.setUsernameFilter = function(val, updateUrl) {
|
||||
if (val && typeof val === 'string') val = val.replace(/;/g, ',').split(',');
|
||||
if (val) {
|
||||
@@ -119,9 +140,13 @@ export function rendererPhotos(context) {
|
||||
}
|
||||
|
||||
photos.shouldFilterByDate = function() {
|
||||
return showsLayer('mapillary') || showsLayer('kartaview') || showsLayer('streetside') || showsLayer('vegbilder') || showsLayer('panoramax');
|
||||
return showsLayer('mapillary') || showsLayer('kartaview') || showsLayer('streetside') || showsLayer('vegbilder');
|
||||
};
|
||||
|
||||
photos.shouldFilterByMaxAge = function(){
|
||||
return showsLayer('panoramax');
|
||||
}
|
||||
|
||||
photos.shouldFilterByPhotoType = function() {
|
||||
return showsLayer('mapillary') ||
|
||||
(showsLayer('streetside') && showsLayer('kartaview')) || showsLayer('vegbilder') || showsLayer('panoramax');
|
||||
|
||||
@@ -30,6 +30,7 @@ export function uiSectionPhotoOverlays(context) {
|
||||
.merge(container)
|
||||
.call(drawPhotoItems)
|
||||
.call(drawPhotoTypeItems)
|
||||
.call(drawMaxAgeFilter)
|
||||
.call(drawDateFilter)
|
||||
.call(drawUsernameFilter)
|
||||
.call(drawLocalPhotos);
|
||||
@@ -257,6 +258,86 @@ export function uiSectionPhotoOverlays(context) {
|
||||
.classed('active', filterEnabled);
|
||||
}
|
||||
|
||||
function drawMaxAgeFilter(selection){
|
||||
function filterEnabled(d) {
|
||||
return context.photos().maxPhotoAge(d);
|
||||
}
|
||||
|
||||
var ul = selection
|
||||
.selectAll('.layer-list-date-age')
|
||||
.data([0]);
|
||||
|
||||
ul.exit()
|
||||
.remove();
|
||||
|
||||
ul = ul.enter()
|
||||
.append('ul')
|
||||
.attr('class', 'layer-list layer-list-date-age')
|
||||
.merge(ul);
|
||||
|
||||
var li = ul.selectAll('.list-item-date-age')
|
||||
.data(context.photos().shouldFilterByMaxAge() ? ['max-age'] : []);
|
||||
|
||||
li.exit()
|
||||
.remove();
|
||||
|
||||
var liEnter = li.enter()
|
||||
.append('li')
|
||||
.attr('class', 'list-item-date-age');
|
||||
|
||||
var labelEnter = liEnter
|
||||
.append('label')
|
||||
.each(function() {
|
||||
d3_select(this)
|
||||
.call(uiTooltip()
|
||||
.title(() => t.append('photo_overlays.max_age_filter.tooltip'))
|
||||
.placement('top')
|
||||
);
|
||||
});
|
||||
|
||||
labelEnter
|
||||
.append('span')
|
||||
.call(t.append('photo_overlays.max_age_filter.title'));
|
||||
|
||||
labelEnter
|
||||
.append('select')
|
||||
.attr('type', 'text')
|
||||
.attr('class', 'list-option')
|
||||
.call(utilNoAuto)
|
||||
|
||||
var select = labelEnter.selectAll('.list-option');
|
||||
|
||||
select
|
||||
.append('option')
|
||||
.attr('value', -1)
|
||||
.call(t.append('photo_overlays.max_age_filter.all'));
|
||||
|
||||
select
|
||||
.append('option')
|
||||
.attr('value', 7)
|
||||
.call(t.append('photo_overlays.max_age_filter.week'));
|
||||
|
||||
select
|
||||
.append('option')
|
||||
.attr('value', 31)
|
||||
.call(t.append('photo_overlays.max_age_filter.month'));
|
||||
|
||||
select
|
||||
.append('option')
|
||||
.attr('value', 365)
|
||||
.call(t.append('photo_overlays.max_age_filter.year'));
|
||||
|
||||
select
|
||||
.on('change', function() {
|
||||
var value = d3_select(this).property('value');
|
||||
context.photos().setMaxPhotoAge(parseInt(value));
|
||||
});
|
||||
|
||||
li
|
||||
.merge(liEnter)
|
||||
.classed('active', filterEnabled);
|
||||
}
|
||||
|
||||
function drawUsernameFilter(selection) {
|
||||
function filterEnabled() {
|
||||
return context.photos().usernames();
|
||||
|
||||
Generated
+11
@@ -20,6 +20,7 @@
|
||||
"abortcontroller-polyfill": "^1.7.5",
|
||||
"aes-js": "^3.1.2",
|
||||
"alif-toolkit": "^1.2.9",
|
||||
"all": "^0.0.0",
|
||||
"core-js-bundle": "^3.37.0",
|
||||
"diacritics": "1.3.0",
|
||||
"exifr": "^7.1.3",
|
||||
@@ -1902,6 +1903,11 @@
|
||||
"version": "1.2.9",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/all": {
|
||||
"version": "0.0.0",
|
||||
"resolved": "https://registry.npmjs.org/all/-/all-0.0.0.tgz",
|
||||
"integrity": "sha512-0oKlfNVv2d+d7c1gwjGspzgbwot47PGQ4b3v1ccx4mR8l9P/Y6E6Dr/yE8lNT63EcAKEbHo6UG3odDpC/NQcKw=="
|
||||
},
|
||||
"node_modules/amdefine": {
|
||||
"version": "1.0.1",
|
||||
"dev": true,
|
||||
@@ -10191,6 +10197,11 @@
|
||||
"alif-toolkit": {
|
||||
"version": "1.2.9"
|
||||
},
|
||||
"all": {
|
||||
"version": "0.0.0",
|
||||
"resolved": "https://registry.npmjs.org/all/-/all-0.0.0.tgz",
|
||||
"integrity": "sha512-0oKlfNVv2d+d7c1gwjGspzgbwot47PGQ4b3v1ccx4mR8l9P/Y6E6Dr/yE8lNT63EcAKEbHo6UG3odDpC/NQcKw=="
|
||||
},
|
||||
"amdefine": {
|
||||
"version": "1.0.1",
|
||||
"dev": true
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
"abortcontroller-polyfill": "^1.7.5",
|
||||
"aes-js": "^3.1.2",
|
||||
"alif-toolkit": "^1.2.9",
|
||||
"all": "^0.0.0",
|
||||
"core-js-bundle": "^3.37.0",
|
||||
"diacritics": "1.3.0",
|
||||
"exifr": "^7.1.3",
|
||||
|
||||
Reference in New Issue
Block a user