1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-09 10:50:24 +00:00

[share] modified 'contacts' input in file/dir private share

This commit is contained in:
llj
2015-04-29 12:04:46 +08:00
parent 2c6994c56a
commit fb0c5ed09f
2 changed files with 35 additions and 4 deletions

View File

@@ -2287,7 +2287,7 @@ def set_user_folder_perm(request, repo_id):
content_type = 'application/json; charset=utf-8'
if not (is_pro_version() and ENABLE_FOLDER_PERM):
return HttpResponse(json.dumps({"error": True}),
return HttpResponse(json.dumps({"error": _(u"Permission denied")}),
status=403, content_type=content_type)
user = request.POST.get('user', None)

View File

@@ -409,19 +409,34 @@ define([
var form = this.$('#file-private-share-form');
loading_tip.show();
var contacts = app.pageOptions.contacts || [];
$('[name="emails"]', form).select2({
placeholder: gettext("Select contacts or input"),
width: '400px',
// with 'tags', the user can directly enter, not just select
// tags need `<input type="hidden" />`, not `<select>`
tags: function () {
var contacts = app.pageOptions.contacts || [];
var contact_list = [];
for (var i = 0, len = contacts.length; i < len; i++) {
contact_list.push(contacts[i].email);
contact_list.push({ // 'id' & 'text' are required by the plugin
"id": contacts[i].email,
"text": contacts[i].email,
"avatar": contacts[i].avatar,
"name": contacts[i].name
});
}
return contact_list;
},
formatResult: function(item) { // format items shown in the drop-down menu
if (item.avatar) {
return item.avatar + '<span class="text">' + item.name + '<br />' + item.text + '</span>';
} else {
return; // if no match, show nothing
}
},
formatSelection: function(item) { // format selected item shown in the input
return item.name || item.text; // if no name, show the email, i.e., when directly input, show the email
},
tokenSeparators: [',', ' '],
escapeMarkup: function(m) { return m; }
});
@@ -479,12 +494,28 @@ define([
placeholder: gettext("Select contacts or input"),
width: '400px',
tags: function () {
var contacts = app.pageOptions.contacts || [];
var contact_list = [];
for (var i = 0, len = contacts.length; i < len; i++) {
contact_list.push(contacts[i].email);
contact_list.push({ // 'id' & 'text' are required by the plugin
"id": contacts[i].email,
"text": contacts[i].email,
"avatar": contacts[i].avatar,
"name": contacts[i].name
});
}
return contact_list;
},
formatResult: function(item) { // format items shown in the drop-down menu
if (item.avatar) {
return item.avatar + '<span class="text">' + item.name + '<br />' + item.text + '</span>';
} else {
return; // if no match, show nothing
}
},
formatSelection: function(item) { // format selected item shown in the input
return item.name || item.text; // if no name, show the email, i.e., when directly input, show the email
},
tokenSeparators: [',', ' '],
escapeMarkup: function(m) { return m; }
});