forked from MapComplete/MapComplete
Add MapComplete
This commit is contained in:
commit
6187122294
61 changed files with 107059 additions and 0 deletions
50
UI/QuestionPicker.ts
Normal file
50
UI/QuestionPicker.ts
Normal file
|
@ -0,0 +1,50 @@
|
|||
import {UIElement} from "./UIElement";
|
||||
import {Question} from "../Logic/Question";
|
||||
import {UIEventSource} from "./UIEventSource";
|
||||
|
||||
export class QuestionPicker extends UIElement {
|
||||
private readonly _questions: Question[];
|
||||
private readonly tags: any;
|
||||
private source: UIEventSource<any>;
|
||||
|
||||
constructor(questions: Question[],
|
||||
tags: UIEventSource<any>) {
|
||||
super(tags);
|
||||
this._questions = questions;
|
||||
this.tags = tags.data;
|
||||
this.source = tags;
|
||||
}
|
||||
|
||||
|
||||
protected InnerRender(): string {
|
||||
|
||||
let t = this.tags;
|
||||
let highestPriority = Number.MIN_VALUE;
|
||||
let highestQ: Question;
|
||||
for (const q of this._questions) {
|
||||
|
||||
if (!q.Applicable(t)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const priority = q.question.severity;
|
||||
if (priority > highestPriority) {
|
||||
highestPriority = priority;
|
||||
highestQ = q;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (highestQ === undefined) {
|
||||
return "De vragen zijn op!";
|
||||
}
|
||||
|
||||
return highestQ.CreateHtml(this.source).Render();
|
||||
}
|
||||
InnerUpdate(htmlElement: HTMLElement) {
|
||||
}
|
||||
|
||||
Activate() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue