]> source.dussan.org Git - nextcloud-server.git/commitdiff
Improve the UX for sharing settings
authorMorris Jobke <hey@morrisjobke.de>
Tue, 21 Feb 2017 23:07:07 +0000 (17:07 -0600)
committerMorris Jobke <hey@morrisjobke.de>
Tue, 21 Feb 2017 23:07:07 +0000 (17:07 -0600)
* shows a info when list is potentially truncated
* shows a warning when characters length is not enough

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
core/css/share.scss
core/js/sharedialogview.js
lib/private/Template/JSConfigHelper.php

index 8852ad2748ef311bd8d1790746a21f8e7cacdeb3..6d98dc749450d0cd4aa3acc529ffaf18bb772345 100644 (file)
        }
 }
 
+.ui-autocomplete .autocomplete-note {
+       padding: 5px 10px;
+       color: rgba(0, 0, 0, .3);
+}
+
 #shareWithList {
        list-style-type: none;
        padding: 8px;
index 60cd97fb5727979a7c71edd40e02fdd8377c1a83..bbc40c9c8d4423133670b3d7a2371c3c74916454 100644 (file)
                },
 
                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 are 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) {
                                                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(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({
index 1c241989fd2b373d9e76c7d4094a276393b3019d..7a4e8415e7d18216545eef0922cb4a42d7188f25 100644 (file)
@@ -206,7 +206,9 @@ class JSConfigHelper {
                                'versionstring'         => \OC_Util::getVersionString(),
                                'enable_avatars'        => true, // here for legacy reasons - to not crash existing code that relies on this value
                                'lost_password_link'=> $this->config->getSystemValue('lost_password_link', null),
-                               'modRewriteWorking'     => (\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'),
+                               'modRewriteWorking'     => ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'),
+                               'sharing.maxAutocompleteResults' => $this->config->getSystemValue('sharing.maxAutocompleteResults', 0),
+                               'sharing.minSearchStringLength' => $this->config->getSystemValue('sharing.minSearchStringLength', 0),
                        ]),
                        "oc_appconfig" => json_encode([
                                'core' => [