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:
@@ -2287,7 +2287,7 @@ def set_user_folder_perm(request, repo_id):
|
|||||||
content_type = 'application/json; charset=utf-8'
|
content_type = 'application/json; charset=utf-8'
|
||||||
|
|
||||||
if not (is_pro_version() and ENABLE_FOLDER_PERM):
|
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)
|
status=403, content_type=content_type)
|
||||||
|
|
||||||
user = request.POST.get('user', None)
|
user = request.POST.get('user', None)
|
||||||
|
@@ -409,19 +409,34 @@ define([
|
|||||||
var form = this.$('#file-private-share-form');
|
var form = this.$('#file-private-share-form');
|
||||||
loading_tip.show();
|
loading_tip.show();
|
||||||
|
|
||||||
var contacts = app.pageOptions.contacts || [];
|
|
||||||
$('[name="emails"]', form).select2({
|
$('[name="emails"]', form).select2({
|
||||||
placeholder: gettext("Select contacts or input"),
|
placeholder: gettext("Select contacts or input"),
|
||||||
width: '400px',
|
width: '400px',
|
||||||
// with 'tags', the user can directly enter, not just select
|
// with 'tags', the user can directly enter, not just select
|
||||||
// tags need `<input type="hidden" />`, not `<select>`
|
// tags need `<input type="hidden" />`, not `<select>`
|
||||||
tags: function () {
|
tags: function () {
|
||||||
|
var contacts = app.pageOptions.contacts || [];
|
||||||
var contact_list = [];
|
var contact_list = [];
|
||||||
for (var i = 0, len = contacts.length; i < len; i++) {
|
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;
|
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: [',', ' '],
|
tokenSeparators: [',', ' '],
|
||||||
escapeMarkup: function(m) { return m; }
|
escapeMarkup: function(m) { return m; }
|
||||||
});
|
});
|
||||||
@@ -479,12 +494,28 @@ define([
|
|||||||
placeholder: gettext("Select contacts or input"),
|
placeholder: gettext("Select contacts or input"),
|
||||||
width: '400px',
|
width: '400px',
|
||||||
tags: function () {
|
tags: function () {
|
||||||
|
var contacts = app.pageOptions.contacts || [];
|
||||||
var contact_list = [];
|
var contact_list = [];
|
||||||
for (var i = 0, len = contacts.length; i < len; i++) {
|
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;
|
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: [',', ' '],
|
tokenSeparators: [',', ' '],
|
||||||
escapeMarkup: function(m) { return m; }
|
escapeMarkup: function(m) { return m; }
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user