From 6828699a4c4e4f516cc04903d81542c90a50eb10 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Mon, 13 Jul 2020 12:10:43 +0200 Subject: [PATCH] Change quest descriptions and orders in order to improve data quality --- Customizations/Layers/Bos.ts | 6 +++-- Customizations/Layers/NatureReserves.ts | 2 ++ Customizations/Layers/Park.ts | 6 +++-- Customizations/Layouts/Groen.ts | 1 + Customizations/OnlyShowIf.ts | 23 ++++++++++++++++++- Customizations/Questions/AccessTag.ts | 5 ++-- .../Questions/DescriptionQuestion.ts | 19 +++++++++++++++ Customizations/Questions/NameQuestion.ts | 7 ++++-- Customizations/TagRendering.ts | 12 ++++++++-- Customizations/UIElementConstructor.ts | 4 +++- index.css | 5 ++++ 11 files changed, 77 insertions(+), 13 deletions(-) create mode 100644 Customizations/Questions/DescriptionQuestion.ts diff --git a/Customizations/Layers/Bos.ts b/Customizations/Layers/Bos.ts index 51520ff..e568839 100644 --- a/Customizations/Layers/Bos.ts +++ b/Customizations/Layers/Bos.ts @@ -6,6 +6,7 @@ import {OperatorTag} from "../Questions/OperatorTag"; import {TagRenderingOptions} from "../TagRendering"; import {NameQuestion} from "../Questions/NameQuestion"; import {NameInline} from "../Questions/NameInline"; +import {DescriptionQuestion} from "../Questions/DescriptionQuestion"; export class Bos extends LayerDefinition { @@ -34,7 +35,8 @@ export class Bos extends LayerDefinition { this.elementsToShow = [ new NameQuestion(), new AccessTag(), - new OperatorTag() + new OperatorTag(), + new DescriptionQuestion("bos") ]; } @@ -46,7 +48,7 @@ export class Bos extends LayerDefinition { let questionSeverity = 0; for (const qd of self.elementsToShow) { if (qd.IsQuestioning(properties)) { - questionSeverity = Math.max(questionSeverity, qd.options.priority ?? 0); + questionSeverity = Math.max(questionSeverity, qd.Priority()); } } diff --git a/Customizations/Layers/NatureReserves.ts b/Customizations/Layers/NatureReserves.ts index c741766..8528a0e 100644 --- a/Customizations/Layers/NatureReserves.ts +++ b/Customizations/Layers/NatureReserves.ts @@ -5,6 +5,7 @@ import {AccessTag} from "../Questions/AccessTag"; import {OperatorTag} from "../Questions/OperatorTag"; import {NameQuestion} from "../Questions/NameQuestion"; import {NameInline} from "../Questions/NameInline"; +import {DescriptionQuestion} from "../Questions/DescriptionQuestion"; export class NatureReserves extends LayerDefinition { @@ -25,6 +26,7 @@ export class NatureReserves extends LayerDefinition { new NameQuestion(), new AccessTag(), new OperatorTag(), + new DescriptionQuestion("natuurgebied") ]; } diff --git a/Customizations/Layers/Park.ts b/Customizations/Layers/Park.ts index dcce5d1..c354fb4 100644 --- a/Customizations/Layers/Park.ts +++ b/Customizations/Layers/Park.ts @@ -6,6 +6,7 @@ import {OperatorTag} from "../Questions/OperatorTag"; import {TagRenderingOptions} from "../TagRendering"; import {NameQuestion} from "../Questions/NameQuestion"; import {NameInline} from "../Questions/NameInline"; +import {DescriptionQuestion} from "../Questions/DescriptionQuestion"; export class Park extends LayerDefinition { @@ -50,7 +51,8 @@ export class Park extends LayerDefinition { this.title = new NameInline("park"); this.elementsToShow = [new NameQuestion(), this.accessByDefault, - this.operatorByDefault + this.operatorByDefault, + new DescriptionQuestion("park"), ]; @@ -65,7 +67,7 @@ export class Park extends LayerDefinition { let questionSeverity = 0; for (const qd of self.elementsToShow) { if (qd.IsQuestioning(properties)) { - questionSeverity = Math.max(questionSeverity, qd.options.priority ?? 0); + questionSeverity = Math.max(questionSeverity, qd.Priority() ?? 0); } } diff --git a/Customizations/Layouts/Groen.ts b/Customizations/Layouts/Groen.ts index f27da74..8e7f047 100644 --- a/Customizations/Layouts/Groen.ts +++ b/Customizations/Layouts/Groen.ts @@ -35,6 +35,7 @@ export class Groen extends Layout { "" + diff --git a/Customizations/OnlyShowIf.ts b/Customizations/OnlyShowIf.ts index 1e8d59f..c6f6eaf 100644 --- a/Customizations/OnlyShowIf.ts +++ b/Customizations/OnlyShowIf.ts @@ -22,7 +22,28 @@ export class OnlyShowIfConstructor implements TagDependantUIElementConstructor{ this._embedded.construct(tags, changes), this._tagsFilter); } - + + IsKnown(properties: any): boolean { + if(!this.Matches(properties)){ + return true; + } + return this._embedded.IsKnown(properties); + } + + IsQuestioning(properties: any): boolean { + if(!this.Matches(properties)){ + return false; + } + return this._embedded.IsQuestioning(properties); + } + + Priority(): number { + return this._embedded.Priority(); + } + + private Matches(properties: any) : boolean{ + return this._tagsFilter.matches(TagUtils.proprtiesToKV(properties)); + } } diff --git a/Customizations/Questions/AccessTag.ts b/Customizations/Questions/AccessTag.ts index 06a5fe0..cb2de92 100644 --- a/Customizations/Questions/AccessTag.ts +++ b/Customizations/Questions/AccessTag.ts @@ -10,10 +10,9 @@ export class AccessTag extends TagRenderingOptions { question: "Is dit gebied toegankelijk?", primer: "Dit gebied is ", freeform: { - key: "access", - extraTags: new Tag("fixme", "Freeform access tag used: possibly a wrong value"), + key: "access:description", template: "Iets anders: $$$", - renderTemplate: "De toegangekelijkheid van dit gebied is: {access}", + renderTemplate: "De toegankelijkheid van dit gebied is: {access:description}", placeholder: "Specifieer" }, mappings: [ diff --git a/Customizations/Questions/DescriptionQuestion.ts b/Customizations/Questions/DescriptionQuestion.ts new file mode 100644 index 0000000..b017205 --- /dev/null +++ b/Customizations/Questions/DescriptionQuestion.ts @@ -0,0 +1,19 @@ +import {TagRenderingOptions} from "../TagRendering"; + + +export class DescriptionQuestion extends TagRenderingOptions{ + + constructor(category: string) { + super({ + question: "Zijn er bijzonderheden die we moeten weten over dit "+category+"?
" + + "Je hoeft niet te herhalen wat je net hebt aangeduid.
" + + "Voel je vrij om dit veld over te slaan.
", + freeform:{ + key:"description:0", + renderTemplate: "{description:0}", + template: "$$$" + } + }); + } + +} \ No newline at end of file diff --git a/Customizations/Questions/NameQuestion.ts b/Customizations/Questions/NameQuestion.ts index 270a00e..bc5c351 100644 --- a/Customizations/Questions/NameQuestion.ts +++ b/Customizations/Questions/NameQuestion.ts @@ -9,8 +9,11 @@ import {Tag} from "../../Logic/TagsFilter"; export class NameQuestion extends TagRenderingOptions{ static options = { - priority: 20, - question: "Wat is de officiƫle naam van dit gebied?", + priority: -1, // Move this last on the priority list, in order to prevent ppl to enter access restrictions and descriptions + question: "Wat is de officiƫle naam van dit gebied?
" + + "Zelf een naam bedenken wordt afgeraden.
" + + "Een beschrijving van het gebied geven kan in een volgende stap.
" + + "
", freeform: { key: "name", template: "De naam is $$$", diff --git a/Customizations/TagRendering.ts b/Customizations/TagRendering.ts index 9f80166..bd99ed4 100644 --- a/Customizations/TagRendering.ts +++ b/Customizations/TagRendering.ts @@ -77,7 +77,7 @@ export class TagRenderingOptions implements TagDependantUIElementConstructor { IsQuestioning(tags: any): boolean { const tagsKV = TagUtils.proprtiesToKV(tags); - for (const oneOnOneElement of this.options.mappings) { + for (const oneOnOneElement of this.options.mappings ?? []) { if (oneOnOneElement.k === null || oneOnOneElement.k.matches(tagsKV)) { return false; } @@ -97,6 +97,14 @@ export class TagRenderingOptions implements TagDependantUIElementConstructor { return new TagRendering(tags, changes, this.options); } + IsKnown(properties: any): boolean { + return !this.IsQuestioning(properties); + } + + Priority(): number { + return this.options.priority ?? 0; + } + } class TagRendering extends UIElement implements TagDependantUIElement { @@ -285,7 +293,7 @@ class TagRendering extends UIElement implements TagDependantUIElement { if (isEditing) { return "Annuleren"; } else { - return "Ik weet het niet zeker..."; + return "Overslaan (Ik weet het niet zeker...)"; } }); // And at last, set up the skip button diff --git a/Customizations/UIElementConstructor.ts b/Customizations/UIElementConstructor.ts index 8c0758e..d90ce0c 100644 --- a/Customizations/UIElementConstructor.ts +++ b/Customizations/UIElementConstructor.ts @@ -6,7 +6,9 @@ import {UIElement} from "../UI/UIElement"; export interface TagDependantUIElementConstructor { construct(tags: UIEventSource, changes: Changes): TagDependantUIElement; - + IsKnown(properties: any): boolean; + IsQuestioning(properties: any): boolean; + Priority(): number; } export abstract class TagDependantUIElement extends UIElement { diff --git a/index.css b/index.css index 830269b..07cf49b 100644 --- a/index.css +++ b/index.css @@ -679,6 +679,11 @@ form { font-weight: bold; } +.question-subtext{ + font-size: medium; + font-weight: normal; +} + .answer { display: inline-block; margin: 0.1em;