aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorzsloan2021-08-16 19:51:53 +0000
committerzsloan2021-08-19 18:38:54 +0000
commit0b6da486c0480dfe15486de34260ea462b168e39 (patch)
tree3f9c7b670a05633c109b79fb320ee2c09c21f85e /wqflask
parenteb7863b540bda56f3e0a769440ebc16c675d4adb (diff)
downloadgenenetwork2-0b6da486c0480dfe15486de34260ea462b168e39.tar.gz
Update show_trait.js to make removing covariates work with the new select element; individual covariates can now be removed
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait.js39
1 files changed, 37 insertions, 2 deletions
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js
index 845ed907..bacafca6 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait.js
+++ b/wqflask/wqflask/static/new/javascript/show_trait.js
@@ -98,9 +98,44 @@ sample_group_types = js_data.sample_group_types;
$(".select_covariates").click(function () {
open_covariate_selection();
});
+
$(".remove_covariates").click(function () {
- $("input[name=covariates]").val("")
- $(".selected-covariates").val("")
+ $(".selected-covariates option:selected").each(function() {
+ this_val = $(this).val();
+ $(".selected-covariates option").each(function(){
+ if ($(this).val() == this_val){
+ $(this).remove();
+ }
+ })
+ cofactor_count = $(".selected-covariates:first option").length
+ if (cofactor_count > 2 && cofactor_count < 11){
+ $(".selected-covariates").each(function() {
+ $(this).attr("size", $(".selected-covariates:first option").length)
+ });
+ } else if (cofactor_count > 10) {
+ $(".selected-covariates").each(function() {
+ $(this).attr("size", 10)
+ });
+ } else {
+ $(".selected-covariates").each(function() {
+ $(this).attr("size", 2)
+ });
+ }
+ if (cofactor_count == 0){
+ $(".selected-covariates").each(function() {
+ $(this).append($("<option/>", {
+ value: "",
+ text: "No covariates selected"
+ }))
+ })
+ }
+ });
+
+ covariates_list = [];
+ $(".selected-covariates:first option").each(function() {
+ covariates_list.push($(this).val());
+ })
+ $("input[name=covariates]").val(covariates_list.join(","))
});
open_trait_selection = function() {