use displayname lookup route in files_external settings
This commit is contained in:
parent
91ba1b345e
commit
6202ef3258
|
@ -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'), {
|
||||
$.ajax(OC.generateUrl('displaynames'), {
|
||||
data: {
|
||||
pattern: userId
|
||||
users: element.val().split(",")
|
||||
},
|
||||
dataType: "json"
|
||||
}).done(function(data) {
|
||||
var results = [];
|
||||
if (data.status === "success") {
|
||||
if (data.users[userId]) {
|
||||
results.push({name:userId, displayname:data.users[userId], type:'user'});
|
||||
$.each(data.users, function(user, displayname) {
|
||||
if (displayname !== false) {
|
||||
results.push({name:user, displayname:displayname, type:'user'});
|
||||
}
|
||||
def.resolve();
|
||||
});
|
||||
callback(results);
|
||||
} else {
|
||||
//FIXME add error handling
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$.when.apply(undefined, promises).then(function(){
|
||||
callback(results);
|
||||
});
|
||||
},
|
||||
id: function(element) {
|
||||
return element.name;
|
||||
|
|
Loading…
Reference in New Issue