Commit 016b984a authored by Ryan Herbert's avatar Ryan Herbert

autocomplete.js, set controllers, set forms add group_id param

The group_id had previously been committed as a hard-coded value, thus
locking the completion to a single group. Obviously we want completion
to work for everyone, so this will achieve our goal.
parent 90e76b2b
......@@ -21,12 +21,12 @@
*/
function init_autocomplete(elem) {
function init_autocomplete(elem, group_id) {
var service = 'tag/auto_complete';
var address = db.db_address + service;
$(elem).autocomplete({'serviceUrl': address,
'dataType': 'json',
'params': {'group_id': 10},
'params': {'group_id': group_id},
'delimiter': /[,\.-_=+()$%^&*!@\[\]\{\}\"|'?\\\/><\s]/
});
}
......@@ -203,7 +203,8 @@ def add_form():
## return edit form
def edit():
if (auth.can_modify_patient(request.vars["id"]) ):
return dict(message=T('edit patient'))
group_id = get_set_group(defs.SET_TYPE_PATIENT, request.vars["id"])
return dict(message=T('edit patient'), group_id=group_id)
else :
res = {"message": ACCESS_DENIED}
log.error(res)
......
......@@ -119,9 +119,11 @@ def edit():
distinct=True
)
group_id = get_set_group(defs.SET_TYPE_RUN, request.vars["id"])
return dict(message=T('edit run'),
sequencer_list = sequencer_list,
pcr_list = pcr_list)
pcr_list = pcr_list,
group_id = group_id)
else :
res = {"message": ACCESS_DENIED}
log.error(res)
......
......@@ -284,7 +284,8 @@ def edit():
generic = db((db.generic.sample_set_id == request.vars["id"])).select()[0]
if (auth.can_modify('generic', generic.id)):
request.vars["id"] = generic.id
return dict(message=T('edit sample_set'))
group_id = get_set_group(defs.SET_TYPE_GENERIC, request.vars["id"])
return dict(message=T('edit sample_set'), group_id=group_id)
res = {"message": ACCESS_DENIED}
log.error(res)
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
......
......@@ -11,7 +11,7 @@
<tr {{ if len(groups) <= 1: }} class="hiddenCheckBox" {{pass}}>
<td><label for="patient_group" id="patient_group__label">Owner Group: </label></td>
<td>
{{= SELECT(*[OPTION(g['name'], _value=g['id']) for g in groups], _name="patient_group", _value=master_group, value=master_group) }}
{{= SELECT(*[OPTION(g['name'], _value=g['id']) for g in groups], _id="group_select", _name="patient_group", _value=master_group, value=master_group) }}
</td>
<td></td>
</tr>
......@@ -32,7 +32,7 @@
</tr>
<tr>
<td><label for="patient_info" id="patient_info__label">Info: </label></td>
<td><textarea onfocus="init_autocomplete(this);" class="text" cols="40" id="patient_info" name="info" rows="10"></textarea></td>
<td><textarea onfocus="init_autocomplete(this, $('#group_select option:selected').val());" class="text" cols="40" id="patient_info" name="info" rows="10"></textarea></td>
<td></td>
</tr>
<tr>
......
......@@ -30,7 +30,7 @@ info = db.patient[request.vars["id"]]
</tr>
<tr>
<td> <label for="patient_info" id="patient_info__label">Info: </label> </td>
<td> <textarea onfocus="init_autocomplete(this);" class="text" cols="40" id="patient_info" name="info" rows="10">{{=info.info}}</textarea> </td>
<td> <textarea onfocus="init_autocomplete(this, {{=group_id}});" class="text" cols="40" id="patient_info" name="info" rows="10">{{=info.info}}</textarea> </td>
<td></td>
</tr>
<tr>
......
......@@ -21,13 +21,13 @@
<tr {{ if len(groups) <= 1: }} class="hiddenCheckBox" {{pass}}>
<td><label for="run_group" id="run_group__label">Owner Group: </label></td>
<td>
{{= SELECT(*[OPTION(g['name'], _value=g['id']) for g in groups], _name="run_group", _value=master_group, value=master_group) }}
{{= SELECT(*[OPTION(g['name'], _value=g['id']) for g in groups], _id="group_select", _name="run_group", _value=master_group, value=master_group) }}
</td>
<td></td>
</tr>
<tr>
<td><label for="run_info" id="run_info__label">Info: </label></td>
<td><textarea onfocus="init_autocomplete(this);" class="text" cols="60" id="run_info" name="info" rows="10"></textarea></td>
<td><textarea onfocus="init_autocomplete(this, $('#group_select option:selected').val());" class="text" cols="60" id="run_info" name="info" rows="10"></textarea></td>
<td></td>
</tr>
<tr>
......
......@@ -25,7 +25,7 @@ info = db.run[request.vars["id"]]
</tr>
<tr>
<td> <label for="run_info" id="run_info__label">Info: </label> </td>
<td> <textarea onfocus="init_autocomplete(this);" class="text" cols="60" id="run_info" name="info" rows="10">{{=info.info}}</textarea> </td>
<td> <textarea onfocus="init_autocomplete(this, {{=group_id}});" class="text" cols="60" id="run_info" name="info" rows="10">{{=info.info}}</textarea> </td>
<td></td>
</tr>
<tr>
......
......@@ -11,13 +11,13 @@
<tr {{ if len(groups) <= 1: }} class="hiddenCheckBox" {{pass}}>
<td><label for="sample_set_group" id="sample_set_group__label">Owner Group: </label></td>
<td>
{{= SELECT(*[OPTION(g['name'], _value=g['id']) for g in groups], _name="sample_set_group", _value=master_group, value=master_group) }}
{{= SELECT(*[OPTION(g['name'], _value=g['id']) for g in groups], _id="group_select", _name="sample_set_group", _value=master_group, value=master_group) }}
</td>
<td></td>
</tr>
<tr>
<td><label for="sample_set_info" id="sample_set_info__label">Info: </label></td>
<td><textarea onfocus="init_autocomplete(this);" class="text" cols="60" id="sample_set_info" name="info" rows="10"></textarea></td>
<td><textarea onfocus="init_autocomplete(this, $('#group_select option:selected').val());" class="text" cols="60" id="sample_set_info" name="info" rows="10"></textarea></td>
<td></td>
</tr>
<tr>
......
......@@ -15,7 +15,7 @@ info = db.generic[request.vars["id"]]
</tr>
<tr>
<td> <label for="sample_set_info" id="sample_set_info__label">Info: </label> </td>
<td> <textarea onfocus="init_autocomplete(this);" class="text" cols="60" id="sample_set_info" name="info" rows="10">{{=info.info}}</textarea> </td>
<td> <textarea onfocus="init_autocomplete(this, {{=group_id}});" class="text" cols="60" id="sample_set_info" name="info" rows="10">{{=info.info}}</textarea> </td>
<td></td>
</tr>
<tr>
......
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