mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
B OpenNebula/one#6485: Behavior of non required text (#3025)
fields when update Signed-off-by: David Carracedo <dcarracedo@opennebula.io> Co-authored-by: Tino Vázquez <cvazquez@opennebula.io>
This commit is contained in:
parent
87862523e2
commit
cfe1be8641
@ -62,7 +62,8 @@ const TextController = memo(
|
||||
const handleChange = useCallback(
|
||||
(e) => {
|
||||
onBlur()
|
||||
const condition = e.target.value
|
||||
// Empty string it's undefined value (this way, a number input that is no mandatory could have empty value)
|
||||
const condition = e.target.value === '' ? undefined : e.target.value
|
||||
onChange(condition)
|
||||
if (typeof onConditionChange === 'function') {
|
||||
onConditionChange(condition)
|
||||
|
@ -157,8 +157,9 @@ export const MEMORY_COST = generateCostCapacityInput({
|
||||
fieldProps: ([memory, cost] = []) => {
|
||||
const fieldProps = { step: 0.1 }
|
||||
|
||||
if (memory && cost) {
|
||||
const monthCost = formatNumberByCurrency(memory * cost * 24 * 30)
|
||||
if (memory) {
|
||||
const monthCost = formatNumberByCurrency(memory * (cost || 0) * 24 * 30)
|
||||
|
||||
fieldProps.helperText = (
|
||||
<Translate word={T.CostEachMonth} values={[monthCost]} />
|
||||
)
|
||||
@ -178,8 +179,8 @@ export const CPU_COST = generateCostCapacityInput({
|
||||
fieldProps: ([cpu, cost] = []) => {
|
||||
const fieldProps = { step: 0.1 }
|
||||
|
||||
if (cpu && cost) {
|
||||
const monthCost = formatNumberByCurrency(cpu * cost * 24 * 30)
|
||||
if (cpu) {
|
||||
const monthCost = formatNumberByCurrency(cpu * (cost || 0) * 24 * 30)
|
||||
fieldProps.helperText = (
|
||||
<Translate word={T.CostEachMonth} values={[monthCost]} />
|
||||
)
|
||||
|
@ -205,11 +205,7 @@ const reduceGeneral = (
|
||||
Object.entries(correctionMap || {}).forEach(([key, correction]) => {
|
||||
if (correction && typeof correction === 'object' && correction.__delete__) {
|
||||
delete newGeneral[key]
|
||||
} else if (
|
||||
correction &&
|
||||
key in formData &&
|
||||
(!_.isEmpty(formData[key]) || formData[key] !== null)
|
||||
) {
|
||||
} else if (correction) {
|
||||
// If the correction is boolean, means that the user changed this value that is a simple value
|
||||
// If the correction is an object with an attribute delete means that is a hidden field that was deleted because the user change the value of its parent
|
||||
// If the correction is an object without an attribute delete means that is a field with an object instead a simple value and the user changed its value
|
||||
@ -434,10 +430,13 @@ const handleNetwork = (
|
||||
)
|
||||
}
|
||||
|
||||
// Delete keys on existing data that are marked to delete and not exists on formData
|
||||
// Delete keys on existing data that are marked to delete and not exists on formData or are marked to update and not exists on formData
|
||||
if (wrappedExistingData && wrappedExistingData[index])
|
||||
Object.entries(itemModifications)
|
||||
.filter(([key, value]) => value.__delete__ && !item[key])
|
||||
.filter(
|
||||
([key, value]) =>
|
||||
(value.__delete__ && !item[key]) || (value && !item[key])
|
||||
)
|
||||
.forEach(
|
||||
([key, value]) =>
|
||||
wrappedExistingData[index][key] &&
|
||||
|
Loading…
Reference in New Issue
Block a user