From e37f9c83515a7d691fc4ddb2ff6b5a57fb1a7b70 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 22 Aug 2014 16:07:48 +0200 Subject: [PATCH] use displayname lookup route in files_external settings --- apps/files_external/js/settings.js | 45 ++++++++++-------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js index 7ea82f4bcb3..cfbd3751ac4 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -233,41 +233,24 @@ $(document).ready(function() { } }, initSelection: function(element, callback) { - - var promises = []; - - var results = []; - - $(element.val().split(",")).each(function (i,userId) { - var def = new $.Deferred(); - promises.push(def.promise()); - - var pos = userId.indexOf('(group)'); - if (pos !== -1) { - //add as group - results.push({name:userId, displayname:userId.substr(0, pos), type:'group'}); - def.resolve(); - } else { - $.ajax(OC.generateUrl('apps/files_external/applicable'), { - data: { - pattern: userId - }, - dataType: "json" - }).done(function(data) { - if (data.status === "success") { - if (data.users[userId]) { - results.push({name:userId, displayname:data.users[userId], type:'user'}); - } - def.resolve(); - } else { - //FIXME add error handling + $.ajax(OC.generateUrl('displaynames'), { + data: { + users: element.val().split(",") + }, + dataType: "json" + }).done(function(data) { + var results = []; + if (data.status === "success") { + $.each(data.users, function(user, displayname) { + if (displayname !== false) { + results.push({name:user, displayname:displayname, type:'user'}); } }); + callback(results); + } else { + //FIXME add error handling } }); - $.when.apply(undefined, promises).then(function(){ - callback(results); - }); }, id: function(element) { return element.name; -- 2.39.5