Finish the additions of reviews

This commit is contained in:
Pieter Vander Vennet 2020-12-08 23:44:34 +01:00
parent c02406241e
commit cdfffd6120
29 changed files with 675 additions and 142 deletions

View file

@ -93,6 +93,12 @@ export default class LayerConfig {
return tagRenderings.map(
(renderingJson, i) => {
if (typeof renderingJson === "string") {
if(renderingJson === "questions"){
return new TagRenderingConfig("questions")
}
const shared = SharedTagRenderings.SharedTagRendering[renderingJson];
if (shared !== undefined) {
return shared;

View file

@ -143,6 +143,10 @@ export interface LayerConfigJson {
* Note that we can also use a string here - where the string refers to a tagrenering defined in `assets/questions/questions.json`,
* where a few very general questions are defined e.g. website, phone number, ...
*
* A special value is 'questions', which indicates the location of the questions box. If not specified, it'll be appended to the bottom of the featureInfobox.
*
*/
tagRenderings?: (string | TagRenderingConfigJson) []
}

View file

@ -31,8 +31,15 @@ export default class TagRenderingConfig {
constructor(json: string | TagRenderingConfigJson, context?: string) {
if(json === undefined){
throw "Initing a TagRenderingConfig with undefined in "+context;
if (json === "questions") {
// Very special value
this.render = null;
this.question = null;
this.condition = null;
}
if (json === undefined) {
throw "Initing a TagRenderingConfig with undefined in " + context;
}
if (typeof json === "string") {
this.render = Translations.T(json);
@ -63,13 +70,13 @@ export default class TagRenderingConfig {
throw "Invalid mapping: if without body"
}
let hideInAnswer : boolean | TagsFilter = false;
if(typeof mapping.hideInAnswer === "boolean"){
if (typeof mapping.hideInAnswer === "boolean") {
hideInAnswer = mapping.hideInAnswer;
}else{
hideInAnswer = FromJSON.Tag(mapping.hideInAnswer);
} else if (mapping.hideInAnswer !== undefined) {
hideInAnswer = FromJSON.Tag(mapping.hideInAnswer, `${context}.mapping[${i}].hideInAnswer`);
}
return {
if: FromJSON.Tag(mapping.if, `${context}.mapping[${i}]`),
if: FromJSON.Tag(mapping.if, `${context}.mapping[${i}].if`),
then: Translations.T(mapping.then),
hideInAnswer: hideInAnswer
};

View file

@ -10,12 +10,11 @@ export default class SharedTagRenderings {
private static generatedSharedFields(iconsOnly = false) {
const dict = {}
function add(key, store) {
try {
dict[key] = new TagRenderingConfig(store[key])
dict[key] = new TagRenderingConfig(store[key], key)
} catch (e) {
console.error("BUG: could not parse", key, " from questions.json or icons.json", e)
console.error("BUG: could not parse", key, " from questions.json or icons.json - this error happened during the build step of the SharedTagRenderings", e)
}
}