Skip to content
Snippets Groups Projects
Commit 3da04fc7 authored by Stekelenburg, A.V. (Alexander, Student )'s avatar Stekelenburg, A.V. (Alexander, Student )
Browse files

Add title attributes to sidebar and add number inputs and dropdowns for enums

parent b0d27590
No related branches found
No related tags found
No related merge requests found
......@@ -42,9 +42,11 @@ ul.option-list li input.name {
width: 70%;
}
ul.option-list li input.value {
ul.option-list li input.value,
ul.option-list li select.value {
vertical-align: middle;
margin:0;
height:100%;
}
ul.option-list li input.value[type='checkbox']:focus {
......
......@@ -234,7 +234,7 @@
for (const tool of parameters) {
if (tool.toolName === toolName) {
for (const parameter of tool.parameters) {
addParameterItem(parameter.id, parameter.value, parameter.category, parameter.type, parameter.description);
addParameterItem(parameter.id, parameter.value, parameter.category, parameter.type, parameter.description, parameter.possibleValues);
}
break;
}
......@@ -267,6 +267,7 @@
nameBox.id = "name-" + name;
nameBox.appendChild(document.createTextNode(name));
nameBox.classList.add("name");
nameBox.title = name;
li.appendChild(nameBox);
......@@ -371,7 +372,7 @@
return categoryUl;
}
function addParameterItem(name, value, category, type, description) {
function addParameterItem(name, value, category, type, description, possibleValues) {
if (category === "") {
category = "Other";
}
......@@ -390,28 +391,65 @@
li.appendChild(nameBox);
const valueBox = document.createElement("input");
valueBox.id = "value-" + name;
valueBox.type = type;
valueBox.value = value;
valueBox.classList.add("value");
valueBox.addEventListener("input", event => {
let oldState = vscode.getState();
for (const tool of oldState.parameters) {
if (tool.toolName === oldState.currentTool) {
for (const parameter of tool.parameters) {
if (parameter.id === name) {
parameter.value = valueBox.value;
break;
if (type === "Enum") {
/**
* @type {HTMLSelectElement}
*/
const valueBox = document.createElement("select");
valueBox.id = "value-" + name;
valueBox.classList.add("value");
for (const value of possibleValues) {
const option = document.createElement("option");
option.value = value;
option.text = value;
valueBox.appendChild(option);
}
valueBox.value = value;
valueBox.addEventListener("input", _ => {
let oldState = vscode.getState();
for (const tool of oldState.parameters) {
if (tool.toolName === oldState.currentTool) {
for (const parameter of tool.parameters) {
if (parameter.id === name) {
parameter.value = valueBox.options[valueBox.selectedIndex].value;
break;
}
}
break;
}
break;
}
}
vscode.setState({ tools: oldState.tools, documentVars: oldState.documentVars, parameters: oldState.parameters, currentUri: oldState.currentUri, currentTool: oldState.currentTool });
});
vscode.setState({ tools: oldState.tools, documentVars: oldState.documentVars, parameters: oldState.parameters, currentUri: oldState.currentUri, currentTool: oldState.currentTool });
});
li.appendChild(valueBox);
} else {
const valueBox = document.createElement("input");
valueBox.id = "value-" + name;
valueBox.type = type;
valueBox.value = value;
valueBox.classList.add("value");
valueBox.addEventListener("input", _ => {
let oldState = vscode.getState();
for (const tool of oldState.parameters) {
if (tool.toolName === oldState.currentTool) {
for (const parameter of tool.parameters) {
if (parameter.id === name) {
parameter.value = valueBox.value;
break;
}
}
break;
}
}
vscode.setState({ tools: oldState.tools, documentVars: oldState.documentVars, parameters: oldState.parameters, currentUri: oldState.currentUri, currentTool: oldState.currentTool });
});
li.appendChild(valueBox);
li.appendChild(valueBox);
}
categoryUl.appendChild(li);
}
......
......@@ -89,6 +89,11 @@ function getType(type: string) {
case "Boolean": {
return "checkbox";
}
case "Integer":
case "Real":
case "Long": {
return "number";
}
default: {
return "text";
}
......@@ -100,6 +105,9 @@ function getParameters(toolName: string) {
client?.sendRequest<ParameterDefinitions>("modest/getParameters", jsonObject).then(data => {
const index = localParameters.findIndex(x => x.toolName === toolName);
const newParameters = data.parameterDefinitions.map(parameter => {
if (parameter.type.valueType === "Enum") {
return { id: parameter.id, value: parameter.defaultValue, type: "Enum", category: parameter.category, description: parameter.description, possibleValues: parameter.type.possibleValues };
}
return { id: parameter.id, value: parameter.defaultValue, type: getType(parameter.type.valueType), category: parameter.category, description: parameter.description };
});
if (index === -1) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment