forked from MapComplete/MapComplete
Add the possibility to show all questions of a group as one + documentation update
This commit is contained in:
parent
3570cfbaa8
commit
519feaa54b
10 changed files with 140 additions and 34 deletions
|
@ -8,7 +8,9 @@ export interface TagRenderingConfigJson {
|
|||
|
||||
/**
|
||||
* The id of the tagrendering, should be an unique string.
|
||||
* Used to keep the translations in sync. Only used in the tagRenderings-array of a layerConfig, not requered otherwise
|
||||
* Used to keep the translations in sync. Only used in the tagRenderings-array of a layerConfig, not requered otherwise.
|
||||
*
|
||||
* Use 'questions' to trigger the question box of this group (if a group is defined)
|
||||
*/
|
||||
id?: string,
|
||||
|
||||
|
|
|
@ -104,6 +104,12 @@ export default class TagRenderingConfig {
|
|||
throw `Freeform.args is defined. This should probably be 'freeform.helperArgs' (at ${context})`
|
||||
|
||||
}
|
||||
|
||||
if(json.freeform.key === "questions"){
|
||||
if(this.id !== "questions"){
|
||||
throw `If you use a freeform key 'questions', the ID must be 'questions' too to trigger the special behaviour. The current id is '${this.id}' (at ${context})`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ValidatedTextField.AllTypes[this.freeform.type] === undefined) {
|
||||
|
@ -186,6 +192,9 @@ export default class TagRenderingConfig {
|
|||
throw `${context}: The rendering for language ${ln} does not contain {questions}. This is a bug, as this rendering should include exactly this to trigger those questions to be shown!`
|
||||
|
||||
}
|
||||
if(this.freeform?.key !== undefined && this.freeform?.key !== "questions"){
|
||||
throw `${context}: If the ID is questions to trigger a question box, the only valid freeform value is 'questions' as well. Set freeform to questions or remove the freeform all together`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -201,6 +210,9 @@ export default class TagRenderingConfig {
|
|||
if(txt.indexOf("{"+this.freeform.key+"}") >= 0){
|
||||
continue
|
||||
}
|
||||
if(txt.indexOf("{"+this.freeform.key+":") >= 0){
|
||||
continue
|
||||
}
|
||||
if(txt.indexOf("{canonical("+this.freeform.key+")") >= 0){
|
||||
continue
|
||||
}
|
||||
|
@ -363,6 +375,9 @@ export default class TagRenderingConfig {
|
|||
}
|
||||
}
|
||||
|
||||
if(this.id === "questions"){
|
||||
return this.render
|
||||
}
|
||||
|
||||
if (this.freeform?.key === undefined) {
|
||||
return this.render;
|
||||
|
|
|
@ -77,12 +77,6 @@ export default class WithContextLoader {
|
|||
|
||||
if (renderingJson["builtin"] !== undefined) {
|
||||
const renderingId = renderingJson["builtin"]
|
||||
if (renderingId === "questions") {
|
||||
const tr = new TagRenderingConfig("questions", context);
|
||||
renderings.push(tr)
|
||||
continue;
|
||||
}
|
||||
|
||||
let sharedJson = WithContextLoader.getKnownTagRenderings(renderingId)
|
||||
if (sharedJson === undefined) {
|
||||
const keys = Array.from(SharedTagRenderings.SharedTagRenderingJson.keys());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue