mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 01:12:48 +02:00
userData error message continues popup fix
This commit is contained in:
parent
bbc8e4de70
commit
6d40bc9c2f
2 changed files with 86 additions and 41 deletions
|
@ -1663,3 +1663,27 @@ input.number-slider {
|
|||
.collapse-icon {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#property-userData-editor.error {
|
||||
border: 2px solid red;
|
||||
}
|
||||
|
||||
#property-userData-editorStatus {
|
||||
color: white;
|
||||
background-color: red;
|
||||
padding: 5px;
|
||||
display: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#property-materialData-editor.error {
|
||||
border: 2px solid red;
|
||||
}
|
||||
|
||||
#property-materialData-editorStatus {
|
||||
color: white;
|
||||
background-color: red;
|
||||
padding: 5px;
|
||||
display: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
|
@ -1823,7 +1823,7 @@ function createStringProperty(property, elProperty) {
|
|||
type="text"
|
||||
${propertyData.placeholder ? 'placeholder="' + propertyData.placeholder + '"' : ''}
|
||||
${propertyData.readOnly ? 'readonly' : ''}></input>
|
||||
`)
|
||||
`);
|
||||
|
||||
|
||||
elInput.addEventListener('change', createEmitTextPropertyUpdateFunction(property));
|
||||
|
@ -2359,31 +2359,41 @@ function saveUserData() {
|
|||
saveJSONUserData(true);
|
||||
}
|
||||
|
||||
function setJSONError(property, isError) {
|
||||
$("#property-"+ property + "-editor").toggleClass('error', isError);
|
||||
var $propertyUserDataEditorStatus = $("#property-"+ property + "-editorStatus");
|
||||
$propertyUserDataEditorStatus.css('display', isError ? 'block' : 'none');
|
||||
$propertyUserDataEditorStatus.text(isError ? 'Invalid JSON code - look for red X in your code' : '');
|
||||
}
|
||||
|
||||
function setUserDataFromEditor(noUpdate) {
|
||||
let json = null;
|
||||
let errorFound = false;
|
||||
try {
|
||||
json = editor.get();
|
||||
} catch (e) {
|
||||
alert('Invalid JSON code - look for red X in your code ', +e);
|
||||
errorFound = true;
|
||||
}
|
||||
if (json === null) {
|
||||
|
||||
setJSONError('userData', errorFound);
|
||||
|
||||
if (json !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
let text = editor.getText();
|
||||
if (noUpdate) {
|
||||
EventBridge.emitWebEvent(
|
||||
JSON.stringify({
|
||||
id: lastEntityID,
|
||||
type: "saveUserData",
|
||||
properties: {
|
||||
userData: text
|
||||
}
|
||||
})
|
||||
);
|
||||
} else {
|
||||
let text = editor.getText();
|
||||
if (noUpdate === true) {
|
||||
EventBridge.emitWebEvent(
|
||||
JSON.stringify({
|
||||
id: lastEntityID,
|
||||
type: "saveUserData",
|
||||
properties: {
|
||||
userData: text
|
||||
}
|
||||
})
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
updateProperty('userData', text, false);
|
||||
}
|
||||
updateProperty('userData', text, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2505,9 +2515,10 @@ function hideUserDataSaved() {
|
|||
|
||||
function showStaticUserData() {
|
||||
if (editor !== null) {
|
||||
$('#property-userData-static').show();
|
||||
$('#property-userData-static').css('height', $('#property-userData-editor').height());
|
||||
$('#property-userData-static').text(editor.getText());
|
||||
let $propertyUserDataStatic = $('#property-userData-static');
|
||||
$propertyUserDataStatic.show();
|
||||
$propertyUserDataStatic.css('height', $('#property-userData-editor').height());
|
||||
$propertyUserDataStatic.text(editor.getText());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2528,6 +2539,7 @@ function getEditorJSON() {
|
|||
|
||||
function deleteJSONEditor() {
|
||||
if (editor !== null) {
|
||||
setJSONError('userData', false);
|
||||
editor.destroy();
|
||||
editor = null;
|
||||
}
|
||||
|
@ -2578,29 +2590,31 @@ function saveMaterialData() {
|
|||
|
||||
function setMaterialDataFromEditor(noUpdate) {
|
||||
let json = null;
|
||||
let errorFound = false;
|
||||
try {
|
||||
json = materialEditor.get();
|
||||
} catch (e) {
|
||||
alert('Invalid JSON code - look for red X in your code ', +e);
|
||||
errorFound = true;
|
||||
}
|
||||
|
||||
setJSONError('materialData', errorFound);
|
||||
|
||||
if (json === null) {
|
||||
return;
|
||||
}
|
||||
let text = materialEditor.getText();
|
||||
if (noUpdate) {
|
||||
EventBridge.emitWebEvent(
|
||||
JSON.stringify({
|
||||
id: lastEntityID,
|
||||
type: "saveMaterialData",
|
||||
properties: {
|
||||
materialData: text
|
||||
}
|
||||
})
|
||||
);
|
||||
} else {
|
||||
let text = materialEditor.getText();
|
||||
if (noUpdate === true) {
|
||||
EventBridge.emitWebEvent(
|
||||
JSON.stringify({
|
||||
id: lastEntityID,
|
||||
type: "saveMaterialData",
|
||||
properties: {
|
||||
materialData: text
|
||||
}
|
||||
})
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
updateProperty('materialData', text, false);
|
||||
}
|
||||
updateProperty('materialData', text, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2667,9 +2681,10 @@ function hideMaterialDataSaved() {
|
|||
|
||||
function showStaticMaterialData() {
|
||||
if (materialEditor !== null) {
|
||||
$('#property-materialData-static').show();
|
||||
$('#property-materialData-static').css('height', $('#property-materialData-editor').height());
|
||||
$('#property-materialData-static').text(materialEditor.getText());
|
||||
let $propertyMaterialDataStatic = $('#property-materialData-static');
|
||||
$propertyMaterialDataStatic.show();
|
||||
$propertyMaterialDataStatic.css('height', $('#property-materialData-editor').height());
|
||||
$propertyMaterialDataStatic.text(materialEditor.getText());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2955,7 +2970,7 @@ function loaded() {
|
|||
let elServerScriptError = document.getElementById("property-serverScripts-error");
|
||||
let elServerScriptStatus = document.getElementById("property-serverScripts-status");
|
||||
elServerScriptError.value = data.errorInfo;
|
||||
// If we just set elServerScriptError's diplay to block or none, we still end up with
|
||||
// If we just set elServerScriptError's display to block or none, we still end up with
|
||||
// it's parent contributing 21px bottom padding even when elServerScriptError is display:none.
|
||||
// So set it's parent to block or none
|
||||
elServerScriptError.parentElement.style.display = data.errorInfo ? "block" : "none";
|
||||
|
@ -3314,12 +3329,15 @@ function loaded() {
|
|||
elStaticUserData.setAttribute("id", userDataElementID + "-static");
|
||||
let elUserDataEditor = document.createElement('div');
|
||||
elUserDataEditor.setAttribute("id", userDataElementID + "-editor");
|
||||
let elUserDataEditorStatus = document.createElement('div');
|
||||
elUserDataEditorStatus.setAttribute("id", userDataElementID + "-editorStatus");
|
||||
let elUserDataSaved = document.createElement('span');
|
||||
elUserDataSaved.setAttribute("id", userDataElementID + "-saved");
|
||||
elUserDataSaved.innerText = "Saved!";
|
||||
elDiv.childNodes[JSON_EDITOR_ROW_DIV_INDEX].appendChild(elUserDataSaved);
|
||||
elDiv.insertBefore(elStaticUserData, elUserData);
|
||||
elDiv.insertBefore(elUserDataEditor, elUserData);
|
||||
elDiv.insertBefore(elUserDataEditorStatus, elUserData);
|
||||
|
||||
// Material Data
|
||||
let materialDataProperty = properties["materialData"];
|
||||
|
@ -3330,12 +3348,15 @@ function loaded() {
|
|||
elStaticMaterialData.setAttribute("id", materialDataElementID + "-static");
|
||||
let elMaterialDataEditor = document.createElement('div');
|
||||
elMaterialDataEditor.setAttribute("id", materialDataElementID + "-editor");
|
||||
let elMaterialDataEditorStatus = document.createElement('div');
|
||||
elMaterialDataEditorStatus.setAttribute("id", materialDataElementID + "-editorStatus");
|
||||
let elMaterialDataSaved = document.createElement('span');
|
||||
elMaterialDataSaved.setAttribute("id", materialDataElementID + "-saved");
|
||||
elMaterialDataSaved.innerText = "Saved!";
|
||||
elDiv.childNodes[JSON_EDITOR_ROW_DIV_INDEX].appendChild(elMaterialDataSaved);
|
||||
elDiv.insertBefore(elStaticMaterialData, elMaterialData);
|
||||
elDiv.insertBefore(elMaterialDataEditor, elMaterialData);
|
||||
elDiv.insertBefore(elMaterialDataEditorStatus, elMaterialData);
|
||||
|
||||
// Special Property Callbacks
|
||||
let elParentMaterialNameString = getPropertyInputElement("materialNameToReplace");
|
||||
|
|
Loading…
Reference in a new issue