1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-31 14:42:10 +00:00

Merge pull request #2282 from haiwen/copy-file

update copy dirent api
This commit is contained in:
lian
2018-08-23 17:57:38 +08:00
committed by GitHub
8 changed files with 28 additions and 27 deletions

View File

@@ -179,10 +179,12 @@ define([
dst_path = $('[name="dst_path"]', this.$form).val();
if (!$.trim(dst_repo) || !$.trim(dst_path)) {
$('.error', form).removeClass('hide');
this.$error.removeClass('hide');
return false;
}
if (dst_repo == repo_id && (dst_path == path || (obj_type == 'dir' && dst_path == path + obj_name + '/'))) {
if (dst_repo == repo_id && (
(dst_path == path && this.op_type == 'mv') ||
(obj_type == 'dir' && dst_path == path + obj_name + '/'))) {
this.$error.html(gettext("Invalid destination path")).removeClass('hide');
return false;
}
@@ -207,6 +209,10 @@ define([
} else {
msg = gettext("Successfully copied %(name)s")
.replace('%(name)s', obj_name);
if (dst_repo == repo_id && dst_path == path) {
_this.dirView.renderDir();
}
}
if (!data['task_id']) { // no progress

View File

@@ -1167,7 +1167,8 @@ define([
$('.error', form).removeClass('hide');
return false;
}
if (dst_repo == dirents.repo_id && dst_path == cur_path) {
if (dst_repo == dirents.repo_id &&
(op == 'mv' && dst_path == cur_path)) {
$('.error', form).html(gettext("Invalid destination path")).removeClass('hide');
return false;
}
@@ -1232,6 +1233,11 @@ define([
} else {
msg_s = gettext("Successfully copied %(name)s and %(amount)s other items.");
}
// show the added items
if (dst_path == cur_path) {
_this.renderDir();
}
}
msg_s = msg_s.replace('%(name)s', data['success'][0]).replace('%(amount)s', success_len - 1);

View File

@@ -232,6 +232,7 @@ define([
mvcp: function(e) {
var op_type = $(e.currentTarget).hasClass('mv') ? 'mv' : 'cp';
var options = {
'dirView': this.dirView,
'dir': this.dir,
'dirent': this.model,
'op_type': op_type
@@ -240,7 +241,6 @@ define([
if (this.model.get('is_img') && op_type == 'mv') {
var index = $('.img-grid-item', this.dirView.$gridViewContainer).index(this.$el);
$.extend(options, {
'dirView': this.dirView,
'imgIndex': index
});
}

View File

@@ -540,6 +540,7 @@ define([
this.hideMobileMenu();
var op_type = $(e.currentTarget).hasClass('mv') ? 'mv' : 'cp';
var options = {
'dirView': this.dirView,
'dir': this.dir,
'dirent': this.model,
'op_type': op_type
@@ -547,7 +548,6 @@ define([
if (this.model.get('is_img') && op_type == 'mv') {
var index = $('.img-name-link', this.dirView.$table).index(this.$('.img-name-link'));
$.extend(options, {
'dirView': this.dirView,
'imgIndex': index
});
}