Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for safari issue in autocomplete search #1182

Merged
merged 3 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/portal/public/lib/controllers/controller.groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ angular.module('controller.groups', []).controller('GroupsController', function
},
minLength: 1,
select: function (event, ui) {
$scope.query = ui.item.value;
$("#group-search-text").val(ui.item.value);
return false;
},
Expand Down
64 changes: 33 additions & 31 deletions modules/portal/public/lib/recordset/recordsets.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,39 @@
var recordType = [];
var recordName = [];

$( "#record-search-text" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: "/api/recordsets?maxItems=100",
dataType: "json",
data: "recordNameFilter="+request.term+"%25&nameSort=asc",
success: function( data ) {
const recordSearch = JSON.parse(JSON.stringify(data));
response($.map(recordSearch.recordSets, function(item) {
return {value: item.fqdn +' | '+ item.type , label: 'name: ' + item.fqdn + ' | type: ' + item.type }}))}
});
},
minLength: 2,
select: function (event, ui) {
$scope.query = ui.item.value;
$("#record-search-text").val(ui.item.value);
return false;
},
open: function() {
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function() {
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
}
});

$.ui.autocomplete.prototype._renderItem = function( ul, item ) {
let recordSet = String(item.label).replace(new RegExp(this.term, "gi"),"<b>$&</b>");
return $("<li></li>")
.data("ui-autocomplete-item", item.value)
.append("<div>" + recordSet + "</div>")
.appendTo(ul); };

$scope.refreshRecords = function() {
if($scope.query.includes("|")) {
const queryRecord = $scope.query.split('|');
Expand Down Expand Up @@ -88,37 +121,6 @@
}
};

$( "#record-search-text" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: "/api/recordsets?maxItems=100",
dataType: "json",
data: "recordNameFilter="+request.term+"%25&nameSort=asc",
success: function( data ) {
const recordSearch = JSON.parse(JSON.stringify(data));
response($.map(recordSearch.recordSets, function(item) {
return {value: item.fqdn +' | '+ item.type , label: 'name: ' + item.fqdn + ' | type: ' + item.type }}))}
});
},
minLength: 2,
select: function (event, ui) {
$("#record-search-text").val(ui.item.value);
return false;
},
open: function() {
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function() {
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
}
});

$.ui.autocomplete.prototype._renderItem = function( ul, item ) {
let recordSet = String(item.label).replace(new RegExp(this.term, "gi"),"<b>$&</b>");
return $("<li></li>")
.data("ui-autocomplete-item", item.value)
.append("<div>" + recordSet + "</div>")
.appendTo(ul); };

function updateRecordDisplay(records) {
var newRecords = [];
Expand Down