1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-03 07:55:36 +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; text-decoration:none;
} }
.more-op-icon { .more-op-icon {
display:inline-block;
margin-top:4px;
font-size:12px; font-size:12px;
} }
.big-more-btn { .big-more-btn {
@@ -1197,7 +1199,8 @@ textarea:-moz-placeholder {/* for FF */
.dropdown-menu a { .dropdown-menu a {
display:block; display:block;
padding:4px 12px; padding:4px 12px;
width:180px; min-width:110px;
white-space:nowrap;
} }
.dropdown-menu a:hover { .dropdown-menu a:hover {
background:#eee; background:#eee;
@@ -2263,15 +2266,15 @@ textarea:-moz-placeholder {/* for FF */
#share-popup .op-target { #share-popup .op-target {
max-width:400px; max-width:400px;
} }
#rename-form .op-target {
max-width:280px;
}
#mv-form .op-target { #mv-form .op-target {
max-width:410px; max-width:410px;
} }
#folder-perm-popup .op-target { #folder-perm-popup .op-target {
max-width:540px; max-width:540px;
} }
#repo-transfer-form .op-target {
max-width:200px;
}
/* group-join-form */ /* group-join-form */
/* group-join-form */ /* group-join-form */
#id_group_join_msg { #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> <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" /> <input type="radio" name="history" value="full_history" class="vam" />
<span class="vam">{% trans "Keep full history" %}</span><br /> <span class="vam">{% trans "Keep full history" %}</span><br />
@@ -1098,12 +1098,12 @@
<input type="radio" name="history" value="partial_history" class="vam" /> <input type="radio" name="history" value="partial_history" class="vam" />
<span calss="vam">{% trans "Only keep a period of history:" %} <span calss="vam">{% trans "Only keep a period of history:" %}
<input type="text" name="days" size="4" disabled="disabled" <input type="text" name="days" size="4" disabled="disabled" class="input-disabled" value="<%= default_history_limit %>" /> {% trans "days" %}
class="input-disabled" value="<%- default_history_limit %>" /> {% trans "days" %}
</span><br /> </span><br />
<input type="submit" value="{% trans "Submit" %}" class="submit" /> <input type="submit" value="{% trans "Submit" %}" class="submit" />
</form> </form>
<span class="loading-icon loading-tip"></span> <span class="loading-icon loading-tip"></span>
<p class="error hide"></p> <p class="error hide"></p>
</script> </script>
@@ -1117,8 +1117,8 @@
</script> </script>
<script type="text/template" id="repo-transfer-form-tmpl"> <script type="text/template" id="repo-transfer-form-tmpl">
<form method="post" action=""> <form method="post" action="" id="repo-transfer-form">
<h3>{% trans "Transfer Library To" %}</h3> <h3><%= title %></h3>
<input type="hidden" name="email" /><br /> <input type="hidden" name="email" /><br />
<p class="error hide"></p> <p class="error hide"></p>
<input type="submit" value="{% trans "Submit" %}" /> <input type="submit" value="{% trans "Submit" %}" />

View File

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

View File

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

View File

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

View File

@@ -152,7 +152,7 @@ define([
popup.css({'left': icon.position().left}); popup.css({'left': icon.position().left});
if (icon.offset().top + popup.height() <= $('#main').offset().top + $('#main').height()) { if (icon.offset().top + popup.height() <= $('#main').offset().top + $('#main').height()) {
// below the icon // below the icon
popup.css('top', icon.position().top + icon.height() + 3); popup.css('top', icon.position().top + icon.outerHeight(true) + 3);
} else { } else {
popup.css('bottom', icon.parent().outerHeight() - icon.position().top + 3); popup.css('bottom', icon.parent().outerHeight() - icon.position().top + 3);
} }
@@ -270,7 +270,6 @@ define([
'starred': false 'starred': false
}); });
} }
$.modal.close();
_this.model.set(renamed_dirent_data); // it will trigger 'change' event _this.model.set(renamed_dirent_data); // it will trigger 'change' event
}; };
var after_op_error = function(xhr) { var after_op_error = function(xhr) {

View File

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

View File

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