mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 15:09:14 +00:00
[backbone] Implement delete, rename and add file-tree, partially implemented mvcp
This commit is contained in:
@@ -95,6 +95,11 @@ define([
|
||||
setTimeout(function() { $('.messages').addClass('hide'); }, time);
|
||||
},
|
||||
|
||||
showFormError: function(formid, error_msg) {
|
||||
$("#" + formid + " .error").html(error_msg).removeClass('hide');
|
||||
$("#simplemodal-container").css({'height':'auto'});
|
||||
},
|
||||
|
||||
ajaxErrorHandler: function(xhr, textStatus, errorThrown) {
|
||||
if (xhr.responseText) {
|
||||
feedback($.parseJSON(xhr.responseText).error, 'error');
|
||||
@@ -176,5 +181,90 @@ define([
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
renderFileSystemTree: function() {
|
||||
var form = $('#mv-form'),
|
||||
file_tree = new FileTree(),
|
||||
container = $('#current-repo-dirs'),
|
||||
loading_tip = container.prev();
|
||||
|
||||
var dirents = app.libdirents,
|
||||
repo_id = dirents.repo_id,
|
||||
repo_name = dirents.repo_name,
|
||||
cur_path = dirents.path;
|
||||
if (cur_path != '/') {
|
||||
cur_path += '/';
|
||||
}
|
||||
container.data('site_root', '{{SITE_ROOT}}');
|
||||
$.ajax({
|
||||
url: app.utils.getUrl({name: 'get_dirents', repo_id: repo_id}) + '?path=' + e(cur_path) + '&dir_only=true&all_dir=true',
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
var json_data = [];
|
||||
var repo_data = {
|
||||
'data': repo_name,
|
||||
'attr': {'repo_id': repo_id, 'root_node': true},
|
||||
'state': 'open'
|
||||
};
|
||||
|
||||
var path_eles = cur_path.split('/');
|
||||
path_eles.pop();
|
||||
/* e.g.
|
||||
* path: '/xx/'
|
||||
* path_eles: ['', 'xx']
|
||||
* data: [["xxx", "xx", "test1022"], ["lkjj", "kjhkhi"]]
|
||||
* when no dir in '/', data will be [[]];
|
||||
*/
|
||||
var len = data.length;
|
||||
var children = [];
|
||||
for (var i = len - 1; i > -1; i--) {
|
||||
children[i] = [];
|
||||
if (i == len - 1) {
|
||||
for (var j = 0, len_i = data[i].length; j < len_i; j++) {
|
||||
children[i].push({
|
||||
'data': data[i][j],
|
||||
'state': 'closed'
|
||||
});
|
||||
}
|
||||
} else {
|
||||
for (var j = 0, len_i = data[i].length; j < len_i; j++) {
|
||||
if (data[i][j] == path_eles[i+1]) {
|
||||
children[i].push({
|
||||
'data': data[i][j],
|
||||
'state': 'open',
|
||||
'children': children[i+1]
|
||||
});
|
||||
} else {
|
||||
children[i].push({
|
||||
'data': data[i][j],
|
||||
'state': 'closed'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (children[0].length > 0) {
|
||||
$.extend(repo_data, {'children': children[0]});
|
||||
}
|
||||
json_data.push(repo_data);
|
||||
|
||||
loading_tip.hide();
|
||||
file_tree.renderDirTree(container, form, json_data);
|
||||
container.removeClass('hide');
|
||||
},
|
||||
error: function() {
|
||||
var cur_repo = [{
|
||||
'data': repo_name,
|
||||
'attr': {'repo_id': repo_id, 'root_node': true},
|
||||
'state': 'closed'
|
||||
}];
|
||||
loading_tip.hide();
|
||||
file_tree.renderDirTree(container, form, cur_repo);
|
||||
container.removeClass('hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user