mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
validate inserted values in numeric global settings (#10279)
This commit is contained in:
parent
1c84ce4e23
commit
6f03f9e726
@ -39,6 +39,7 @@
|
|||||||
@keydown.esc="editableValueKey = null"
|
@keydown.esc="editableValueKey = null"
|
||||||
@pressEnter="updateConfigurationValue(configrecord)"
|
@pressEnter="updateConfigurationValue(configrecord)"
|
||||||
@change="value => setConfigurationEditable(configrecord, value)"
|
@change="value => setConfigurationEditable(configrecord, value)"
|
||||||
|
@keydown="e => handleInputNumberKeyDown(e, false)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</span>
|
</span>
|
||||||
@ -52,6 +53,7 @@
|
|||||||
@keydown.esc="editableValueKey = null"
|
@keydown.esc="editableValueKey = null"
|
||||||
@pressEnter="updateConfigurationValue(configrecord)"
|
@pressEnter="updateConfigurationValue(configrecord)"
|
||||||
@change="value => setConfigurationEditable(configrecord, value)"
|
@change="value => setConfigurationEditable(configrecord, value)"
|
||||||
|
@keydown="e => handleInputNumberKeyDown(e, true)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</span>
|
</span>
|
||||||
@ -87,6 +89,7 @@
|
|||||||
@keydown.esc="editableValueKey = null"
|
@keydown.esc="editableValueKey = null"
|
||||||
@pressEnter="updateConfigurationValue(configrecord)"
|
@pressEnter="updateConfigurationValue(configrecord)"
|
||||||
@change="value => setConfigurationEditable(configrecord, value)"
|
@change="value => setConfigurationEditable(configrecord, value)"
|
||||||
|
@keydown="e => handleInputNumberKeyDown(e, true)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</a-col>
|
</a-col>
|
||||||
@ -350,6 +353,26 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.editableValueKey = null
|
this.editableValueKey = null
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
handleInputNumberKeyDown (event, isDecimal) {
|
||||||
|
const allowedCodes = ['Backspace', 'Delete', 'ArrowLeft', 'ArrowRight', 'Minus']
|
||||||
|
|
||||||
|
if (isDecimal) {
|
||||||
|
allowedCodes.push('Period')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
event.getModifierState('Control') ||
|
||||||
|
event.getModifierState('Meta') ||
|
||||||
|
event.getModifierState('Alt')
|
||||||
|
) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const isValid = allowedCodes.includes(event.code) || !isNaN(event.key)
|
||||||
|
if (!isValid) {
|
||||||
|
event.preventDefault()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user