mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 15:09:14 +00:00
[group settings] manage members: added 'add multi members once' and other improvement
This commit is contained in:
@@ -967,7 +967,6 @@
|
|||||||
<form method="post" action="" id="add-group-members-form">
|
<form method="post" action="" id="add-group-members-form">
|
||||||
<input type="hidden" name="user_name" />
|
<input type="hidden" name="user_name" />
|
||||||
<input type="submit" value="{% trans "Add" %}" class="submit" />
|
<input type="submit" value="{% trans "Add" %}" class="submit" />
|
||||||
<p class="error hide"></p>
|
|
||||||
</form>
|
</form>
|
||||||
<div class="members">
|
<div class="members">
|
||||||
<table>
|
<table>
|
||||||
@@ -976,16 +975,16 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th width="5%"></th>
|
<th width="5%"></th>
|
||||||
<th width="25%">{% trans "Name" %}</th>
|
<th width="25%">{% trans "Name" %}</th>
|
||||||
<th width="25%">{% trans "Email" %}</th>
|
<th width="35%">{% trans "Email" %}</th>
|
||||||
<th width="25%">{% trans "Role" %}</th>
|
<th width="25%">{% trans "Role" %}</th>
|
||||||
<th width="20%">{% trans "Operations" %}</th>
|
<th width="10%"><!--Operations--></th>
|
||||||
</tr>
|
</tr>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="5%"></th>
|
<th width="5%"></th>
|
||||||
<th width="30%">{% trans "Name" %}</th>
|
<th width="30%">{% trans "Name" %}</th>
|
||||||
<th width="40%">{% trans "Email" %}</th>
|
<th width="55%">{% trans "Email" %}</th>
|
||||||
<th width="20%">{% trans "Operations" %}</th>
|
<th width="10%"><!--Operations--></th>
|
||||||
</tr>
|
</tr>
|
||||||
<% } %>
|
<% } %>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -995,7 +994,7 @@
|
|||||||
<p class="error hide"></p>
|
<p class="error hide"></p>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
<script type="text/template" id="group-member2-tmpl"> {# TODO: any better id? #}
|
<script type="text/template" id="group-manage-member-tmpl">
|
||||||
<td>
|
<td>
|
||||||
<img src="<%= avatar_url %>" alt="" width="20" class="avatar" />
|
<img src="<%= avatar_url %>" alt="" width="20" class="avatar" />
|
||||||
</td>
|
</td>
|
||||||
@@ -1032,12 +1031,12 @@
|
|||||||
<td></td>
|
<td></td>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<% if (is_owner) { %>
|
<% if (is_owner) { %>
|
||||||
<td><span class="sf2-icon-delete op-icon vh rm" title="{% trans "Delete" %}"></span></td>
|
<td><span class="sf2-icon-x2 op-icon vh rm" title="{% trans "Delete" %}"></span></td>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<% if (is_admin) { %>
|
<% if (is_admin) { %>
|
||||||
<td></td>
|
<td></td>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<td><span class="sf2-icon-delete op-icon vh rm" title="{% trans "Delete" %}"></span></td>
|
<td><span class="sf2-icon-x2 op-icon vh rm" title="{% trans "Delete" %}"></span></td>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
@@ -9,7 +9,7 @@ define([
|
|||||||
var View = Backbone.View.extend({
|
var View = Backbone.View.extend({
|
||||||
tagName: 'tr',
|
tagName: 'tr',
|
||||||
|
|
||||||
template: _.template($('#group-member2-tmpl').html()),
|
template: _.template($('#group-manage-member-tmpl').html()),
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'mouseenter': 'highlight',
|
'mouseenter': 'highlight',
|
||||||
@@ -22,6 +22,7 @@ define([
|
|||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.group_id = options.group_id;
|
this.group_id = options.group_id;
|
||||||
this.is_owner = options.is_owner;
|
this.is_owner = options.is_owner;
|
||||||
|
this.$errorContainer = options.errorContainer;
|
||||||
|
|
||||||
this.listenTo(this.model, 'change', this.render);
|
this.listenTo(this.model, 'change', this.render);
|
||||||
},
|
},
|
||||||
@@ -77,8 +78,7 @@ define([
|
|||||||
} else {
|
} else {
|
||||||
err_msg = gettext("Failed. Please check the network.");
|
err_msg = gettext("Failed. Please check the network.");
|
||||||
}
|
}
|
||||||
// improve it?
|
_this.$errorContainer.html(err_msg).show();
|
||||||
Common.feedback(error_msg, 'error');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -104,8 +104,7 @@ define([
|
|||||||
} else {
|
} else {
|
||||||
err_msg = gettext("Failed. Please check the network.");
|
err_msg = gettext("Failed. Please check the network.");
|
||||||
}
|
}
|
||||||
// improve it?
|
_this.$errorContainer.html(err_msg).show();
|
||||||
Common.feedback(error_msg, 'error');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
@@ -4,7 +4,7 @@ define([
|
|||||||
'backbone',
|
'backbone',
|
||||||
'common',
|
'common',
|
||||||
'app/collections/group-members',
|
'app/collections/group-members',
|
||||||
'app/views/group-member2'
|
'app/views/group-manage-member'
|
||||||
], function($, _, Backbone, Common, GroupMembers, ItemView) {
|
], function($, _, Backbone, Common, GroupMembers, ItemView) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -24,6 +24,10 @@ define([
|
|||||||
focus: false,
|
focus: false,
|
||||||
containerCss: {
|
containerCss: {
|
||||||
'width': 560
|
'width': 560
|
||||||
|
},
|
||||||
|
onClose: function() {
|
||||||
|
$(document).off('click', hideRoleEdit);
|
||||||
|
$.modal.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.$modalContainer = $('#simplemodal-container').css({'height':'auto'});
|
this.$modalContainer = $('#simplemodal-container').css({'height':'auto'});
|
||||||
@@ -39,14 +43,14 @@ define([
|
|||||||
|
|
||||||
this.$loadingTip = this.$('.loading-tip');
|
this.$loadingTip = this.$('.loading-tip');
|
||||||
this.$listContainer = this.$('tbody');
|
this.$listContainer = this.$('tbody');
|
||||||
this.$listError = this.$('.members .error');
|
this.$error = this.$('.error');
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
$(window).resize(function() {
|
$(window).resize(function() {
|
||||||
_this.setConMaxHeight();
|
_this.setConMaxHeight();
|
||||||
});
|
});
|
||||||
// click other place to hide '.role-edit'
|
// click other place to hide '.role-edit'
|
||||||
$(document).click(function(e) {
|
var hideRoleEdit = function(e) {
|
||||||
var target = e.target || event.srcElement;
|
var target = e.target || event.srcElement;
|
||||||
var $el = _this.$('.role-edit:visible');
|
var $el = _this.$('.role-edit:visible');
|
||||||
var $td = $el.parent();
|
var $td = $el.parent();
|
||||||
@@ -57,7 +61,8 @@ define([
|
|||||||
$el.hide();
|
$el.hide();
|
||||||
$td.find('.cur-role, .role-edit-icon').show();
|
$td.find('.cur-role, .role-edit-icon').show();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
$(document).click(hideRoleEdit);
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
@@ -78,7 +83,8 @@ define([
|
|||||||
var view = new ItemView({
|
var view = new ItemView({
|
||||||
model: item,
|
model: item,
|
||||||
group_id: this.group_id,
|
group_id: this.group_id,
|
||||||
is_owner: this.is_owner
|
is_owner: this.is_owner,
|
||||||
|
errorContainer: this.$error
|
||||||
});
|
});
|
||||||
if (options.prepend) {
|
if (options.prepend) {
|
||||||
this.$listContainer.prepend(view.render().el);
|
this.$listContainer.prepend(view.render().el);
|
||||||
@@ -108,7 +114,7 @@ define([
|
|||||||
} else {
|
} else {
|
||||||
err_msg = gettext('Please check the network.');
|
err_msg = gettext('Please check the network.');
|
||||||
}
|
}
|
||||||
_this.$listError.html(err_msg).show();
|
_this.$error.html(err_msg).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -121,7 +127,7 @@ define([
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var input_val_list = input_val.split(',');
|
var input_val_list = input_val.split(',');
|
||||||
if (input_val_list.length == 1) {
|
if (input_val_list.length == 1) { // 1 email
|
||||||
this.collection.create({'email': input_val}, {
|
this.collection.create({'email': input_val}, {
|
||||||
wait: true,
|
wait: true,
|
||||||
validate: true,
|
validate: true,
|
||||||
@@ -130,17 +136,50 @@ define([
|
|||||||
$input.select2('val', '');
|
$input.select2('val', '');
|
||||||
},
|
},
|
||||||
error: function(collection, response, options) {
|
error: function(collection, response, options) {
|
||||||
|
$input.select2('val', '');
|
||||||
var err_msg;
|
var err_msg;
|
||||||
if (response.responseText) {
|
if (response.responseText) {
|
||||||
err_msg = response.responseJSON.error_msg;
|
err_msg = response.responseJSON.error_msg;
|
||||||
} else {
|
} else {
|
||||||
err_msg = gettext('Please check the network.');
|
err_msg = gettext('Please check the network.');
|
||||||
}
|
}
|
||||||
_this.$listError.html(err_msg).show();
|
_this.$error.html(err_msg).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// TODO: input_val_list.length > 1
|
$.ajax({
|
||||||
|
url: Common.getUrl({
|
||||||
|
'name': 'group_member_bulk',
|
||||||
|
'group_id': _this.group_id
|
||||||
|
}),
|
||||||
|
type: 'post',
|
||||||
|
dataType: 'json',
|
||||||
|
beforeSend: Common.prepareCSRFToken,
|
||||||
|
data: {'emails': input_val},
|
||||||
|
success: function(data) { // data: {success, failed}
|
||||||
|
$input.select2('val', '');
|
||||||
|
|
||||||
|
if (data.success.length > 0) {
|
||||||
|
_this.collection.add(data.success, {prepend: true});
|
||||||
|
}
|
||||||
|
var err_str = '';
|
||||||
|
if (data.failed.length > 0) {
|
||||||
|
$(data.failed).each(function(index, item) {
|
||||||
|
err_str += item.email + ': ' + item.error_msg + '<br />';
|
||||||
|
});
|
||||||
|
_this.$error.html(err_str).show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
var err_msg;
|
||||||
|
if (xhr.responseText) {
|
||||||
|
err_msg = gettext('Error');
|
||||||
|
} else {
|
||||||
|
err_msg = gettext("Failed. Please check the network.");
|
||||||
|
}
|
||||||
|
_this.$error.html(err_msg).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -154,7 +193,8 @@ define([
|
|||||||
- parseInt($modalContainer.css('padding-top'))
|
- parseInt($modalContainer.css('padding-top'))
|
||||||
- parseInt($modalContainer.css('padding-bottom'))
|
- parseInt($modalContainer.css('padding-bottom'))
|
||||||
- this.$('h3').outerHeight(true)
|
- this.$('h3').outerHeight(true)
|
||||||
- this.$('form').outerHeight(true),
|
- this.$('form').outerHeight(true)
|
||||||
|
- 20, // add some gap between the bottom borders of the popup & the window
|
||||||
'overflow': 'auto'
|
'overflow': 'auto'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -106,6 +106,7 @@ define([
|
|||||||
case 'group': return siteRoot + 'api/v2.1/groups/' + options.group_id + '/';
|
case 'group': return siteRoot + 'api/v2.1/groups/' + options.group_id + '/';
|
||||||
case 'group_members': return siteRoot + 'api/v2.1/groups/' + options.group_id + '/members/';
|
case 'group_members': return siteRoot + 'api/v2.1/groups/' + options.group_id + '/members/';
|
||||||
case 'group_member': return siteRoot + 'api/v2.1/groups/' + options.group_id + '/members/' + options.email + '/';
|
case 'group_member': return siteRoot + 'api/v2.1/groups/' + options.group_id + '/members/' + options.email + '/';
|
||||||
|
case 'group_member_bulk': return siteRoot + 'api/v2.1/groups/' + options.group_id + '/members/bulk/';
|
||||||
case 'group_repos': return siteRoot + 'api2/groups/' + options.group_id + '/repos/';
|
case 'group_repos': return siteRoot + 'api2/groups/' + options.group_id + '/repos/';
|
||||||
case 'group_basic_info': return siteRoot + 'ajax/group/' + options.group_id + '/basic-info/';
|
case 'group_basic_info': return siteRoot + 'ajax/group/' + options.group_id + '/basic-info/';
|
||||||
case 'toggle_group_modules': return siteRoot + 'ajax/group/' + options.group_id + '/toggle-modules/';
|
case 'toggle_group_modules': return siteRoot + 'ajax/group/' + options.group_id + '/toggle-modules/';
|
||||||
|
Reference in New Issue
Block a user