diff options
Diffstat (limited to 'core/js/sharedialogview.js')
-rw-r--r-- | core/js/sharedialogview.js | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index 4cebf7962e8..e7435877cb3 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -67,6 +67,10 @@ /** @type {object} **/ shareeListView: undefined, + events: { + 'input .shareWithField': 'onShareWithFieldChanged' + }, + initialize: function(options) { var view = this; @@ -109,7 +113,18 @@ : options[name]; } - _.bindAll(this, 'autocompleteHandler', '_onSelectRecipient'); + _.bindAll(this, + 'autocompleteHandler', + '_onSelectRecipient', + 'onShareWithFieldChanged' + ); + }, + + onShareWithFieldChanged: function() { + var $el = this.$el.find('.shareWithField'); + if ($el.val().length < 2) { + $el.removeClass('error').tooltip('hide'); + } }, autocompleteHandler: function (search, response) { @@ -196,9 +211,20 @@ var suggestions = users.concat(groups).concat(remotes); if (suggestions.length > 0) { - $('.shareWithField').autocomplete("option", "autoFocus", true); + $('.shareWithField').removeClass('error') + .tooltip('hide') + .autocomplete("option", "autoFocus", true); response(suggestions); } else { + $('.shareWithField').addClass('error') + .attr('data-original-title', t('core', 'No users or groups found for {search}', {search: $('.shareWithField').val()})) + .tooltip('hide') + .tooltip({ + placement: 'bottom', + trigger: 'manual', + }) + .tooltip('fixTitle') + .tooltip('show'); response(); } } else { @@ -217,9 +243,20 @@ var insert = $("<a>"); var text = item.label; if (item.value.shareType === OC.Share.SHARE_TYPE_GROUP) { - text = text + ' ('+t('core', 'group')+')'; + text = t('core', '{sharee} (group)', { + sharee: text + }); } else if (item.value.shareType === OC.Share.SHARE_TYPE_REMOTE) { - text = text + ' ('+t('core', 'remote')+')'; + if (item.value.server) { + text = t('core', '{sharee} (at {server})', { + sharee: text, + server: item.value.server + }); + } else { + text = t('core', '{sharee} (remote)', { + sharee: text + }); + } } insert.text(text); if(item.value.shareType === OC.Share.SHARE_TYPE_GROUP) { @@ -233,8 +270,18 @@ _onSelectRecipient: function(e, s) { e.preventDefault(); - $(e.target).val(''); - this.model.addShare(s.item.value); + $(e.target).attr('disabled', true) + .val(s.item.label); + var $loading = this.$el.find('.shareWithLoading'); + $loading.removeClass('hidden') + .addClass('inlineblock'); + + this.model.addShare(s.item.value, {success: function() { + $(e.target).val('') + .attr('disabled', false); + $loading.addClass('hidden') + .removeClass('inlineblock'); + }}); }, _toggleLoading: function(state) { |