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

mcgilman pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 5016eac  NIFI-9205 - Update prioritizer configuration (#5516)
5016eac is described below

commit 5016eac0105923a852634748d6922a4ab864e3a8
Author: M Tien <[email protected]>
AuthorDate: Wed Nov 17 10:55:02 2021 -0800

    NIFI-9205 - Update prioritizer configuration (#5516)
    
    * NIFI-9205 - Update prioritizer configuration
    
    * - Address review feedback
    
    This closes #5516
---
 .../partials/canvas/connection-configuration.jsp   |  2 +-
 .../main/webapp/css/connection-configuration.css   | 10 ++-
 .../js/nf/canvas/nf-connection-configuration.js    | 92 +++++++++++++++++++++-
 .../webapp/js/nf/canvas/nf-parameter-contexts.js   |  2 +-
 4 files changed, 99 insertions(+), 7 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/connection-configuration.jsp
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/connection-configuration.jsp
index ffa4733..4289083 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/connection-configuration.jsp
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/connection-configuration.jsp
@@ -104,7 +104,7 @@
                             <div class="fa fa-question-circle" alt="Info" 
title="Available prioritizers that could reprioritize FlowFiles in this work 
queue."></div>
                         </div>
                         <div class="setting-field">
-                            <ul id="prioritizer-available"></ul>
+                            <ol id="prioritizer-available"></ol>
                         </div>
                     </div>
                     <div class="setting">
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/connection-configuration.css
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/connection-configuration.css
index b18da8d..94ae63b 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/connection-configuration.css
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/connection-configuration.css
@@ -122,4 +122,12 @@ div.undefined {
     line-height: 32px;
     height: 32px;
     padding: 0px 10px;
-}
\ No newline at end of file
+}
+
+#prioritizer-selected .draggable-control {
+    float: right;
+}
+
+#prioritizer-selected .fa-remove {
+    color: #fff;
+}
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js
index 83871db..ff70841 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js
@@ -1197,7 +1197,11 @@
         // reset the prioritizers
         var selectedList = $('#prioritizer-selected');
         var availableList = $('#prioritizer-available');
-        selectedList.children().detach().appendTo(availableList);
+        selectedList.children()
+            .detach()
+            .appendTo(availableList)
+            .find('div.draggable-control')
+            .remove();
 
         // sort the available list
         var listItems = availableList.children('li').get();
@@ -1340,16 +1344,56 @@
                     
nfConnectionConfiguration.addAvailablePrioritizer('#prioritizer-available', 
documentedType);
                 });
 
+                // work around for https://bugs.jqueryui.com/ticket/6054
+                var shouldAllowDrop = true;
+
                 // make the prioritizer containers sortable
-                $('#prioritizer-available, #prioritizer-selected').sortable({
+                $('#prioritizer-available').sortable({
                     containment: 
$('#connection-settings-tab-content').find('.settings-right'),
                     connectWith: 'ul',
                     placeholder: 'ui-state-highlight',
                     scroll: true,
-                    opacity: 0.6
+                    opacity: 0.6,
+                    beforeStop: function (event, ui) {
+                        if 
($('#prioritizer-available').find('.ui-sortable-placeholder').length) {
+                            shouldAllowDrop = false;
+                        }
+                    },
+                    stop: function (event, ui) {
+                        const allowDrop = shouldAllowDrop;
+                        shouldAllowDrop = true;
+                        return allowDrop;
+                    }
                 });
+
+                $('#prioritizer-selected').sortable({
+                    containment: 
$('#connection-settings-tab-content').find('.settings-right'),
+                    placeholder: 'selected',
+                    scroll: true,
+                    opacity: 0.6,
+                    receive: function (event, ui) {
+                        
nfConnectionConfiguration.addControlsForSelectedPrioritizer(ui.item);
+                    },
+                    update: function (event, ui) {
+                        // update the buttons to possibly trigger the disabled 
state
+                        $('#connection-configuration').modal('refreshButtons');
+                    }
+                });
+
                 $('#prioritizer-available, 
#prioritizer-selected').disableSelection();
+
+                // add a listener that will handle dblclick for all available 
prioritizers
+                $(document).on('dblclick', '#prioritizer-available li', 
function() {
+                    var availablePrioritizerElement = 
$(this).detach().appendTo($('#prioritizer-selected'));
+
+                    
nfConnectionConfiguration.addControlsForSelectedPrioritizer(availablePrioritizerElement);
+
+                    // update the buttons to possibly trigger the disabled 
state
+                    $('#connection-configuration').modal('refreshButtons');
+                });
             }).fail(nfErrorHandler.handleAjaxError);
+
+            nfConnectionConfiguration.sortAvailablePrioritizers();
         },
 
         /**
@@ -1375,6 +1419,44 @@
         },
 
         /**
+         * Sorts the available prioritizers.
+         */
+        sortAvailablePrioritizers: function () {
+            var availablePrioritizersList = $('#prioritizer-available');
+            availablePrioritizersList.children('li')
+                .detach()
+                .sort(function (aElement, bElement) {
+                    var nameA = $(aElement).text();
+                    var nameB = $(bElement).text();
+                    return nameA.localeCompare(nameB);
+                })
+                .appendTo(availablePrioritizersList);
+        },
+
+        /**
+         * Adds the controls to the specified selected draggable element.
+         *
+         * @argument {jQuery} draggableElement
+         */
+        addControlsForSelectedPrioritizer: function (draggableElement) {
+            var removeIcon = $('<div class="draggable-control"><div class="fa 
fa-remove"></div></div>')
+                .on('click', function () {
+                    // remove the remove icon
+                    removeIcon.remove();
+
+                    // restore to the available parameter contexts
+                    $('#prioritizer-available').append(draggableElement);
+
+                    // resort the available parameter contexts
+                    nfConnectionConfiguration.sortAvailablePrioritizers();
+
+                    // update the buttons to possibly trigger the disabled 
state
+                    $('#connection-configuration').modal('refreshButtons');
+                })
+                .appendTo(draggableElement);
+        },
+
+        /**
          * Shows the dialog for creating a new connection.
          *
          * @argument {string} sourceId      The source id
@@ -1526,7 +1608,9 @@
 
                     // handle each prioritizer
                     $.each(connection.prioritizers, function (i, type) {
-                        $('#prioritizer-available').children('li[id="' + type 
+ '"]').detach().appendTo('#prioritizer-selected');
+                        var selectedPrioritizer = 
$('#prioritizer-available').children('li[id="' + type + '"]');
+                        
nfConnectionConfiguration.addControlsForSelectedPrioritizer(selectedPrioritizer);
+                        
selectedPrioritizer.detach().appendTo('#prioritizer-selected');
                     });
 
                     // store the connection details
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-parameter-contexts.js
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-parameter-contexts.js
index 6ec550d..146b627 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-parameter-contexts.js
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-parameter-contexts.js
@@ -1774,7 +1774,7 @@
     var addControlsForSelectedParameterContext = function (draggableElement) {
         var removeIcon = $('<div class="draggable-control"><div class="fa 
fa-remove"></div></div>')
             .on('click', function () {
-                // remove the remove ice
+                // remove the remove icon
                 removeIcon.remove();
 
                 // restore to the available parameter contexts

Reply via email to