You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2015/04/10 17:36:32 UTC
incubator-nifi git commit: NIFI-497: - Requiring new property names
to be unique.
Repository: incubator-nifi
Updated Branches:
refs/heads/develop 322be256b -> 9299355ae
NIFI-497:
- Requiring new property names to be unique.
Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/9299355a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/9299355a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/9299355a
Branch: refs/heads/develop
Commit: 9299355ae9fe31d47824acab21aa02fc92c5d897
Parents: 322be25
Author: Matt Gilman <ma...@gmail.com>
Authored: Fri Apr 10 11:30:54 2015 -0400
Committer: Matt Gilman <ma...@gmail.com>
Committed: Fri Apr 10 11:30:54 2015 -0400
----------------------------------------------------------------------
.../propertytable/jquery.propertytable.js | 74 +++++++++++++-------
1 file changed, 48 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9299355a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
index b5f56b0..7ffaa3f 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
@@ -1375,37 +1375,59 @@
var add = function () {
var propertyName = $.trim(newPropertyNameField.val());
- // ensure the property name and value is specified
+ // ensure the property name is specified
if (propertyName !== '') {
- // load the descriptor and add the property
- options.descriptorDeferred(propertyName).done(function(response) {
- var descriptor = response.propertyDescriptor;
-
- // store the descriptor for use later
- var descriptors = table.data('descriptors');
- if (!nf.Common.isUndefined(descriptors)) {
- descriptors[descriptor.name] = descriptor;
+ var propertyGrid = table.data('gridInstance');
+ var propertyData = propertyGrid.getData();
+
+ // ensure the property name is unique
+ var existingPropertyId = null;
+ $.each(propertyData.getItems(), function (_, item) {
+ if (propertyName === item.property) {
+ existingPropertyId = item.id;
+ return false;
}
-
- // add a row for the new property
- var propertyGrid = table.data('gridInstance');
- var propertyData = propertyGrid.getData();
- var id = propertyData.getLength();
- propertyData.addItem({
- id: id,
- hidden: false,
- property: propertyName,
- displayName: propertyName,
- previousValue: null,
- value: null,
- type: 'userDefined'
+ });
+
+ if (existingPropertyId === null) {
+ // load the descriptor and add the property
+ options.descriptorDeferred(propertyName).done(function(response) {
+ var descriptor = response.propertyDescriptor;
+
+ // store the descriptor for use later
+ var descriptors = table.data('descriptors');
+ if (!nf.Common.isUndefined(descriptors)) {
+ descriptors[descriptor.name] = descriptor;
+ }
+
+ // add a row for the new property
+ var id = propertyData.getLength();
+ propertyData.addItem({
+ id: id,
+ hidden: false,
+ property: propertyName,
+ displayName: propertyName,
+ previousValue: null,
+ value: null,
+ type: 'userDefined'
+ });
+
+ // select the new properties row
+ var row = propertyData.getRowById(id);
+ propertyGrid.setSelectedRows([row]);
+ propertyGrid.scrollRowIntoView(row);
});
-
- // select the new properties row
- var row = propertyData.getRowById(id);
+ } else {
+ nf.Dialog.showOkDialog({
+ dialogContent: 'A property with this name already exists.',
+ overlayBackground: false
+ });
+
+ // select the existing properties row
+ var row = propertyData.getRowById(existingPropertyId);
propertyGrid.setSelectedRows([row]);
propertyGrid.scrollRowIntoView(row);
- });
+ }
} else {
nf.Dialog.showOkDialog({
dialogContent: 'Property name must be specified.',