Commit 48fff7cd authored by Ryan Herbert's avatar Ryan Herbert

global and specific file set selection

Reintroduces the file-specific set selection for file uploads. As
expected the global selector will be applied to all files in the form.
The two methods complement each other rather than override.
parent f17c27dd
......@@ -227,6 +227,7 @@ FileFormBuilder.prototype.build = function(index) {
fieldset.appendChild(this.createCloseButton());
fieldset.appendChild(this.build_hidden_fields());
fieldset.appendChild(this.build_file_fieldset());
fieldset.appendChild(this.build_set_fieldset());
fieldset.appendChild(this.build_info_fieldset());
return fieldset;
}
......
......@@ -22,6 +22,14 @@
function Tokeniser(target, form_input) {
if (typeof Tokeniser.instance === 'object') {
if (typeof target !== "undefined") {
Tokeniser.instance.target = target;
}
if (typeof form_input !== "undefined") {
Tokeniser.instance.form_input = form_input
}
return Tokeniser.instance;
}
......
......@@ -184,6 +184,7 @@ def form():
myfile = db.sequence_file[request.vars["file_id"]]
if myfile is None:
myfile = {}
myfile['sets'] = []
sets = get_set_list(relevant_ids, helpers)
data = {}
......@@ -217,6 +218,8 @@ def submit():
for f in data['file']:
errors = validate(f)
f['sets'], f['id_dict'], err = validate_sets(f['set_ids'])
if len(errors) > 0:
f['error'] = errors
error = True
......@@ -248,6 +251,12 @@ def submit():
mes = "file (%d) %s %sed" % (f["id"], f["filename"], action)
f['message'].append(mes)
f['message'].append("You must reselect the file for it to be uploaded")
for key in f['id_dict']:
if key not in id_dict:
id_dict[key] = []
id_dict[key] += f['id_dict'][key]
for key in id_dict:
for sid in id_dict[key]:
group_id = get_set_group(sid)
......
......@@ -37,28 +37,28 @@
{{ if len(errors) > 0: }}
<div class="error">{{=", ".join(errors)}}</div>
{{ pass }}
<label for="set_ids_{{=0}}" id="set_ids__label_{{=0}}">sets: </label>
<div class="token_div form-control" onclick="$('#token_input_{{=0}}').focus()">
<label for="set_ids" id="set_ids__label">sets: </label>
<div class="token_div form-control" onclick="$('#token_input').focus()">
<input
hidden
id="file_set_list_{{=0}}"
id="file_set_list"
name="set_ids"
type="text"
value="{{=",".join([set['id'] for set in sets])}}">
<div id="set_div_{{=0}}" class="token_container">
<div id="set_div" class="token_container">
{{ for set in sets: }}
<span class="set_token {{=set['type']}}_token" data-set-id="{{=set['id']}}">
<i class="icon-cancel" onclick="new Tokeniser(document.getElementById('set_div_{{=0}}'), document.getElementById('file_set_list_{{=0}}')).removeToken(this.parentNode);"></i>
<i class="icon-cancel" onclick="new Tokeniser(document.getElementById('set_div'), document.getElementById('file_set_list')).removeToken(this.parentNode);"></i>
{{=set['id'][3:]}}
</span>
{{pass}}
</div>
<input
id="token_input_{{=0}}"
id="token_input"
class="token_input"
autocomplete="off"
onfocus="new VidjilAutoComplete().setupSamples(this);
new Tokeniser(document.getElementById('set_div_{{=0}}'), document.getElementById('file_set_list_{{=0}}'));"
new Tokeniser(document.getElementById('set_div'), document.getElementById('file_set_list'));"
data-needs-atwho="true"
data-needs-tokeniser="true"
data-group-ids="{{=upload_group_ids}}"
......
......@@ -47,6 +47,42 @@
</div>
</div>
</fieldset>
<fieldset>
<legend>set selection</legend>
<div>
You must associate this sample with at least one patient, run or set.<br>You can also associate it with any combination of the three.
</div>
<div class="field_div">
<label for="file_set_ids_{{=i}}" id="file_set_ids__label_{{=i}}">sets: </label>
<div class="token_div form-control" onclick="$('#token_input_{{=i}}').focus()">
<input
hidden
id="file_set_list_{{=i}}"
name="file[{{=i}}][set_ids]"
type="text"
value="{{=",".join([set['id'] for set in sets])}}">
<div id="file_set_div_{{=i}}" class="token_container">
{{ for set in file['sets']: }}
<span class="set_token {{=set['type']}}_token" data-set-id="{{=set['id']}}">
<i class="icon-cancel" onclick="new Tokeniser(document.getElementById('file_set_div_{{=i}}'), document.getElementById('file_set_list_{{=i}}')).removeToken(this.parentNode);"></i>
{{=set['id'][3:]}}
</span>
{{pass}}
</div>
<input
id="token_input_{{=i}}"
class="token_input"
autocomplete="off"
onfocus="new VidjilAutoComplete().setupSamples(this);
new Tokeniser(document.getElementById('file_set_div_{{=i}}'), document.getElementById('file_set_list_{{=i}}'));"
data-needs-atwho="true"
data-needs-tokeniser="true"
data-group-ids="{{=upload_group_ids}}"
data-keys='["generic", "patient", "run"]'
type="text">
</div>
</div>
</fieldset>
<fieldset>
<legend>sample information</legend>
<div class="field_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