mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 00:43:53 +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:
@@ -53,7 +53,6 @@ class ShareableGroups(APIView):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
avatar_size = GROUP_AVATAR_DEFAULT_SIZE
|
avatar_size = GROUP_AVATAR_DEFAULT_SIZE
|
||||||
|
|
||||||
result = [get_group_info(request, g.id, avatar_size)
|
result = [get_group_info(request, g.id, avatar_size) for g in groups]
|
||||||
for g in groups if g.parent_group_id == 0]
|
|
||||||
|
|
||||||
return Response(result)
|
return Response(result)
|
||||||
|
@@ -102,7 +102,30 @@ define([
|
|||||||
placeholder: gettext("Search user or enter email and press Enter") // to override 'placeholder' returned by `Common.conta...`
|
placeholder: gettext("Search user or enter email and press Enter") // to override 'placeholder' returned by `Common.conta...`
|
||||||
}));
|
}));
|
||||||
} else {
|
} 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 = '';
|
var g_opts = '';
|
||||||
for (var i = 0, len = groups.length; i < len; i++) {
|
for (var i = 0, len = groups.length; i < len; i++) {
|
||||||
g_opts += '<option value="' + groups[i].id + '" data-index="' + i + '">' + groups[i].name + '</option>';
|
g_opts += '<option value="' + groups[i].id + '" data-index="' + i + '">' + groups[i].name + '</option>';
|
||||||
@@ -114,6 +137,9 @@ define([
|
|||||||
escapeMarkup: function(m) { return m; }
|
escapeMarkup: function(m) { return m; }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// show existing items
|
// show existing items
|
||||||
this.listenTo(collection, 'add', this.addItem);
|
this.listenTo(collection, 'add', this.addItem);
|
||||||
|
@@ -122,7 +122,7 @@ define([
|
|||||||
Common.contactInputOptionsForSelect2({'url': url}));
|
Common.contactInputOptionsForSelect2({'url': url}));
|
||||||
|
|
||||||
// use select2 to 'group' input in 'add group perm'
|
// use select2 to 'group' input in 'add group perm'
|
||||||
var groups;
|
var groups, groups_url;
|
||||||
var prepareGroupSelector = function(groups) {
|
var prepareGroupSelector = function(groups) {
|
||||||
var g_opts = '';
|
var g_opts = '';
|
||||||
for (var i = 0, len = groups.length; i < len; i++) {
|
for (var i = 0, len = groups.length; i < len; i++) {
|
||||||
@@ -133,12 +133,14 @@ define([
|
|||||||
escapeMarkup: function(m) { return m; }
|
escapeMarkup: function(m) { return m; }
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.is_group_owned_repo) {
|
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({
|
$.ajax({
|
||||||
url: Common.getUrl({
|
url: groups_url,
|
||||||
'name': 'address_book_sub_groups',
|
|
||||||
'group_id': this.group_id
|
|
||||||
}),
|
|
||||||
cache: false,
|
cache: false,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
@@ -151,10 +153,6 @@ define([
|
|||||||
prepareGroupSelector(groups);
|
prepareGroupSelector(groups);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
groups = app.pageOptions.joined_groups_exclude_address_book || [];
|
|
||||||
prepareGroupSelector(groups);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
|
Reference in New Issue
Block a user