Fix rendering of questions, they update now with the tags

This commit is contained in:
pietervdvn 2020-12-27 21:44:49 +01:00
parent 0b28c5d319
commit 3179e59f53
3 changed files with 8 additions and 5 deletions

View file

@ -113,7 +113,6 @@ export default class TagRenderingQuestion extends UIElement {
} }
private GenerateMultiAnswer(elements: InputElement<TagsFilter>[], freeformField: InputElement<TagsFilter>): InputElement<TagsFilter> { private GenerateMultiAnswer(elements: InputElement<TagsFilter>[], freeformField: InputElement<TagsFilter>): InputElement<TagsFilter> {
const possibleTags = elements.map(el => el.GetValue().data);
const checkBoxes = new CheckBoxes(elements); const checkBoxes = new CheckBoxes(elements);
const inputEl = new InputElementMap<number[], TagsFilter>( const inputEl = new InputElementMap<number[], TagsFilter>(
checkBoxes, checkBoxes,
@ -125,8 +124,7 @@ export default class TagRenderingQuestion extends UIElement {
return undefined; return undefined;
} }
const tags: TagsFilter[] = indices.map(i => elements[i].GetValue().data); const tags: TagsFilter[] = indices.map(i => elements[i].GetValue().data);
const multi = TagUtils.FlattenMultiAnswer(tags); return TagUtils.FlattenMultiAnswer(tags);
return multi;
}, },
(tags: TagsFilter) => { (tags: TagsFilter) => {
// {key --> values[]} // {key --> values[]}

View file

@ -29,7 +29,12 @@ export class SubstitutedTranslation extends UIElement {
this.translation = translation; this.translation = translation;
this.tags = tags; this.tags = tags;
const self = this; const self = this;
Locale.language.addCallbackAndRun(() => { tags.addCallbackAndRun(() => {
self.content = self.CreateContent();
self.Update();
});
Locale.language.addCallback(() => {
self.content = self.CreateContent(); self.content = self.CreateContent();
self.Update(); self.Update();
}); });

View file

@ -17,7 +17,7 @@
"prepare-deploy": "npm run generate:editor-layer-index && npm run generate:layouts && npm run generate && npm run build && rm -rf .cache", "prepare-deploy": "npm run generate:editor-layer-index && npm run generate:layouts && npm run generate && npm run build && rm -rf .cache",
"deploy:staging": "npm run prepare-deploy && rm -rf /home/pietervdvn/git/pietervdvn.github.io/MapComplete/* && cp -r dist/* /home/pietervdvn/git/pietervdvn.github.io/MapComplete/ && cd /home/pietervdvn/git/pietervdvn.github.io/ && git add * && git commit -m 'New MapComplete Version' && git push && cd - && npm run clean", "deploy:staging": "npm run prepare-deploy && rm -rf /home/pietervdvn/git/pietervdvn.github.io/MapComplete/* && cp -r dist/* /home/pietervdvn/git/pietervdvn.github.io/MapComplete/ && cd /home/pietervdvn/git/pietervdvn.github.io/ && git add * && git commit -m 'New MapComplete Version' && git push && cd - && npm run clean",
"deploy:production": "rm -rf ./assets/generated && npm run prepare-deploy && npm run optimize-images && rm -rf /home/pietervdvn/git/mapcomplete.github.io/* && cp -r dist/* /home/pietervdvn/git/mapcomplete.github.io/ && cd /home/pietervdvn/git/mapcomplete.github.io/ && echo \"mapcomplete.osm.be\" > CNAME && git add * && git commit -m 'New MapComplete Version' && git push && cd - && npm run clean", "deploy:production": "rm -rf ./assets/generated && npm run prepare-deploy && npm run optimize-images && rm -rf /home/pietervdvn/git/mapcomplete.github.io/* && cp -r dist/* /home/pietervdvn/git/mapcomplete.github.io/ && cd /home/pietervdvn/git/mapcomplete.github.io/ && echo \"mapcomplete.osm.be\" > CNAME && git add * && git commit -m 'New MapComplete Version' && git push && cd - && npm run clean",
"clean": "rm -rf .cache/ && (find *.html | grep -v \"\\(index\\|land\\|test\\|preferences\\|customGenerator\\).html\" | xargs rm) && (find *.webmanifest | xargs rm)" "clean": "rm -rf .cache/ && (find *.html | grep -v \"\\(index\\|land\\|test\\|preferences\\|customGenerator\\).html\" | xargs rm) && rm *.webmanifest"
}, },
"keywords": [ "keywords": [
"OpenStreetMap", "OpenStreetMap",