]> source.dussan.org Git - nextcloud-server.git/commitdiff
use displayname lookup route in files_external settings
authorJörn Friedrich Dreyer <jfd@butonic.de>
Fri, 22 Aug 2014 14:07:48 +0000 (16:07 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Thu, 23 Apr 2015 12:23:17 +0000 (14:23 +0200)
apps/files_external/js/settings.js

index 7ea82f4bcb31c175edfd8daf3499c569bb090f7e..cfbd3751ac4998d12404ab067dc9e808dc3e0397 100644 (file)
@@ -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;