Commit f4778a45 authored by Ryan Herbert's avatar Ryan Herbert

database.js split load_jstree into two methods

Although in the current context these two functions are heavily linked,
this may not be the case in the future, so splitting them seems like a
good idea.

They are now also toggle functions as we need to be able to restore the
previous state.
parent 5023ba23
......@@ -499,33 +499,51 @@ Database.prototype = {
},
load_jstree: function(){
toggle_upload_fields: function() {
var elem = $('.upload_field');
elem.prop('disabled', true);
elem.parents("tr").hide();
var disable = !elem.prop('disabled');
elem.prop('disabled', disable);
elem.parents("tr").prop('hidden', disable);
var pre_process = $('#pre_process');
pre_process.prop('disabled', true);
pre_process.parents("tr").hide();
pre_process.prop('disabled', disable);
pre_process.parents("tr").prop('hidden', disable);
},
toggle_jstree: function(){
var tree = $('#jstree');
tree.jstree({
"plugins" : ["sort"],
'core' : {
'multiple': false,
'data' : {
'url' : function(node){
var address = DB_ADDRESS + '/file/filesystem'
return node.id === '#' ? address
: address + '?node=' + node.id
var enable = tree.parents("tr").prop('hidden');
tree.parents("tr").prop('hidden', !enable);
if (enable) {
console.log("enable");
tree.jstree({
"plugins" : ["sort"],
'core' : {
'multiple': false,
'data' : {
'url' : function(node){
var address = DB_ADDRESS + '/file/filesystem'
return node.id === '#' ? address
: address + '?node=' + node.id
},
'dataType' : 'json',
},
'dataType' : 'json',
},
}
});
tree.on('select_node.jstree', function(event, data){
$('#filename').val(data.selected);
});
}
});
tree.on('select_node.jstree', function(event, data){
$('#filename').val(data.selected);
});
} else {
console.log('disable')
$.jstree.destroy();
tree.off('select_node.jstree');
$('#filename').val(undefined);
}
},
toggle_file_source: function() {
this.toggle_upload_fields();
this.toggle_jstree()
},
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment