mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 07:27:04 +00:00
[system admin] groups: bugfix & improvement
This commit is contained in:
@@ -507,36 +507,37 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/template" id="groups-tmpl">
|
<script type="text/template" id="groups-tmpl">
|
||||||
<div class="hd">
|
<div class="hd ovhd">
|
||||||
<h3 class="fleft">{% trans "Groups" %}</h3>
|
<h3 class="fleft">{% trans "Groups" %}</h3>
|
||||||
<button class="js-export-excel fright">{% trans "Export Excel" %}</button>
|
<a class="sf-btn-link btn-white js-export-excel fright hide" href="{% url "sys_group_admin_export_excel" %}">{% trans "Export Excel" %}</a>
|
||||||
</div>
|
</div>
|
||||||
|
<span class="loading-icon loading-tip"></span>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="30%">{% trans "Name" %}</th>
|
<th width="35%">{% trans "Name" %}</th>
|
||||||
<th width="30%">{% trans "Creator" %}</th>
|
<th width="30%">{% trans "Owner" %}</th>
|
||||||
<th width="25%">{% trans "Create At" %}</th>
|
<th width="25%">{% trans "Created At" %}</th>
|
||||||
<th width="15%">{% trans "Operations" %}</th>
|
<th width="10%"><!--Operations--></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<span class="loading-icon loading-tip"></span>
|
|
||||||
<div class="empty-tips hide">
|
|
||||||
<h2 class="alc">{% trans "No groups" %}</h2>
|
|
||||||
</div>
|
|
||||||
<div id="paginator">
|
<div id="paginator">
|
||||||
<a class="prev js-previous hide" href="#">{% trans "Previous" %}</a>
|
<a class="prev js-previous hide" href="#">{% trans "Previous" %}</a>
|
||||||
<a class="next js-next hide" href="#">{% trans "Next" %}</a>
|
<a class="next js-next hide" href="#">{% trans "Next" %}</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="empty-tips hide">
|
||||||
|
<h2 class="alc">{% trans "No groups" %}</h2>
|
||||||
|
</div>
|
||||||
|
<p class="error error-tip hide"></p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/template" id="group-item-tmpl">
|
<script type="text/template" id="group-item-tmpl">
|
||||||
<td><a href="/sys/groupadmin/<%- id %>/"><%- name %></a></td>
|
<td><a href="{{ SITE_ROOT }}sys/groupadmin/<%= id %>/"><%- name %></a></td>
|
||||||
<td><a href="{{ SITE_ROOT }}useradmin/info/<% print(encodeURIComponent(owner)); %>/"><%- owner %></a></td>
|
<td><a href="{{ SITE_ROOT }}useradmin/info/<% print(encodeURIComponent(owner)); %>/"><%- owner %></a></td>
|
||||||
<td><time title='<%- time %>'><%- time_from_now %></time></td>
|
<td><time title="<%= time %>"><%= time_from_now %></time></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#" class="sf2-icon-delete sf2-x group-delete-btn op-icon vh" title="{% trans "Delete" %}" aria-label="{% trans "Delete" %}"></a>
|
<a href="#" class="sf2-icon-delete sf2-x group-delete-btn op-icon vh" title="{% trans "Delete" %}" aria-label="{% trans "Delete" %}"></a>
|
||||||
<a href="#" class="sf2-icon-move sf2-x group-transfer-btn op-icon vh" title="{% trans "Transfer" %}" aria-label="{% trans "Transfer" %}"></a>
|
<a href="#" class="sf2-icon-move sf2-x group-transfer-btn op-icon vh" title="{% trans "Transfer" %}" aria-label="{% trans "Transfer" %}"></a>
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
{% block right_panel %}
|
{% block right_panel %}
|
||||||
|
|
||||||
<p class="path-bar">
|
<p class="path-bar">
|
||||||
<a class="normal" href="{{ SITE_ROOT }}sys/groupadmin/">Groups</a>
|
<a class="normal" href="{{ SITE_ROOT }}sysadmin/#groups/">Groups</a>
|
||||||
<span class="path-split">/</span>
|
<span class="path-split">/</span>
|
||||||
{{ group.group_name }}
|
{{ group.group_name }}
|
||||||
</p>
|
</p>
|
||||||
|
@@ -15,7 +15,7 @@ define([
|
|||||||
parseRecords: function(data) {
|
parseRecords: function(data) {
|
||||||
return data.groups;
|
return data.groups;
|
||||||
},
|
},
|
||||||
url: function () {
|
url: function() {
|
||||||
return Common.getUrl({name: 'admin-groups'});
|
return Common.getUrl({name: 'admin-groups'});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -4,10 +4,8 @@ define([
|
|||||||
'backbone',
|
'backbone',
|
||||||
'common',
|
'common',
|
||||||
'moment',
|
'moment',
|
||||||
'simplemodal',
|
|
||||||
'select2',
|
|
||||||
'app/views/widgets/hl-item-view'
|
'app/views/widgets/hl-item-view'
|
||||||
], function($, _, Backbone, Common, Moment, Simplemodal, Select2, HLItemView) {
|
], function($, _, Backbone, Common, Moment, HLItemView) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var GroupView = HLItemView.extend({
|
var GroupView = HLItemView.extend({
|
||||||
@@ -43,7 +41,7 @@ define([
|
|||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function() {
|
success: function() {
|
||||||
_this.$el.remove();
|
_this.$el.remove();
|
||||||
Common.feedback(gettext("Successfully deleted."), 'success');
|
Common.feedback(gettext("Successfully deleted 1 item."), 'success');
|
||||||
},
|
},
|
||||||
error: function(xhr, textStatus, errorThrown) {
|
error: function(xhr, textStatus, errorThrown) {
|
||||||
Common.ajaxErrorHandler(xhr, textStatus, errorThrown);
|
Common.ajaxErrorHandler(xhr, textStatus, errorThrown);
|
||||||
@@ -60,6 +58,8 @@ define([
|
|||||||
transferGroup: function() {
|
transferGroup: function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var group_name = this.model.get('name');
|
var group_name = this.model.get('name');
|
||||||
|
var group_id = this.model.get('id');
|
||||||
|
var cur_owner = this.model.get('owner');
|
||||||
var $form = $(this.transferTemplate({
|
var $form = $(this.transferTemplate({
|
||||||
title: gettext("Transfer Group {group_name} To").replace('{group_name}',
|
title: gettext("Transfer Group {group_name} To").replace('{group_name}',
|
||||||
'<span class="op-target ellipsis ellipsis-op-target" title="' + Common.HTMLescape(group_name) + '">' + Common.HTMLescape(group_name) + '</span>')
|
'<span class="op-target ellipsis ellipsis-op-target" title="' + Common.HTMLescape(group_name) + '">' + Common.HTMLescape(group_name) + '</span>')
|
||||||
@@ -77,25 +77,24 @@ define([
|
|||||||
|
|
||||||
$form.submit(function() {
|
$form.submit(function() {
|
||||||
var email = $.trim($('[name="email"]', $(this)).val());
|
var email = $.trim($('[name="email"]', $(this)).val());
|
||||||
|
var $submitBtn = $('[type="submit"]', $(this));
|
||||||
|
|
||||||
if (!email) {
|
if (!email) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (email == _this.model.get('owner')) {
|
if (email == cur_owner) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = Common.getUrl({'name': 'admin-group','group_id': _this.model.get('id')});
|
|
||||||
var $submitBtn = $('[type="submit"]', $(this));
|
|
||||||
Common.disableButton($submitBtn);
|
Common.disableButton($submitBtn);
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: Common.getUrl({'name': 'admin-group', 'group_id': group_id}),
|
||||||
type: 'put',
|
type: 'put',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
beforeSend: Common.prepareCSRFToken,
|
beforeSend: Common.prepareCSRFToken,
|
||||||
data: {
|
data: {
|
||||||
'new_owner': email,
|
'new_owner': email,
|
||||||
'old_owner': _this.model.get('owner')
|
'old_owner': cur_owner
|
||||||
},
|
},
|
||||||
success: function() {
|
success: function() {
|
||||||
$.modal.close();
|
$.modal.close();
|
||||||
|
@@ -24,31 +24,30 @@ define([
|
|||||||
render: function() {
|
render: function() {
|
||||||
this.$el.append(this.template());
|
this.$el.append(this.template());
|
||||||
|
|
||||||
|
this.$exportExcel = this.$('.js-export-excel');
|
||||||
this.$table = this.$('table');
|
this.$table = this.$('table');
|
||||||
this.$tableBody = $('tbody', this.$table);
|
this.$tableBody = $('tbody', this.$table);
|
||||||
this.$loadingTip = this.$('.loading-tip');
|
this.$loadingTip = this.$('.loading-tip');
|
||||||
this.$emptyTip = this.$('.empty-tips');
|
this.$emptyTip = this.$('.empty-tips');
|
||||||
this.$jsPrevious = this.$('.js-previous');
|
this.$jsPrevious = this.$('.js-previous');
|
||||||
this.$jsNext = this.$('.js-next');
|
this.$jsNext = this.$('.js-next');
|
||||||
|
this.$error = this.$('.error');
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'click .js-export-excel': 'exportExcel',
|
|
||||||
'click #paginator .js-next': 'getNextPage',
|
'click #paginator .js-next': 'getNextPage',
|
||||||
'click #paginator .js-previous': 'getPreviousPage'
|
'click #paginator .js-previous': 'getPreviousPage'
|
||||||
},
|
},
|
||||||
|
|
||||||
exportExcel: function() {
|
|
||||||
location.href = app.config.siteRoot + "sys/groupadmin/export-excel/";
|
|
||||||
},
|
|
||||||
|
|
||||||
initPage: function() {
|
initPage: function() {
|
||||||
|
this.$loadingTip.show();
|
||||||
|
this.$exportExcel.hide();
|
||||||
this.$table.hide();
|
this.$table.hide();
|
||||||
this.$tableBody.empty();
|
this.$tableBody.empty();
|
||||||
this.$loadingTip.show();
|
|
||||||
this.$emptyTip.hide();
|
|
||||||
this.$jsNext.hide();
|
this.$jsNext.hide();
|
||||||
this.$jsPrevious.hide();
|
this.$jsPrevious.hide();
|
||||||
|
this.$emptyTip.hide();
|
||||||
|
this.$error.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
getNextPage: function() {
|
getNextPage: function() {
|
||||||
@@ -106,7 +105,7 @@ define([
|
|||||||
} else {
|
} else {
|
||||||
err_msg = gettext("Failed. Please check the network.");
|
err_msg = gettext("Failed. Please check the network.");
|
||||||
}
|
}
|
||||||
Common.feedback(err_msg, 'error');
|
_this.$error.html(err_msg).show();
|
||||||
},
|
},
|
||||||
complete:function() {
|
complete:function() {
|
||||||
_this.$loadingTip.hide();
|
_this.$loadingTip.hide();
|
||||||
@@ -121,6 +120,7 @@ define([
|
|||||||
|
|
||||||
this.$loadingTip.hide();
|
this.$loadingTip.hide();
|
||||||
if (this.groupCollection.length > 0) {
|
if (this.groupCollection.length > 0) {
|
||||||
|
this.$exportExcel.show();
|
||||||
this.groupCollection.each(this.addOne, this);
|
this.groupCollection.each(this.addOne, this);
|
||||||
this.$table.show();
|
this.$table.show();
|
||||||
this.renderPaginator();
|
this.renderPaginator();
|
||||||
|
Reference in New Issue
Block a user