1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-18 08:16:07 +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

@@ -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;