This is an automated email from the ASF dual-hosted git repository.

scottyaslan pushed a commit to branch support/nifi-1.x
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/support/nifi-1.x by this push:
     new d8ac6bf8f9 This closes #7810
d8ac6bf8f9 is described below

commit d8ac6bf8f9f5286e6eec8c1f4fd184ef2544c12e
Author: Shane Ardell <[email protected]>
AuthorDate: Thu Sep 28 12:43:38 2023 -0400

    This closes #7810
    
    NIFI-12088: recalculate hidden property fields when new service is created
    
    Signed-off-by: Scott Aslan <[email protected]>
---
 .../jquery/propertytable/jquery.propertytable.js   | 182 +++++++++++----------
 1 file changed, 95 insertions(+), 87 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
index 013cbeb2eb..5fa3b224b4 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
@@ -1036,6 +1036,7 @@
 
             var controllerServiceLookup = new Map();
             var options = [];
+        
             $.each(response.controllerServiceTypes, function (i, 
controllerServiceType) {
                 controllerServiceLookup.set(i, controllerServiceType);
                 options.push({
@@ -1237,6 +1238,8 @@
                         if (typeof 
configurationOptions.controllerServiceCreatedDeferred === 'function') {
                             
configurationOptions.controllerServiceCreatedDeferred(response);
                         }
+                        
+                        toggleHiddenDependentProperties(gridContainer);
                     }).fail(nfErrorHandler.handleAjaxError);
                 };
 
@@ -1686,93 +1689,7 @@
                 nfCommon.cleanUpTooltips(table, 'div.fa-question-circle, 
div.fa-info');
             });
             propertyGrid.onBeforeCellEditorDestroy.subscribe(function (e, 
args) {
-                setTimeout(function() {
-                    var propertyData = propertyGrid.getData();
-
-                    // Get the default properties object
-                    var descriptors = table.data('descriptors');
-
-                    // Get the rows from the table
-                    var items = propertyData.getItems();
-
-                    // Loop over each row
-                    $.each(items, function (id, item) {
-                        // Get the property descriptor object
-                        var descriptor = descriptors[item.property];
-                        var dependent = false;
-
-                        // Check if descriptor is a dynamic property
-                        if (!descriptor.dynamic) {
-                            var hidden = false;
-
-                            // Check for dependencies
-                            if (descriptor.dependencies.length > 0) {
-                                // Loop over each dependency
-                                $.each(descriptor.dependencies, function (i, 
dependency) {
-                                    // It is sufficient to have found a single 
instance of not meeting the
-                                    // requirement for a dependent value in 
order to hide a property
-                                    if (hidden) {
-                                        return false;
-                                    }
-                                    // Check the row's dependent values 
against all other row's current values to determine hidden state
-                                    $.each(items, function (k, property) {
-                                        if (property.property === 
dependency.propertyName) {
-                                            dependent = true;
-                                            if (property.hidden === false) {
-                                                // Get the current property 
value to compare with the dependent value
-                                                var propertyValue = 
property.value;
-
-                                                // check if the property 
references a parameter
-                                                if 
(!_.isEmpty(currentParameters)) {
-                                                    const paramReference = 
getExistingParametersReferenced(propertyValue);
-                                                    // if parameter references 
exist, loop through all and interpolate the value in the propertyValue string
-                                                    if (paramReference.length 
> 0) {
-                                                        
paramReference.forEach(function (param) {
-                                                            // handle null 
values by replacing with an empty string instead
-                                                            propertyValue = 
propertyValue.replace('#{' + param.name + '}', 
nfCommon.isDefinedAndNotNull(param.value) ? param.value : '');
-                                                        });
-                                                    }
-                                                }
-
-                                                // Test the dependentValues 
array against the current value of the property
-                                                if (propertyValue) {
-                                                    if 
(dependency.dependentValues) {
-                                                        hidden = 
!dependency.dependentValues.includes(propertyValue);
-                                                    } else {
-                                                        hidden = false;
-                                                    }
-                                                } else {
-                                                    hidden = true;
-                                                }
-                                            } else {
-                                                hidden = true;
-                                            }
-                                            if (hidden) {
-                                                // It is sufficient to have 
found a single instance of not meeting the
-                                                // requirement for a dependent 
value in order to hide a property
-                                                return false;
-                                            }
-                                        }
-                                    });
-                                });
-                            }
-                        } else {
-                            hidden = item.hidden;
-                        }
-
-                        propertyData.beginUpdate();
-                        propertyData.updateItem(id, $.extend(item, {
-                            hidden: hidden,
-                            dependent: dependent
-                        }));
-                        propertyData.endUpdate();
-
-                        // Reset hidden property
-                        hidden = false;
-                    });
-
-                    propertyGrid.resizeCanvas();
-                }, 50);
+                toggleHiddenDependentProperties(table);
             });
         }
 
@@ -1828,6 +1745,97 @@
         });
     };
 
+    var toggleHiddenDependentProperties = function (gridContainer) {
+        setTimeout(function() {
+            var propertyGrid = gridContainer.data('gridInstance');
+            var propertyData = propertyGrid.getData();
+
+            // Get the default properties object
+            var descriptors = gridContainer.data('descriptors');
+
+            // Get the rows from the table
+            var items = propertyData.getItems();
+
+            // Loop over each row
+            $.each(items, function (id, item) {
+                // Get the property descriptor object
+                var descriptor = descriptors[item.property];
+                var dependent = false;
+
+                // Check if descriptor is a dynamic property
+                if (!descriptor.dynamic) {
+                    var hidden = false;
+
+                    // Check for dependencies
+                    if (descriptor.dependencies.length > 0) {
+                        // Loop over each dependency
+                        $.each(descriptor.dependencies, function (i, 
dependency) {
+                            // It is sufficient to have found a single 
instance of not meeting the
+                            // requirement for a dependent value in order to 
hide a property
+                            if (hidden) {
+                                return false;
+                            }
+                            // Check the row's dependent values against all 
other row's current values to determine hidden state
+                            $.each(items, function (k, property) {
+                                if (property.property === 
dependency.propertyName) {
+                                    dependent = true;
+                                    if (property.hidden === false) {
+                                        // Get the current property value to 
compare with the dependent value
+                                        var propertyValue = property.value;
+
+                                        // check if the property references a 
parameter
+                                        if (!_.isEmpty(currentParameters)) {
+                                            const paramReference = 
getExistingParametersReferenced(propertyValue);
+                                            // if parameter references exist, 
loop through all and interpolate the value in the propertyValue string
+                                            if (paramReference.length > 0) {
+                                                
paramReference.forEach(function (param) {
+                                                    // handle null values by 
replacing with an empty string instead
+                                                    propertyValue = 
propertyValue.replace('#{' + param.name + '}', 
nfCommon.isDefinedAndNotNull(param.value) ? param.value : '');
+                                                });
+                                            }
+                                        }
+
+                                        // Test the dependentValues array 
against the current value of the property
+                                        if (propertyValue) {
+                                            if (dependency.dependentValues) {
+                                                hidden = 
!dependency.dependentValues.includes(propertyValue);
+                                            } else {
+                                                hidden = false;
+                                            }
+                                        } else {
+                                            hidden = true;
+                                        }
+                                    } else {
+                                        hidden = true;
+                                    }
+                                    if (hidden) {
+                                        // It is sufficient to have found a 
single instance of not meeting the
+                                        // requirement for a dependent value 
in order to hide a property
+                                        return false;
+                                    }
+                                }
+                            });
+                        });
+                    }
+                } else {
+                    hidden = item.hidden;
+                }
+
+                propertyData.beginUpdate();
+                propertyData.updateItem(id, $.extend(item, {
+                    hidden: hidden,
+                    dependent: dependent
+                }));
+                propertyData.endUpdate();
+
+                // Reset hidden property
+                hidden = false;
+            });
+
+            propertyGrid.resizeCanvas();
+        }, 50);
+    }
+
     var saveRow = function (table) {
         // get the property grid to commit the current edit
         var propertyGrid = table.data('gridInstance');

Reply via email to