1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 15:38:15 +00:00

Folder perm group (#2261)

* update shareable-groups api

return all groups, include address book groups

* update folder perm select group

send ajax groups request every time set folder perm
This commit is contained in:
lian
2018-08-08 17:52:16 +08:00
committed by llj
parent 54a01b495b
commit 8bb7b15082
3 changed files with 55 additions and 32 deletions

View File

@@ -53,7 +53,6 @@ class ShareableGroups(APIView):
except ValueError:
avatar_size = GROUP_AVATAR_DEFAULT_SIZE
result = [get_group_info(request, g.id, avatar_size)
for g in groups if g.parent_group_id == 0]
result = [get_group_info(request, g.id, avatar_size) for g in groups]
return Response(result)

View File

@@ -102,7 +102,30 @@ define([
placeholder: gettext("Search user or enter email and press Enter") // to override 'placeholder' returned by `Common.conta...`
}));
} else {
var groups = app.pageOptions.joined_groups_exclude_address_book || [];
var groups = [];
$.ajax({
url: Common.getUrl({
name: app.pageOptions.enable_share_to_all_groups ? 'shareable_groups' : 'groups'
}),
type: 'GET',
dataType: 'json',
cache: false,
success: function(data) {
for (var i = 0, len = data.length; i < len; i++) {
groups.push({
'id': data[i].id,
'name': data[i].name
});
}
groups.sort(function(a, b) {
return Common.compareTwoWord(a.name, b.name);
});
},
error: function(xhr, textStatus, errorThrown) {
// do nothing
},
complete: function() {
var g_opts = '';
for (var i = 0, len = groups.length; i < len; i++) {
g_opts += '<option value="' + groups[i].id + '" data-index="' + i + '">' + groups[i].name + '</option>';
@@ -114,6 +137,9 @@ define([
escapeMarkup: function(m) { return m; }
});
}
});
}
// show existing items
this.listenTo(collection, 'add', this.addItem);

View File

@@ -122,7 +122,7 @@ define([
Common.contactInputOptionsForSelect2({'url': url}));
// use select2 to 'group' input in 'add group perm'
var groups;
var groups, groups_url;
var prepareGroupSelector = function(groups) {
var g_opts = '';
for (var i = 0, len = groups.length; i < len; i++) {
@@ -133,12 +133,14 @@ define([
escapeMarkup: function(m) { return m; }
});
};
if (this.is_group_owned_repo) {
groups_url = Common.getUrl({'name': 'address_book_sub_groups', 'group_id': this.group_id});
} else {
groups_url = Common.getUrl({name: app.pageOptions.enable_share_to_all_groups ? 'shareable_groups' : 'groups'});
}
$.ajax({
url: Common.getUrl({
'name': 'address_book_sub_groups',
'group_id': this.group_id
}),
url: groups_url,
cache: false,
dataType: 'json',
success: function(data) {
@@ -151,10 +153,6 @@ define([
prepareGroupSelector(groups);
}
});
} else {
groups = app.pageOptions.joined_groups_exclude_address_book || [];
prepareGroupSelector(groups);
}
},
events: {