diff options
author | Björn Schießle <bjoern@schiessle.org> | 2017-02-22 16:30:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-22 16:30:21 +0100 |
commit | 621f920d682c78b12b8a57abcf0d4af09a11757b (patch) | |
tree | d21a39b2edec56b32088755eb41ce17305ab353f /core | |
parent | a2e16fd5bada32559fca9450b4b635d7c0708668 (diff) | |
parent | 11e5a3dcf4767149a3f7e14deb8e684bb6500276 (diff) | |
download | nextcloud-server-621f920d682c78b12b8a57abcf0d4af09a11757b.tar.gz nextcloud-server-621f920d682c78b12b8a57abcf0d4af09a11757b.zip |
Merge pull request #3567 from nextcloud/autocomplete-settings
some sharing settings
Diffstat (limited to 'core')
-rw-r--r-- | core/css/share.scss | 5 | ||||
-rw-r--r-- | core/js/sharedialogview.js | 55 |
2 files changed, 52 insertions, 8 deletions
diff --git a/core/css/share.scss b/core/css/share.scss index 8852ad2748e..6d98dc74945 100644 --- a/core/css/share.scss +++ b/core/css/share.scss @@ -78,6 +78,11 @@ } } +.ui-autocomplete .autocomplete-note { + padding: 5px 10px; + color: rgba(0, 0, 0, .3); +} + #shareWithList { list-style-type: none; padding: 8px; diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index 60cd97fb572..a63960da2b8 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -130,18 +130,46 @@ }, autocompleteHandler: function (search, response) { - var view = this; - var $loading = this.$el.find('.shareWithLoading'); + var $shareWithField = $('.shareWithField'), + view = this, + $loading = this.$el.find('.shareWithLoading'), + $remoteShareInfo = this.$el.find('.shareWithRemoteInfo'); + + var count = oc_config['sharing.minSearchStringLength']; + if (search.term.trim().length < count) { + var title = n('core', + 'At least {count} character is needed for autocompletion', + 'At least {count} characters are needed for autocompletion', + count, + { count: count } + ); + $shareWithField.addClass('error') + .attr('data-original-title', title) + .tooltip('hide') + .tooltip({ + placement: 'bottom', + trigger: 'manual' + }) + .tooltip('fixTitle') + .tooltip('show'); + response(); + return; + } + $loading.removeClass('hidden'); $loading.addClass('inlineblock'); - var $remoteShareInfo = this.$el.find('.shareWithRemoteInfo'); $remoteShareInfo.addClass('hidden'); + + $shareWithField.removeClass('error') + .tooltip('hide'); + + var perPage = 200; $.get( OC.linkToOCS('apps/files_sharing/api/v1') + 'sharees', { format: 'json', search: search.term.trim(), - perPage: 200, + perPage: perPage, itemType: view.model.get('itemType') }, function (result) { @@ -232,16 +260,27 @@ var suggestions = users.concat(groups).concat(remotes).concat(emails).concat(lookup); if (suggestions.length > 0) { - $('.shareWithField').removeClass('error') - .tooltip('hide') + $shareWithField .autocomplete("option", "autoFocus", true); + response(suggestions); + + // show a notice that the list is truncated + // this is the case if one of the search results is at least as long as the max result config option + if(oc_config['sharing.maxAutocompleteResults'] > 0 && + Math.min(perPage, oc_config['sharing.maxAutocompleteResults']) + <= Math.max(users.length, groups.length, remotes.length, emails.length, lookup.length)) { + + var message = t('core', 'This list is maybe truncated - please refine your search term to see more results.'); + $('.ui-autocomplete').append('<li class="autocomplete-note">' + message + '</li>'); + } + } else { - var title = t('core', 'No users or groups found for {search}', {search: $('.shareWithField').val()}); + var title = t('core', 'No users or groups found for {search}', {search: $shareWithField.val()}); if (!view.configModel.get('allowGroupSharing')) { title = t('core', 'No users found for {search}', {search: $('.shareWithField').val()}); } - $('.shareWithField').addClass('error') + $shareWithField.addClass('error') .attr('data-original-title', title) .tooltip('hide') .tooltip({ |