Skip to content

Commit

Permalink
Re: OpenHistoricalMap/issues#670, repairs botched resolution of merge…
Browse files Browse the repository at this point in the history
… conflict.
  • Loading branch information
erictheise committed Feb 20, 2024
1 parent aa23e2b commit 697ec0e
Showing 1 changed file with 0 additions and 57 deletions.
57 changes: 0 additions & 57 deletions modules/validations/mismatched_dates.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,64 +121,7 @@ export function validationMismatchedDates() {
reference: showReferenceEDTF,
entityIds: [entity.id],
hash: key + entity.tags[key + ':edtf'],

dynamicFixes: function() {
let fixes = [];
let likelyDates = new Set();

let valueFromDate = date => {
date.precision = (parsed.lower || parsed.first || parsed).precision;
return date.edtf.split('T')[0];
};

if (Number.isFinite(parsed.min)) {
let min = edtf.default(parsed.min);
likelyDates.add(valueFromDate(min));
}

if (Number.isFinite(parsed.max)) {
let max = edtf.default(parsed.max);
likelyDates.add(valueFromDate(max));
}

let sortedDates = [...likelyDates];
sortedDates.sort();
fixes.push(...sortedDates.map(value => {
let normalized = utilNormalizeDateString(value);
let localeDateString = normalized.date.toLocaleDateString(localizer.localeCodes(), normalized.localeOptions);
return new validationIssueFix({
title: t.append('issues.fix.reformat_date.title', { date: localeDateString }),
onClick: function(context) {
context.perform(function(graph) {
var entityInGraph = graph.hasEntity(entity.id);
if (!entityInGraph) return graph;
var newTags = Object.assign({}, entityInGraph.tags);
newTags[key] = normalized.value;
return actionChangeTags(entityInGraph.id, newTags)(graph);
}, t('issues.fix.reformat_date.annotation'));
}
});
}));

fixes.push(new validationIssueFix({
icon: 'iD-operation-delete',
title: t.append('issues.fix.remove_tag.title'),
onClick: function(context) {
context.perform(function(graph) {
var entityInGraph = graph.hasEntity(entity.id);
if (!entityInGraph) return graph;
var newTags = Object.assign({}, entityInGraph.tags);
delete newTags[key];
return actionChangeTags(entityInGraph.id, newTags)(graph);
}, t('issues.fix.remove_tag.annotation'));
}
}));

return fixes;
}

dynamicFixes: () => getDynamicFixes(key, parsed),

}));
}
validateEDTF('start_date', 'start');
Expand Down

0 comments on commit 697ec0e

Please sign in to comment.