mirror of
https://github.com/nasa/openmct.git
synced 2024-12-20 05:37:53 +00:00
[Layout] Consistent input behavior
Inputs now handle invalid input consistently for all fields
This commit is contained in:
parent
f992fcebe1
commit
2e6fcec1c3
@ -148,21 +148,21 @@ define([
|
|||||||
{
|
{
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"property": "x",
|
"property": "editX",
|
||||||
"text": "X",
|
"text": "X",
|
||||||
"name": "X",
|
"name": "X",
|
||||||
"cssClass": "l-input-sm",
|
"cssClass": "l-input-sm",
|
||||||
"control": "textfield"
|
"control": "textfield"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"property":"y",
|
"property":"editY",
|
||||||
"text": "Y",
|
"text": "Y",
|
||||||
"name": "Y",
|
"name": "Y",
|
||||||
"cssClass": "l-input-sm",
|
"cssClass": "l-input-sm",
|
||||||
"control": "textfield"
|
"control": "textfield"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"property": "x1",
|
"method": "editX1",
|
||||||
"text": "X1",
|
"text": "X1",
|
||||||
"name": "X1",
|
"name": "X1",
|
||||||
"cssClass": "l-input-sm",
|
"cssClass": "l-input-sm",
|
||||||
|
@ -52,9 +52,11 @@ define(
|
|||||||
*/
|
*/
|
||||||
proxy.fill = new AccessorMutator(element, 'fill');
|
proxy.fill = new AccessorMutator(element, 'fill');
|
||||||
|
|
||||||
//Expose width and height for editing
|
//Expose x,y, width and height for editing
|
||||||
proxy.editWidth = new AccessorMutator(element,'width', proxy.checkNumeric);
|
proxy.editWidth = new AccessorMutator(element,'width', proxy.checkNumeric);
|
||||||
proxy.editHeight = new AccessorMutator(element,'height', proxy.checkNumeric);
|
proxy.editHeight = new AccessorMutator(element,'height', proxy.checkNumeric);
|
||||||
|
proxy.editX = new AccessorMutator(element,'x',proxy.checkNumeric);
|
||||||
|
proxy.editY = new AccessorMutator(element,'y', proxy.checkNumeric);
|
||||||
|
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
@ -164,17 +164,17 @@ define(
|
|||||||
* or the current value of the new value is invalid.
|
* or the current value of the new value is invalid.
|
||||||
*/
|
*/
|
||||||
ElementProxy.prototype.checkNumeric = function(value, current) {
|
ElementProxy.prototype.checkNumeric = function(value, current) {
|
||||||
// Allow field to be empty
|
var intValue = parseInt(value);
|
||||||
|
// Handle case of empty field by swapping in 0
|
||||||
if (value === ''){
|
if (value === ''){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// Else, check if the input is integral, and not, return current value
|
// Else, check if the input is integral, and not, return current value
|
||||||
// of the field
|
// of the field
|
||||||
value = parseInt(value);
|
if ( isNaN(intValue) ){
|
||||||
if ( isNaN(value) ){
|
|
||||||
return current;
|
return current;
|
||||||
} else {
|
} else {
|
||||||
return value;
|
return intValue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,6 +52,8 @@ define(
|
|||||||
//Expose width and height properties for editing
|
//Expose width and height properties for editing
|
||||||
proxy.editWidth = new AccessorMutator(element, 'width', proxy.checkNumeric);
|
proxy.editWidth = new AccessorMutator(element, 'width', proxy.checkNumeric);
|
||||||
proxy.editHeight = new AccessorMutator(element, 'height', proxy.checkNumeric);
|
proxy.editHeight = new AccessorMutator(element, 'height', proxy.checkNumeric);
|
||||||
|
proxy.editX = new AccessorMutator(element,'x',proxy.checkNumeric);
|
||||||
|
proxy.editY = new AccessorMutator(element,'y', proxy.checkNumeric);
|
||||||
|
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user