From f376eaca55643972943fc6d313a3ca00b32d66ae Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 18 Sep 2020 14:40:41 -0500 Subject: Made a bunch of changes to move trait page DataTables initialization to a separate file (initialize_show_trait_tables.js). The biggest complication was getting the order of attributes in the rows to sync with the order of atribute namees in the column headers. Previously this logic was all in the template. * wqflask/base/webqtlCaseData.py - added attribute first_attr_col as a very awkward solution to passing the column position into the column render function in situations where there are case attribute columns (which can be variable in number) * wqflask/wqflask/show_trait/show_trait.py - Replace "attribute_names" in js_data with "attributes" (which allows the JS access to more information) and also pass new se_exists and has_num_cases variables with js_data, so the javascript has access to whether or not those columns exist in the table * wqflask/wqflask/static/new/javascript/show_trait.js - Change case attribute-related logic to use js_data.attributes instead of js_data.attribute_names * wqflask/wqflask/templates/show_trait.html - Removed table initialization from template * wqflask/wqflask/static/new/javascript/initialize_show_trait_tables.js - new file that initializes tables and reproduces what the template logic used to do with JS logic --- wqflask/base/webqtlCaseData.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'wqflask/base') diff --git a/wqflask/base/webqtlCaseData.py b/wqflask/base/webqtlCaseData.py index 2844cedd..3cf2d80d 100644 --- a/wqflask/base/webqtlCaseData.py +++ b/wqflask/base/webqtlCaseData.py @@ -41,6 +41,8 @@ class webqtlCaseData: self.this_id = None # Set a sane default (can't be just "id" cause that's a reserved word) self.outlier = None # Not set to True/False until later + self.first_attr_col = self.get_first_attr_col() + def __repr__(self): case_data_string = " " if self.value is not None: @@ -79,3 +81,12 @@ class webqtlCaseData: if self.num_cases is not None: return "%s" % self.num_cases return "x" + + def get_first_attr_col(self): + col_num = 4 + if self.variance is not None: + col_num += 2 + if self.num_cases is not None: + col_num += 1 + + return col_num \ No newline at end of file -- cgit v1.2.3