NIFI-159:

- Allowing optional properties to be reset.
- Used null to represent an unset value as previously it was considered undefined. When undefined, the property was not being included in the serialized configuration.
This commit is contained in:
Matt Gilman 2014-12-10 14:27:11 -05:00
parent cb2e855fc7
commit fe2a331820
5 changed files with 16 additions and 24 deletions

View File

@ -51,13 +51,15 @@ nf.ProcessorPropertyComboEditor = function (args) {
optionClass: 'unset' optionClass: 'unset'
}); });
} }
$.each(allowableValues, function (i, allowableValue) { if ($.isArray(allowableValues)) {
options.push({ $.each(allowableValues, function (i, allowableValue) {
text: allowableValue.displayName, options.push({
value: allowableValue.value, text: allowableValue.displayName,
description: nf.Common.escapeHtml(allowableValue.description) value: allowableValue.value,
description: nf.Common.escapeHtml(allowableValue.description)
});
}); });
}); }
// ensure the options there is at least one option // ensure the options there is at least one option
if (options.length === 0) { if (options.length === 0) {

View File

@ -160,18 +160,13 @@ nf.ProcessorPropertyNfelEditor = function (args) {
// otherwise if the property is required // otherwise if the property is required
if (nf.ProcessorPropertyTable.isRequiredProperty(propertyDescriptor)) { if (nf.ProcessorPropertyTable.isRequiredProperty(propertyDescriptor)) {
if (nf.Common.isBlank(propertyDescriptor.defaultValue)) { if (nf.Common.isBlank(propertyDescriptor.defaultValue)) {
// reset to the previous value if available return previousValue;
if (nf.Common.isDefinedAndNotNull(previousValue)) {
return previousValue;
} else {
return undefined;
}
} else { } else {
return propertyDescriptor.defaultValue; return propertyDescriptor.defaultValue;
} }
} else { } else {
// if the property is not required, clear the value // if the property is not required, clear the value
return undefined; return null;
} }
} }
} else { } else {

View File

@ -40,7 +40,7 @@ nf.ProcessorPropertyTable = (function () {
hidden: false, hidden: false,
property: propertyName, property: propertyName,
displayName: propertyName, displayName: propertyName,
previousValue: undefined, previousValue: null,
value: propertyValue, value: propertyValue,
type: 'userDefined' type: 'userDefined'
}); });
@ -377,7 +377,7 @@ nf.ProcessorPropertyTable = (function () {
if (nf.Common.isDefinedAndNotNull(propertyDescriptor)) { if (nf.Common.isDefinedAndNotNull(propertyDescriptor)) {
return propertyDescriptor.allowableValues; return propertyDescriptor.allowableValues;
} else { } else {
return undefined; return null;
} }
}, },
/** /**
@ -477,7 +477,7 @@ nf.ProcessorPropertyTable = (function () {
displayName = descriptor.displayName; displayName = descriptor.displayName;
// determine the value // determine the value
if (nf.Common.isUndefined(value) || nf.Common.isNull(value)) { if (nf.Common.isNull(value) && nf.Common.isDefinedAndNotNull(descriptor.defaultValue)) {
value = descriptor.defaultValue; value = descriptor.defaultValue;
} }
} }

View File

@ -169,18 +169,13 @@ nf.ProcessorPropertyTextEditor = function (args) {
// otherwise if the property is required // otherwise if the property is required
if (nf.ProcessorPropertyTable.isRequiredProperty(propertyDescriptor)) { if (nf.ProcessorPropertyTable.isRequiredProperty(propertyDescriptor)) {
if (nf.Common.isBlank(propertyDescriptor.defaultValue)) { if (nf.Common.isBlank(propertyDescriptor.defaultValue)) {
// reset to the previous value if available return previousValue;
if (nf.Common.isDefinedAndNotNull(previousValue)) {
return previousValue;
} else {
return undefined;
}
} else { } else {
return propertyDescriptor.defaultValue; return propertyDescriptor.defaultValue;
} }
} else { } else {
// if the property is not required, clear the value // if the property is not required, clear the value
return undefined; return null;
} }
} }
} else { } else {

View File

@ -476,7 +476,7 @@ nf.ProcessorDetails = (function () {
displayName = descriptor.displayName; displayName = descriptor.displayName;
// determine the value // determine the value
if (nf.Common.isUndefined(value) || nf.Common.isNull(value)) { if (nf.Common.isNull(value) && nf.Common.isDefinedAndNotNull(descriptor.defaultValue)) {
value = descriptor.defaultValue; value = descriptor.defaultValue;
} }
} }