Skip to content

Commit

Permalink
Show Telephone and Website fields by default on more POI presets (close
Browse files Browse the repository at this point in the history
  • Loading branch information
quincylvania committed Sep 21, 2020
1 parent 0226b6f commit f141d1a
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 40 deletions.
16 changes: 8 additions & 8 deletions data/presets/presets.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions data/presets/presets/amenity/cafe.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"outdoor_seating",
"internet_access",
"internet_access/fee",
"internet_access/ssid"
"internet_access/ssid",
"phone",
"website"
],
"moreFields": [
"air_conditioning",
Expand All @@ -26,12 +28,10 @@
"min_age",
"not/name",
"payment_multi",
"phone",
"ref/vatin",
"reservation",
"smoking",
"takeaway",
"website",
"wheelchair"
],
"geometry": [
Expand Down
6 changes: 3 additions & 3 deletions data/presets/presets/amenity/fast_food.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"building_area",
"opening_hours",
"opening_hours/covid19",
"drive_through"
"drive_through",
"phone",
"website"
],
"moreFields": [
"air_conditioning",
Expand All @@ -27,11 +29,9 @@
"opening_hours/covid19",
"outdoor_seating",
"payment_multi",
"phone",
"ref/vatin",
"smoking",
"takeaway",
"website",
"wheelchair"
],
"geometry": [
Expand Down
6 changes: 3 additions & 3 deletions data/presets/presets/amenity/internet_cafe.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"building_area",
"internet_access",
"internet_access/fee",
"internet_access/ssid"
"internet_access/ssid",
"phone",
"website"
],
"moreFields": [
"air_conditioning",
Expand All @@ -21,10 +23,8 @@
"opening_hours/covid19",
"outdoor_seating",
"payment_multi",
"phone",
"ref/vatin",
"smoking",
"website",
"wheelchair"
],
"geometry": [
Expand Down
4 changes: 3 additions & 1 deletion data/presets/presets/club.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"address",
"building_area",
"opening_hours",
"opening_hours/covid19"
"opening_hours/covid19",
"phone",
"website"
],
"moreFields": [
"access_simple",
Expand Down
6 changes: 3 additions & 3 deletions data/presets/presets/craft.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"address",
"building_area",
"opening_hours",
"opening_hours/covid19"
"opening_hours/covid19",
"phone",
"website"
],
"moreFields": [
"air_conditioning",
Expand All @@ -21,10 +23,8 @@
"internet_access/fee",
"internet_access/ssid",
"level",
"phone",
"product",
"ref/vatin",
"website",
"wheelchair"
],
"geometry": [
Expand Down
6 changes: 3 additions & 3 deletions data/presets/presets/healthcare.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"operator",
"healthcare/speciality",
"address",
"building_area"
"building_area",
"phone",
"website"
],
"moreFields": [
"brand",
Expand All @@ -19,8 +21,6 @@
"opening_hours",
"opening_hours/covid19",
"payment_multi",
"phone",
"website",
"wheelchair"
],
"geometry": [
Expand Down
6 changes: 3 additions & 3 deletions data/presets/presets/polling_station.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"address",
"opening_hours",
"opening_hours/covid19",
"building_area"
"building_area",
"phone",
"website"
],
"moreFields": [
"air_conditioning",
Expand All @@ -17,8 +19,6 @@
"internet_access/fee",
"internet_access/ssid",
"level",
"phone",
"website",
"wheelchair"
],
"geometry": [
Expand Down
6 changes: 3 additions & 3 deletions data/presets/presets/shop.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"building_area",
"opening_hours",
"opening_hours/covid19",
"payment_multi"
"payment_multi",
"phone",
"website"
],
"moreFields": [
"air_conditioning",
Expand All @@ -25,11 +27,9 @@
"internet_access/ssid",
"level",
"not/name",
"phone",
"ref/vatin",
"second_hand",
"stroller",
"website",
"wheelchair"
],
"geometry": [
Expand Down
16 changes: 6 additions & 10 deletions scripts/build_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,7 @@ function validateCategoryPresets(categories, presets) {

function validatePresetFields(presets, fields) {
const betweenBracketsRegex = /([^{]*?)(?=\})/;
const maxFieldsBeforeError = 12;
const maxFieldsBeforeWarning = 8;
const maxFieldsBeforeError = 10;

for (let presetID in presets) {
let preset = presets[presetID];
Expand Down Expand Up @@ -734,23 +733,20 @@ function validatePresetFields(presets, fields) {
// since `moreFields` is available, check that `fields` doesn't get too cluttered
let fieldCount = preset.fields.length;

if (fieldCount > maxFieldsBeforeWarning) {
// Fields with `prerequisiteTag` probably won't show up initially,
if (fieldCount > maxFieldsBeforeError) {
// Fields with `prerequisiteTag` or `geometry` may not always be shown,
// so don't count them against the limits.
const fieldsWithoutPrerequisites = preset.fields.filter(fieldID => {
if (fields[fieldID] && fields[fieldID].prerequisiteTag) return false;
const alwaysShownFields = preset.fields.filter(fieldID => {
if (fields[fieldID] && fields[fieldID].prerequisiteTag || fields[fieldID].geometry) return false;
return true;
});
fieldCount = fieldsWithoutPrerequisites.length;
fieldCount = alwaysShownFields.length;
}
if (fieldCount > maxFieldsBeforeError) {
console.error(fieldCount + ' values in "fields" of "' + preset.name + '" (' + presetID + '). Limit: ' + maxFieldsBeforeError + '. Please move lower-priority fields to "moreFields".');
console.log('');
process.exit(1);
}
else if (fieldCount > maxFieldsBeforeWarning) {
console.log('Warning: ' + fieldCount + ' values in "fields" of "' + preset.name + '" (' + presetID + '). Recommended: ' + maxFieldsBeforeWarning + ' or fewer. Consider moving lower-priority fields to "moreFields".');
}
}
}
}
Expand Down

0 comments on commit f141d1a

Please sign in to comment.