1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 07:01:12 +00:00

[lib settings] modification

This commit is contained in:
llj
2016-01-28 14:33:17 +08:00
parent adf9837337
commit f6ed190d5b
9 changed files with 159 additions and 153 deletions

View File

@@ -430,6 +430,8 @@ p { margin:0.5em 0; }
text-decoration:none;
}
.more-op-icon {
display:inline-block;
margin-top:4px;
font-size:12px;
}
.big-more-btn {
@@ -1197,7 +1199,8 @@ textarea:-moz-placeholder {/* for FF */
.dropdown-menu a {
display:block;
padding:4px 12px;
width:180px;
min-width:110px;
white-space:nowrap;
}
.dropdown-menu a:hover {
background:#eee;
@@ -2263,15 +2266,15 @@ textarea:-moz-placeholder {/* for FF */
#share-popup .op-target {
max-width:400px;
}
#rename-form .op-target {
max-width:280px;
}
#mv-form .op-target {
max-width:410px;
}
#folder-perm-popup .op-target {
max-width:540px;
}
#repo-transfer-form .op-target {
max-width:200px;
}
/* group-join-form */
/* group-join-form */
#id_group_join_msg {

View File

@@ -1089,7 +1089,7 @@
<p class="history-settings-notice outstanding-tip hide">{% trans "Setting library history is disabled by Admin" %}</p>
<form id="repo-history-settings-form" action="" method="post" class="form">{% csrf_token %}
<form action="" method="post">
<input type="radio" name="history" value="full_history" class="vam" />
<span class="vam">{% trans "Keep full history" %}</span><br />
@@ -1098,12 +1098,12 @@
<input type="radio" name="history" value="partial_history" class="vam" />
<span calss="vam">{% trans "Only keep a period of history:" %}
<input type="text" name="days" size="4" disabled="disabled"
class="input-disabled" value="<%- default_history_limit %>" /> {% trans "days" %}
<input type="text" name="days" size="4" disabled="disabled" class="input-disabled" value="<%= default_history_limit %>" /> {% trans "days" %}
</span><br />
<input type="submit" value="{% trans "Submit" %}" class="submit" />
</form>
<span class="loading-icon loading-tip"></span>
<p class="error hide"></p>
</script>
@@ -1117,8 +1117,8 @@
</script>
<script type="text/template" id="repo-transfer-form-tmpl">
<form method="post" action="">
<h3>{% trans "Transfer Library To" %}</h3>
<form method="post" action="" id="repo-transfer-form">
<h3><%= title %></h3>
<input type="hidden" name="email" /><br />
<p class="error hide"></p>
<input type="submit" value="{% trans "Submit" %}" />

View File

@@ -7,8 +7,7 @@ define([
'use strict';
var HistorySettingsDialog = Backbone.View.extend({
tagName: 'div',
id: 'history-settings-dialog',
template: _.template($('#history-settings-dialog-tmpl').html()),
initialize: function(options) {
@@ -16,61 +15,45 @@ define([
this.repo_id = options.repo_id;
this.render();
this.$('.op-target').css({'max-width':280}); // for long repo name
this.$el.modal();
$("#simplemodal-container").css({'height':'auto'});
this.$loadingTip = this.$('.loading-tip');
this.$error = this.$('.error');
this.$form = this.$('#repo-history-settings-form');
this.$form = this.$('form');
this.$radios = this.$('input:radio[name=history]');
this.$days_input = this.$('input:text[name=days]');
this.$submit = this.$('input[type=submit]');
this.$submit = this.$('[type=submit]');
this.renderHistorySettings();
// only enable setting keep_days when partial history radio is chosen
var _this = this;
this.$radios.change(function() {
var value = $(this).attr('value');
if (value == 'full_history' || value == 'no_history') {
_this.$days_input.prop('disabled', true).addClass('input-disabled');
} else {
_this.$days_input.prop('disabled', false).removeClass('input-disabled');
}
});
},
render: function() {
var repo_name = this.repo_name;
this.$el.html(this.template({
title: gettext("{placeholder} History Settings")
.replace('{placeholder}',
'<span class="op-target ellipsis ellipsis-op-target" title="'
+ Common.HTMLescape(this.repo_name) + '">'
+ Common.HTMLescape(this.repo_name) + '</span>'),
repo_id: this.repo_id,
+ Common.HTMLescape(repo_name) + '">'
+ Common.HTMLescape(repo_name) + '</span>'),
default_history_limit: 30
}));
return this;
},
events: {
'submit form': 'formSubmit'
},
renderHistorySettings: function() {
var _this = this;
$.ajax({
url: Common.getUrl({
'name': 'repo_history_limit',
'repo_id': _this.repo_id
'repo_id': this.repo_id
}),
type: 'get',
dataType: 'json',
beforeSend: Common.prepareCSRFToken,
success: function(data) { // data: { keep_days: -1 }
success: function(data) {
_this.$loadingTip.hide();
if (data.keep_days <= -1) {
@@ -102,6 +85,23 @@ define([
});
},
events: {
'change [name="history"]': 'changeHistorySetting',
'submit form': 'formSubmit'
},
// only enable setting keep_days when partial history radio is chosen
changeHistorySetting: function(e) {
var value = $(e.currentTarget).val();
var $days_input = this.$days_input;
if (value == 'full_history' || value == 'no_history') {
$days_input.prop('disabled', true).addClass('input-disabled');
} else {
$days_input.prop('disabled', false).removeClass('input-disabled');
}
},
formSubmit: function() {
var days;
var value = this.$radios.filter(':checked').val();
@@ -120,7 +120,7 @@ define([
$.ajax({
url: Common.getUrl({
'name': 'repo_history_limit',
'repo_id': _this.repo_id
'repo_id': this.repo_id
}),
type: 'put',
dataType: 'json',
@@ -128,9 +128,9 @@ define([
data: {
'keep_days': days
},
success: function(data) {
success: function() {
$.modal.close();
Common.feedback(gettext("Set library history succeeded."), 'success');
Common.feedback(gettext("Successfully set library history."), 'success');
},
error: function(xhr) {
var err_msg;

View File

@@ -16,19 +16,19 @@ define([
this.repo_id = options.repo_id;
this.render();
this.$('.op-target').css({'max-width': 280});
this.$el.modal();
$("#simplemodal-container").css({'height':'auto'});
},
render: function() {
var repo_name = this.repo_name;
this.$el.html(this.template({
title: gettext("{placeholder} Permission Settings")
.replace('{placeholder}',
'<span class="op-target ellipsis ellipsis-op-target" title="'
+ Common.HTMLescape(this.repo_name) + '">'
+ Common.HTMLescape(this.repo_name) + '</span>'),
repo_id: this.repo_id
// TODO: get settings from server
+ Common.HTMLescape(repo_name) + '">'
+ Common.HTMLescape(repo_name) + '</span>'),
}));
return this;

View File

@@ -16,6 +16,7 @@ define([
this.repo_id = options.repo_id;
this.render();
this.$('.op-target').css({'max-width':280}); // for long repo name
this.$el.modal();
$("#simplemodal-container").css({'height':'auto'});
},
@@ -26,9 +27,7 @@ define([
.replace('{placeholder}',
'<span class="op-target ellipsis ellipsis-op-target" title="'
+ Common.HTMLescape(this.repo_name) + '">'
+ Common.HTMLescape(this.repo_name) + '</span>'),
repo_id: this.repo_id
// TODO: get settings from server
+ Common.HTMLescape(this.repo_name) + '</span>')
}));
return this;

View File

@@ -152,7 +152,7 @@ define([
popup.css({'left': icon.position().left});
if (icon.offset().top + popup.height() <= $('#main').offset().top + $('#main').height()) {
// below the icon
popup.css('top', icon.position().top + icon.height() + 3);
popup.css('top', icon.position().top + icon.outerHeight(true) + 3);
} else {
popup.css('bottom', icon.parent().outerHeight() - icon.position().top + 3);
}
@@ -259,7 +259,7 @@ define([
name: is_dir ? 'rename_dir' : 'rename_file',
repo_id: dir.repo_id
}) + '?parent_dir=' + encodeURIComponent(dir.path);
var after_op_success = function (data) {
var after_op_success = function(data) {
var renamed_dirent_data = {
'obj_name': data['newname'],
'last_modified': new Date().getTime()/1000,
@@ -270,7 +270,6 @@ define([
'starred': false
});
}
$.modal.close();
_this.model.set(renamed_dirent_data); // it will trigger 'change' event
};
var after_op_error = function(xhr) {

View File

@@ -19,6 +19,8 @@ define([
this.is_owner = options.is_owner;
this.render();
// for long group name
this.$('.op-target').css({'max-width': 270});
this.$el.modal({
appendTo: '#main',
focus: false,

View File

@@ -4,7 +4,7 @@ define([
'backbone',
'common',
'app/views/share',
'app/views/dialogs/history-settings',
'app/views/dialogs/repo-history-settings',
'app/views/dialogs/repo-permissions',
'app/views/dialogs/repo-share-link-admin'
], function($, _, Backbone, Common, ShareView, HistorySettingsDialog,
@@ -27,8 +27,8 @@ define([
'click .js-toggle-popup': 'togglePopup',
'click .js-repo-rename': 'rename',
'click .js-repo-transfer': 'transfer',
'click .js-popup-history-settings': 'popupHistorySettings',
'click .js-popup-permission-settings': 'popupPermissionSettings',
'click .js-popup-history-settings': 'popupHistorySettings',
'click .js-popup-share-link-admin': 'popupShareLinkAdmin'
},
@@ -120,20 +120,20 @@ define([
},
togglePopup: function() {
var icon = this.$('.js-toggle-popup'),
popup = this.$('.hidden-op');
var $icon = this.$('.js-toggle-popup'),
$popup = this.$('.hidden-op');
if (popup.hasClass('hide')) { // the popup is not shown
popup.css({'left': icon.position().left});
if (icon.offset().top + popup.height() <= $('#main').offset().top + $('#main').height()) {
if ($popup.hasClass('hide')) { // the popup is not shown
$popup.css({'left': $icon.position().left});
if ($icon.offset().top + $popup.height() <= $('#main').offset().top + $('#main').height()) {
// below the icon
popup.css('top', icon.position().top + icon.height() + 3);
$popup.css('top', $icon.position().top + $icon.outerHeight(true) + 3);
} else {
popup.css('bottom', icon.parent().outerHeight() - icon.position().top + 3);
$popup.css('bottom', $icon.parent().outerHeight() - $icon.position().top + 3);
}
popup.removeClass('hide');
$popup.removeClass('hide');
} else {
popup.addClass('hide');
$popup.addClass('hide');
}
},
@@ -182,9 +182,9 @@ define([
'repo_name': new_name
};
var post_url = Common.getUrl({
name: 'rename_repo',
name: 'repo',
repo_id: _this.model.get('id')
});
}) + '?op=rename';
var after_op_success = function(data) {
_this.model.set({ 'name': new_name }); // it will trigger 'change' event
};
@@ -220,7 +220,11 @@ define([
var _this = this;
this.togglePopup(); // Close the popup
var $form = $(this.transferTemplate());
var repo_name = this.model.get('name');
var $form = $(this.transferTemplate({
title: gettext("Transfer Library {library_name} To").replace('{library_name}',
'<span class="op-target ellipsis ellipsis-op-target" title="' + Common.HTMLescape(repo_name) + '">' + Common.HTMLescape(repo_name) + '</span>')
}));
$form.modal({focus:false});
$('#simplemodal-container').css({'width':'auto', 'height':'auto'});
@@ -245,7 +249,7 @@ define([
Common.disableButton($submitBtn);
$.ajax({
url: Common.getUrl({
'name': 'transfer_repo',
'name': 'repo_owner',
'repo_id': _this.model.get('id')
}),
type: 'put',
@@ -255,10 +259,9 @@ define([
'owner': email
},
success: function() {
// after the transfer, the former owner becomes a common admin of the group.
$.modal.close();
_this.remove();
Common.feedback(gettext("Transfer library succeeded."), 'success');
Common.feedback(gettext("Successfully transferred the library."), 'success');
},
error: function(xhr) {
var error_msg;

View File

@@ -98,8 +98,8 @@ define([
case 'dir_shared_items': return siteRoot + 'api2/repos/' + options.repo_id + '/dir/shared_items/';
case 'shared_repos': return siteRoot + 'api2/shared-repos/' + options.repo_id + '/';
case 'ajax_unset_inner_pub_repo': return siteRoot + 'ajax/unset-inner-pub-repo/' + options.repo_id + '/';
case 'rename_repo': return siteRoot + 'api2/repos/' + options.repo_id + '/?op=rename';
case 'transfer_repo': return siteRoot + 'api2/repos/' + options.repo_id + '/owner/';
case 'repo': return siteRoot + 'api2/repos/' + options.repo_id + '/';
case 'repo_owner': return siteRoot + 'api2/repos/' + options.repo_id + '/owner/';
case 'repo_history_limit': return siteRoot + 'api2/repos/' + options.repo_id + '/history-limit/';
// Permission