37 lines
974 B
JavaScript
37 lines
974 B
JavaScript
import { Term } from "./Term.js";
|
|
import { ValueRequirement } from "./ValueRequirement.js";
|
|
|
|
export class Mechanism extends Term {
|
|
separator = ":";
|
|
placeholder = null;
|
|
|
|
constructor(key) {
|
|
super(key);
|
|
}
|
|
|
|
getInputQualifier(id) {
|
|
return document.getElementById(id + "-qualifier").value;
|
|
}
|
|
|
|
getInputValue(id) {
|
|
return document.getElementById(id + "-value")?.value;
|
|
}
|
|
|
|
getInputHtml(id) {
|
|
const noValue = this.valueRequirement === ValueRequirement.PROHIBITED;
|
|
const placeholder = this.placeholder
|
|
+ (this.valueRequirement === ValueRequirement.OPTIONAL ? " (Optional)" : "");
|
|
|
|
return `
|
|
<select id="${id}-qualifier">
|
|
${this.isRequired ? "" : `<option value=""><not set></option>`}
|
|
<option value="+">Pass</option>
|
|
<option value="-">Fail</option>
|
|
<option value="~">Soft fail</option>
|
|
<option value="?">Neutral</option>
|
|
</select>
|
|
${noValue ? "" : `<input id="${id}-value" type="text" placeholder="${placeholder}">`}
|
|
`;
|
|
}
|
|
}
|