summaryrefslogtreecommitdiffstats
path: root/core/js/sharedialogview.js
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-10-26 13:46:24 +0200
committerJulius Härtl <jus@bitgrid.net>2018-10-30 10:19:36 +0100
commitf116461d4b435b28cd62c3c121a33108e8812e56 (patch)
tree1a874643935d65a061cfdf94095d3daa60605c60 /core/js/sharedialogview.js
parente8e898ede8b7655f9c4e61834d2a038b009bc6cb (diff)
downloadnextcloud-server-f116461d4b435b28cd62c3c121a33108e8812e56.tar.gz
nextcloud-server-f116461d4b435b28cd62c3c121a33108e8812e56.zip
Show one share method per contact for inaccurate results
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'core/js/sharedialogview.js')
-rw-r--r--core/js/sharedialogview.js38
1 files changed, 30 insertions, 8 deletions
diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js
index cd7f07011c3..c255152e666 100644
--- a/core/js/sharedialogview.js
+++ b/core/js/sharedialogview.js
@@ -325,16 +325,30 @@
return (aProperty < bProperty) ? -1 : (aProperty > bProperty) ? 1 : 0;
}
}
+
+ /**
+ * Sort share entries by uuid to properly group them
+ */
var grouped = suggestions.sort(dynamicSort('uuid'));
- console.log(grouped);
+
var previousUuid = null;
- groupedLength = grouped.length;
+ var groupedLength = grouped.length;
+ var result = [];
+ /**
+ * build the result array that only contains all contact entries from
+ * merged contacts, if the search term matches its contact name
+ */
for (i = 0; i < groupedLength; i++) {
+ console.log(grouped[i]);
if (typeof grouped[i].uuid !== 'undefined' && grouped[i].uuid === previousUuid) {
grouped[i].merged = true;
} else {
grouped[i].merged = false;
}
+ if (searchTerm === grouped[i].name || grouped[i].merged === false) {
+ result.push(grouped[i]);
+ } else {
+ }
previousUuid = grouped[i].uuid;
}
var moreResultsAvailable =
@@ -353,7 +367,7 @@
)
);
- deferred.resolve(grouped, exactMatches, moreResultsAvailable);
+ deferred.resolve(result, exactMatches, moreResultsAvailable);
} else {
deferred.reject(result.ocs.meta.message);
}
@@ -468,6 +482,9 @@
autocompleteRenderItem: function(ul, item) {
var icon = 'icon-user';
var text = item.label;
+ if (typeof item.name !== 'undefined') {
+ text = item.name;
+ }
if (item.value.shareType === OC.Share.SHARE_TYPE_GROUP) {
icon = 'icon-contacts-dark';
} else if (item.value.shareType === OC.Share.SHARE_TYPE_REMOTE) {
@@ -496,13 +513,10 @@
return type;
}
};
- if (typeof item.type !== 'undefined') {
+ if (typeof item.type !== 'undefined' && item.type !== null) {
description = getTranslatedType(item.type);
}
var insert = $("<div class='share-autocomplete-item'/>");
- if (description !== '') {
- insert.addClass('with-description');
- }
if (item.merged) {
insert.addClass('merged');
text = item.value.shareWith;
@@ -516,6 +530,10 @@
}
avatar.imageplaceholder(item.uuid, text, 32);
}
+ description = item.value.shareWith;
+ }
+ if (description !== '') {
+ insert.addClass('with-description');
}
$("<div class='autocomplete-item-text'></div>")
@@ -541,7 +559,11 @@
if (e.keyCode == 9) {
e.preventDefault();
- e.target.value = s.item.label;
+ if (typeof s.item.name !== 'undefined') {
+ e.target.value = s.item.name;
+ } else {
+ e.target.value = s.item.label;
+ }
setTimeout(function() {
$(e.target).attr('disabled', false)
.autocomplete('search', $(e.target).val());