From f4d4a5394bc45264d866ee508013c7267f603779 Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Oct 05 2018 08:28:41 +0000 Subject: [PATCH 1/3] Add a spinner when selectize is loading data. --- diff --git a/pagure/static/pagure.css b/pagure/static/pagure.css index 7b5a083..b43e464 100644 --- a/pagure/static/pagure.css +++ b/pagure/static/pagure.css @@ -349,3 +349,21 @@ th[data-sort] { .line-height-1{ line-height: 1em; } + + +.selectize-control:before{ + -webkit-animation: fa-spin 2s infinite linear; + animation: fa-spin 2s infinite linear; + content: '\f1ce'; + font-family: FontAwesome; + z-index: 2; + position: absolute; + display: block; + right: 34px; + top: 7px; + opacity: 0; +} + +.selectize-control.loading:before{ + opacity:0.4; +} From 6a36194cb6aac8eb29f32b81bee93888b33b343a Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Oct 05 2018 08:28:41 +0000 Subject: [PATCH 2/3] Fix the selectize call to return proper query results on PR assignee Fixes: #3471 --- diff --git a/pagure/templates/repo_pull_request.html b/pagure/templates/repo_pull_request.html index ad23d53..d42a502 100644 --- a/pagure/templates/repo_pull_request.html +++ b/pagure/templates/repo_pull_request.html @@ -1015,7 +1015,7 @@ $('#assignee').selectize({ if (!query.length) return callback(); $.getJSON( "{{ url_for('api_ns.api_users') }}", { - pattern: query.term + pattern: "*"+query+"*" }, function( data ) { callback( data.users.map(function(x) { return { user: x }; }) ); From 05c2286e3eda6b8e3b75a7179fa30d2c4efbe958 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 05 2018 08:28:41 +0000 Subject: [PATCH 3/3] Load user async when looking up assignee on issue Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index 5a381c1..666cae7 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -675,6 +675,25 @@ $(document).ready(function() { doUpload("{{ form.csrf_token.current_token }}", this.files); }); + $('.mainform #assignee').selectize({ + valueField: 'user', + labelField: 'user', + searchField: 'user', + maxItems: 1, + create: false, + load: function(query, callback) { + if (!query.length) return callback(); + $.getJSON( + "{{ url_for('api_ns.api_users') }}", { + pattern: "*"+query+"*" + }, + function( data ) { + callback( data.users.map(function(x) { return { user: x }; }) ); + } + ); + } + }); + $.get("{{ url_for('api_ns.api_users') }}", { pattern: '*' }).done(function(resp) { @@ -687,17 +706,6 @@ $(document).ready(function() { } $("#comment").atwho(userConfig); - $('.mainform #assignee').selectize({ - valueField: 'user', - labelField: 'user', - searchField: 'user', - maxItems: 1, - create: false, - load: function(query, callback) { - callback( resp.users.map(function(x) { return { user: x }; }) ); - } - }); - }); $.when($.get("{{ url_for('api_ns.api_view_issues', repo=repo.name,