Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint 201903 dynamic properties #35

Open
wants to merge 2 commits into
base: sprint-201903-editable-properties
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lib/rest_library/areCommunicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,26 @@ function getRuntimeComponentProperty(successCallback, errorCallback, componentId
});
}

function getRuntimeComponentPropertyList(successCallback, errorCallback, componentId, componentKey) {

if ( (compoentId == "") || (componentKey == "")) return;

$.ajax({
type: "GET",
url: _baseURI + "runtime/model/components/"+encodeParam(componentId)+"/properties/"+encodeParam(componentKey),
datatype: "application/json",
crossDomain: true,
success:
function (data, textStatus, jqXHR) {
successCallback(jqXHR.responseText, textStatus);
},
error:
function (jqXHR, textStatus, errorThrown) {
errorCallback(errorThrown, jqXHR.responseText);
}
});
}


function setRuntimeComponentProperties(successCallback, errorCallback, propertyMap) {

Expand Down
166 changes: 103 additions & 63 deletions view/propertyEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ ACS.propertyEditor = function (modelList, // ACS.modelList
}
}
}



//Part for component
if (selectedElementType === "component") {
Expand Down Expand Up @@ -211,14 +209,15 @@ ACS.propertyEditor = function (modelList, // ACS.modelList
//var tempString=actModel.componentList[selectedElement].getId();
//Properties
for (var h = 0; h < actModel.componentList[selectedElement].propertyList.length; h++) {
var property = actModel.componentList[selectedElement].propertyList[h];
var property = actModel.componentList[selectedElement].propertyList[h];
var propName = property.getKey();
row[h + 1] = bodyT.insertRow(-1);
cell = row[h + 1].insertCell(0);

var comboValues = property.combobox;
var valtemp = property.value;
var typetemp = property.getType();
var isDynProp = property.getStringList;
cell.innerHTML = propName;

//generat dropdown list in case that combox includes values
Expand All @@ -245,77 +244,118 @@ ACS.propertyEditor = function (modelList, // ACS.modelList
cell.appendChild(dropdownList);
}

//generate checkbox field for boolean
if (comboValues === '' && typetemp === ACS.dataType.BOOLEAN) {
if (isDynProp) {

log.debug('downloading (dynamic) properties list');
setBaseURI(ACS.areBaseURI + '/rest/');

cell = row[h + 1].insertCell(1);
boolInput = null;
boolInput = document.createElement("INPUT");
boolInput.setAttribute("type", "checkbox");
boolInput.setAttribute("value", valtemp);
if ((valtemp === "true") || (valtemp === "True")) {
boolInput.setAttribute("checked", true);
var id = propertyEdPanelCaptions.innerHTML;
var key = propName;
var currentValue = valtemp || "";
var elementId = h + "/1/" + valtemp;

fetchDynProperties(cell, elementId, currentValue, id, key);
function fetchDynProperties(cellToAdd, elementId, currentValue, id, key) {
getRuntimeComponentPropertyList(function(data, httpStatus) {
var entries = data ? JSON.parse(data) : null;
entries.unshift("");
if(entries && entries.length === 0) {
console.warn('empty dynamic property list');
var inputElement = document.createElement('input');
inputElement.setAttribute("id", elementId);
cellToAdd.appendChild(inputElement);
} else {
var dropdownList = document.createElement('select');
for (var l = 0; l < entries.length; l++) {
var option = new Option(entries[l], entries[l]);
option.selected = (entries[l] == currentValue);
dropdownList.appendChild(option);
}
dropdownList.setAttribute("id", elementId);
dropdownList.addEventListener("change", writeProperty);
cellToAdd.appendChild(dropdownList);
}
}, function(HTTPstatus, AREerrorMessage) {
console.error('check if ARE is running');
console.error('error: ' + AREerrorMessage);
var inputElement = document.createElement('input');
inputElement.setAttribute("id", elementId);
cellToAdd.appendChild(inputElement);
}, id, key);
};

} else {
//generate checkbox field for boolean
if (comboValues === '' && typetemp === ACS.dataType.BOOLEAN) {
cell = row[h + 1].insertCell(1);
boolInput = null;
boolInput = document.createElement("INPUT");
boolInput.setAttribute("type", "checkbox");
boolInput.setAttribute("value", valtemp);
if ((valtemp === "true") || (valtemp === "True")) {
boolInput.setAttribute("checked", true);
}
boolInput.setAttribute("id", h + "/1/" + valtemp);
boolInput.addEventListener("change", writeProperty);
cell.appendChild(boolInput);
}
//generate intage field
if (comboValues === '' && typetemp === ACS.dataType.INTEGER) {
cell = row[h + 1].insertCell(1);
numberInput = null;
numberInput = document.createElement("INPUT");
numberInput.setAttribute("type", "number");
numberInput.setAttribute("value", valtemp);
numberInput.setAttribute("id", h + "/1/" + valtemp);
numberInput.addEventListener("focus", setPreviousNumber);
numberInput.addEventListener("change", writeProperty);
numberInput.addEventListener("input", writePropertyChangLocal); //workaround when blur is not fired
cell.appendChild(numberInput);
}
boolInput.setAttribute("id", h + "/1/" + valtemp);
boolInput.addEventListener("change", writeProperty);
cell.appendChild(boolInput);
}
//generate intage field
if (comboValues === '' && typetemp === ACS.dataType.INTEGER) {
cell = row[h + 1].insertCell(1);
numberInput = null;
numberInput = document.createElement("INPUT");
numberInput.setAttribute("type", "number");
numberInput.setAttribute("value", valtemp);
numberInput.setAttribute("id", h + "/1/" + valtemp);
numberInput.addEventListener("focus", setPreviousNumber);
numberInput.addEventListener("change", writeProperty);
numberInput.addEventListener("input", writePropertyChangLocal); //workaround when blur is not fired
cell.appendChild(numberInput);
}

if (comboValues === '' && typetemp === ACS.dataType.DOUBLE) {
cell = row[h + 1].insertCell(1);
numberInput = null;
numberInput = document.createElement("INPUT");
numberInput.setAttribute("type", "text");
//numberInput.setAttribute("step","0.0000000001");
numberInput.setAttribute("value", valtemp);
numberInput.setAttribute("pattern", "^[-]?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?");
numberInput.setAttribute("id", h + "/1/" + valtemp);
numberInput.addEventListener("change", writeProperty);
numberInput.addEventListener("input", writePropertyChangLocal); //workaround when blur is not fired
cell.appendChild(numberInput);
}
if (comboValues === '' && typetemp === ACS.dataType.DOUBLE) {
cell = row[h + 1].insertCell(1);
numberInput = null;
numberInput = document.createElement("INPUT");
numberInput.setAttribute("type", "text");
//numberInput.setAttribute("step","0.0000000001");
numberInput.setAttribute("value", valtemp);
numberInput.setAttribute("pattern", "^[-]?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?");
numberInput.setAttribute("id", h + "/1/" + valtemp);
numberInput.addEventListener("change", writeProperty);
numberInput.addEventListener("input", writePropertyChangLocal); //workaround when blur is not fired
cell.appendChild(numberInput);
}

if (comboValues === '' && typetemp === ACS.dataType.STRING) {
cell = row[h + 1].insertCell(1);
textInput = null;
textInput = document.createElement("INPUT");
textInput.setAttribute("type", "text");
textInput.setAttribute("name", propName);
textInput.setAttribute("value", ACS.utils.decodeForXml(valtemp));
textInput.setAttribute("id", h + "/1/" + valtemp);
textInput.addEventListener("blur", writeProperty);
textInput.addEventListener("input", writePropertyChangLocal); //workaround when blur is not fired
cell.appendChild(textInput);
if (comboValues === '' && typetemp === ACS.dataType.STRING) {
cell = row[h + 1].insertCell(1);
textInput = null;
textInput = document.createElement("INPUT");
textInput.setAttribute("type", "text");
textInput.setAttribute("name", propName);
textInput.setAttribute("value", ACS.utils.decodeForXml(valtemp));
textInput.setAttribute("id", h + "/1/" + valtemp);
textInput.addEventListener("blur", writeProperty);
textInput.addEventListener("input", writePropertyChangLocal); //workaround when blur is not fired
cell.appendChild(textInput);
}
}

//element.setAttribute("type", "button");
//element.setAttribute("value", tempString);
}

//internal Properties
internalPropertyTable.setAttribute("class", "propertyEditorT");

var headerInternalProoperty = internalPropertyTable.createTHead();
headerInternalProoperty.setAttribute("class", "propertyEditorTh");
row[0] = headerInternalProoperty.insertRow(0);
var headerInternalProopertyCell1 = document.createElement("TH");
headerInternalProopertyCell1.innerHTML = "Internal Property";
row[0].appendChild(headerInternalProopertyCell1);
var headerInternalProopertyCell2 = document.createElement("TH");
headerInternalProopertyCell2.innerHTML = "Value";
row[0].appendChild(headerInternalProopertyCell2);
var headerInternalProperty = internalPropertyTable.createTHead();
headerInternalProperty.setAttribute("class", "propertyEditorTh");
row[0] = headerInternalProperty.insertRow(0);
var headerInternalPropertyCell1 = document.createElement("TH");
headerInternalPropertyCell1.innerHTML = "Internal Property";
row[0].appendChild(headerInternalPropertyCell1);
var headerInternalPropertyCell2 = document.createElement("TH");
headerInternalPropertyCell2.innerHTML = "Value";
row[0].appendChild(headerInternalPropertyCell2);

var bodyT2 = internalPropertyTable.createTBody();
bodyT2.setAttribute("class", "propertyEditorTb");
Expand Down