Refactoring: new background selector

This commit is contained in:
Pieter Vander Vennet 2023-05-18 15:44:54 +02:00
parent 5427a4cb05
commit 82093ffdf4
25 changed files with 658 additions and 269 deletions

View file

@ -106,11 +106,11 @@ export default class CreateNoteImportLayer extends Conversion<LayerConfigJson, L
render: trs(t.popupTitle, { title }),
},
calculatedTags: [
"_first_comment=feat.get('comments')[0].text.toLowerCase()",
"_first_comment=get(feat)('comments')[0].text.toLowerCase()",
"_trigger_index=(() => {const lines = feat.properties['_first_comment'].split('\\n'); const matchesMapCompleteURL = lines.map(l => l.match(\".*https://mapcomplete.osm.be/\\([a-zA-Z_-]+\\)\\(.html\\)?.*#import\")); const matchedIndexes = matchesMapCompleteURL.map((doesMatch, i) => [doesMatch !== null, i]).filter(v => v[0]).map(v => v[1]); return matchedIndexes[0] })()",
"_comments_count=feat.get('comments').length",
"_intro=(() => {const lines = feat.get('comments')[0].text.split('\\n'); lines.splice(feat.get('_trigger_index')-1, lines.length); return lines.filter(l => l !== '').join('<br/>');})()",
"_tags=(() => {let lines = feat.get('comments')[0].text.split('\\n').map(l => l.trim()); lines.splice(0, feat.get('_trigger_index') + 1); lines = lines.filter(l => l != ''); return lines.join(';');})()",
"_comments_count=get(feat)('comments').length",
"_intro=(() => {const lines = get(feat)('comments')[0].text.split('\\n'); lines.splice(get(feat)('_trigger_index')-1, lines.length); return lines.filter(l => l !== '').join('<br/>');})()",
"_tags=(() => {let lines = get(feat)('comments')[0].text.split('\\n').map(l => l.trim()); lines.splice(0, get(feat)('_trigger_index') + 1); lines = lines.filter(l => l != ''); return lines.join(';');})()",
],
isShown: {
and: ["_trigger_index~*", { or: isShownIfAny }],