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

#2162 Avoid double input in data point properties edition #3095

Open
wants to merge 3 commits into
base: release/2.8.0
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
29 changes: 27 additions & 2 deletions WebContent/WEB-INF/jsp/dataPointEdit.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@
<tr>
<td valign="top" width="60%">
<%@ include file="/WEB-INF/jsp/pointEdit/pointProperties.jsp" %>
<%@ include file="/WEB-INF/jsp/pointEdit/loggingProperties.jsp" %>
<%@ include file="/WEB-INF/jsp/pointEdit/eventTextRenderer.jsp"%>
<%@ include file="/WEB-INF/jsp/pointEdit/textRenderer.jsp" %>
<%@ include file="/WEB-INF/jsp/pointEdit/eventTextRenderer.jsp"%>
<%@ include file="/WEB-INF/jsp/pointEdit/chartRenderer.jsp" %>
<%@ include file="/WEB-INF/jsp/pointEdit/loggingProperties.jsp" %>
</td>
<td valign="top" width="40%">
<%@ include file="/WEB-INF/jsp/pointEdit/eventDetectors.jsp" %>
Expand Down Expand Up @@ -883,6 +883,31 @@
}
});
}

jQuery(document).ready(function() {
function updateSuffixForEngineeringUnits() {
let value = jQuery("select[name='engineeringUnits']").val();
let unitValue = parseInt(value);
let units = ${unitsListJson};
units.forEach(unit => {
if(unit.value === unitValue) {
jQuery("#textRendererAnalogFormat").val('#.##');
jQuery("#textRendererAnalogSuffix").val(' ' + unescapeHtml(unit.suffix));
jQuery("#textRendererPlainSuffix").val(' ' + unescapeHtml(unit.suffix));
}
});
}

jQuery("select[name='engineeringUnits']").on("change", function() {
updateSuffixForEngineeringUnits();
});

let suffix = jQuery("#textRendererAnalogSuffix").val();

if(!suffix){
updateSuffixForEngineeringUnits();
}
});
</script>

</td>
Expand Down
2 changes: 1 addition & 1 deletion WebContent/WEB-INF/jsp/pointEdit/pointProperties.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<tr>
<td class="formLabelRequired"><spring:message code="pointEdit.props.engineeringUnits"/></td>
<td class="formField">
<sst:select name="engineeringUnits" value="${status.value}"><tag:engineeringUnits/></sst:select>
<sst:select name="engineeringUnits" value="${status.value}"><tag:engineeringUnits unitsMap="${unitsMap}"/></sst:select>
</td>
<c:if test="${error.engineeringUnits != null}"><td class="formError"><spring:message code="${error.engineeringUnits}"/></td></c:if>
</tr>
Expand Down
246 changes: 9 additions & 237 deletions WebContent/WEB-INF/tags/engineeringUnits.tag

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ test {
includeTestsMatching "org.scada_lts.web.beans.validation.xss.XssValidatorTestsSuite"
includeTestsMatching "org.scada_lts.utils.CyclicDependencyValidationUtilsTest"
includeTestsMatching "org.scada_lts.ds.polling.protocol.opcua.vo.OpcUaDataTypeTestsSuite"
includeTestsMatching "com.serotonin.mango.vo.EngineeringUnitsTypesTest"
}

failFast = true
Expand Down
8 changes: 8 additions & 0 deletions src/com/serotonin/mango/vo/EngineeringUnit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.serotonin.mango.vo;

public interface EngineeringUnit {
int getValue();
String getName();
String getSuffix();
String getKey();
}
Loading
Loading