NIFI-12972 - Only show selected relationships in read-only connection details (#8582)

* NIFI-12972 - Only show selected relationships in read-only connection details

* review

This closes #8582
This commit is contained in:
Pierre Villard 2024-04-04 01:50:17 +03:00 committed by GitHub
parent 88d434f9ec
commit 644d086ff2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 22 deletions

View File

@ -38,8 +38,7 @@
</div> </div>
<div id="read-only-relationship-names-container" class="setting"> <div id="read-only-relationship-names-container" class="setting">
<div class="setting-name"> <div class="setting-name">
Relationships Selected relationships
<div class="fa fa-question-circle" alt="Info" title="Selected relationships are in bold."></div>
</div> </div>
<div class="setting-field"> <div class="setting-field">
<div id="read-only-relationship-names"></div> <div id="read-only-relationship-names"></div>

View File

@ -370,7 +370,7 @@
* @argument {string} name The relationship name * @argument {string} name The relationship name
*/ */
var createRelationshipOption = function (name) { var createRelationshipOption = function (name) {
$('<div class="available-relationship-container"></div>').append( return $('<div class="available-relationship-container"></div>').append(
$('<div class="relationship-name"></div>').text(name)).appendTo('#read-only-relationship-names'); $('<div class="relationship-name"></div>').text(name)).appendTo('#read-only-relationship-names');
}; };
@ -496,30 +496,17 @@
var availableRelationships = connection.availableRelationships; var availableRelationships = connection.availableRelationships;
var selectedRelationships = connection.selectedRelationships; var selectedRelationships = connection.selectedRelationships;
// show the available relationship if applicable // show the selected relationships if applicable
if (nfCommon.isDefinedAndNotNull(availableRelationships) || nfCommon.isDefinedAndNotNull(selectedRelationships)) { if (nfCommon.isDefinedAndNotNull(availableRelationships) || nfCommon.isDefinedAndNotNull(selectedRelationships)) {
// populate the available connections // populate the selected connections
$.each(availableRelationships, function (i, name) {
createRelationshipOption(name);
});
// ensure all selected relationships are present
// (may be undefined) and selected
$.each(selectedRelationships, function (i, name) { $.each(selectedRelationships, function (i, name) {
// mark undefined relationships accordingly // mark undefined relationships accordingly
if ($.inArray(name, availableRelationships) === -1) { if ($.inArray(name, availableRelationships) === -1) {
var option = createRelationshipOption(name); var option = createRelationshipOption(name);
$(option).children('div.relationship-name').addClass('undefined'); $(option).children('div.relationship-name').addClass('undefined');
} else {
createRelationshipOption(name);
} }
// ensure all selected relationships are bold
var relationships = $('#read-only-relationship-names').children('div');
$.each(relationships.children('div.relationship-name'), function (i, relationshipNameElement) {
var relationshipName = $(relationshipNameElement);
if (relationshipName.text() === name) {
relationshipName.css('font-weight', 'bold');
}
});
}); });
$('#selected-relationship-text').show(); $('#selected-relationship-text').show();