Maj terminée. Pour consulter la release notes associée voici le lien :
https://about.gitlab.com/releases/2021/07/07/critical-security-release-gitlab-14-0-4-released/

Commit add3e7f4 authored by Ryan Herbert's avatar Ryan Herbert
Browse files

file form modal popup jstree

instead of having an instance of jstree for each file form, we can share
the instance in a popup window.

This is a step towards #2208

See #3044
parent 435d829b
...@@ -1044,6 +1044,14 @@ a.tag-link { ...@@ -1044,6 +1044,14 @@ a.tag-link {
height: -webkit-calc(~"100%" - 215px); height: -webkit-calc(~"100%" - 215px);
height: calc(~"100%" - 215px); height: calc(~"100%" - 215px);
} }
&.jstree-container {
padding-top: 30px;
top: 10%;
left: 25%;
width: 50%;
height: 70%;
}
} }
.data-msg, .info-msg{ .data-msg, .info-msg{
...@@ -2207,9 +2215,15 @@ label.highlight_label { ...@@ -2207,9 +2215,15 @@ label.highlight_label {
white-space: pre-line; white-space: pre-line;
} }
#jstree { .jstree {
max-height: 300px; height: 90%;
width: 100%;
overflow-y: auto; overflow-y: auto;
overflow-x: auto;
}
.jstree_button {
float: right;
} }
.jstree-anchor { .jstree-anchor {
......
...@@ -621,15 +621,31 @@ Database.prototype = { ...@@ -621,15 +621,31 @@ Database.prototype = {
}, },
} }
}); });
var index = elem.data('index');
elem.on('select_node.jstree', function(event, data){ elem.on('select_node.jstree', function(event, data){
$('#file_filename_' + index).val(data.selected); $('#file_filename').val(data.selected);
var split_file = data.selected.toString().split('/'); var split_file = data.selected.toString().split('/');
var file = split_file[split_file.length - 1]; var file = split_file[split_file.length - 1];
$('#file_indicator_' + index).text(file); $('#file_indicator').text(file);
}); });
}, },
display_jstree: function(caller_index) {
$("#jstree_button").data("index", caller_index);
$("#jstree_container").show();
$('#file_indicator_' + caller_index).text("");
$('#file_filename_' + caller_index).val("");
},
close_jstree: function() {
$("#jstree_container").hide();
},
select_jstree: function(caller_index) {
$('#file_indicator_' + caller_index).text($('#file_indicator').text());
$('#file_filename_' + caller_index).val($('#file_filename').val());
$("#jstree_container").hide();
},
toggle_upload_fields: function() { toggle_upload_fields: function() {
var elem = $('.upload_field'); var elem = $('.upload_field');
var disable = !elem.prop('disabled'); var disable = !elem.prop('disabled');
......
...@@ -361,23 +361,17 @@ FileFormBuilder.prototype.build_jstree = function() { ...@@ -361,23 +361,17 @@ FileFormBuilder.prototype.build_jstree = function() {
if (!this.source) { if (!this.source) {
d.hidden = true; d.hidden = true;
} }
d.onclick = function() {
db.display_jstree(self.index);
}
var sel = document.createTextNode('selected:'); var sel = document.createElement('span');
sel.className = "form_label";
sel.appendChild(document.createTextNode(('selected:')));
d.appendChild(sel); d.appendChild(sel);
var indicator = document.createElement('span'); var indicator = document.createElement('span');
indicator.id = "file_indicator_" + self.index; indicator.id = "file_indicator_" + self.index;
d.appendChild(indicator); d.appendChild(indicator);
var tree_par = document.createElement('div');
tree_par.id = "jstree_loader_" + self.index;
tree_par.className = "jstree";
tree_par.onload = function() {db.set_jstree($('#jstree_' + self.index), self.index)};
tree_par.appendChild(document.createTextNode('file'));
d.appendChild(tree_par);
var tree = document.createElement('div');
tree.id = 'jstree_' + this.index;
tree.className = "inline";
tree.dataset.index = this.index;
tree_par.appendChild(tree);
return d; return d;
} }
......
...@@ -69,4 +69,25 @@ ...@@ -69,4 +69,25 @@
<div class="clear"></div> <div class="clear"></div>
<input type="submit" value="Soumettre" class="btn"> <input type="submit" value="Soumettre" class="btn">
</form> </form>
<div id="jstree_container" class="modal jstree-container">
<span class="closeButton"
onclick="db.close_jstree()">
<i class="icon-cancel"></i>
</span>
<input type="hidden" id="file_filename" />
<span>file:</span>
<span id="file_indicator"></span>
<div class="jstree" id="jstree_loader"
{{if not source_module_active:}}
hidden
{{else:}}
onload="db.set_jstree($('#jstree'))"
{{pass}}>
<div id="jstree"></div>
</div>
<span id="jstree_button" class="jstree_button button2" data-index=0 onclick="db.select_jstree($(this).data('index'))">ok</span>
<span id="jstree_close" class="jstree_button button2" onclick="db.close_jstree()">cancel</span>
</div>
<div class="clear"></div> <div class="clear"></div>
...@@ -77,18 +77,12 @@ ...@@ -77,18 +77,12 @@
title="(.fa, .fastq, .fa.gz, .fastq.gz, .clntab)" title="(.fa, .fastq, .fa.gz, .fastq.gz, .clntab)"
> >
</div> </div>
<div class="jstree_container" {{if not source_module_active:}} hidden {{pass}}> <div id="jstree_field_{{=i}}"
selected: {{if not source_module_active:}} style="display: none;" {{pass}}
data-index={{=i}}
onclick="db.display_jstree(this.dataset.index)">
<span class="form_label">selected:</span>
<span id="file_indicator_{{=i}}"></span> <span id="file_indicator_{{=i}}"></span>
<div class="jstree" id="jstree_loader_{{=i}}"
{{if not source_module_active:}}
hidden
{{else:}}
onload="db.set_jstree($('#jstree_{{=i}}'), {{=i}})"
{{pass}}>
file
<div id="jstree_{{=i}}" class="inline" data-index="{{=i}}"></div>
</div>
</div> </div>
</div> </div>
</div> </div>
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