From 66550944f147df384764dec56fa03876c5793afc Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 17 Mar 2022 22:23:04 +0000 Subject: Fix/change Authors column in phenotype search results - Limit number of full names to 2 followed by "et al." - Fix wrong logic that was using the full length of the authors string instead of the truncated length when determining the width of the column, resulting in it always being at least 500px wide --- wqflask/wqflask/search_results.py | 4 ++-- wqflask/wqflask/templates/search_result_page.html | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index 807e7305..858ca56d 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -203,8 +203,8 @@ class SearchResultPage: for i, trait in enumerate(trait_list): for key in trait.keys(): if key == "authors": - authors_string = ",".join(str(trait[key]).split(",")[:6]) + ", et al." - self.max_widths[key] = max(len(authors_string), self.max_widths[key]) if key in self.max_widths else len(str(trait[key])) + authors_string = ",".join(str(trait[key]).split(",")[:2]) + ", et al." + self.max_widths[key] = max(len(authors_string), self.max_widths[key]) if key in self.max_widths else len(str(authors_string)) else: self.max_widths[key] = max(len(str(trait[key])), self.max_widths[key]) if key in self.max_widths else len(str(trait[key])) diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index c6e4b4d2..b9859229 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -313,8 +313,8 @@ { 'title': "Authors", 'type': "natural", - {% if (max_widths.authors * 7) < 500 %} - 'width': "{{ max_widths.authors * 7 }}px", + {% if (max_widths.authors * 5) < 500 %} + 'width': "{{ max_widths.authors * 5 }}px", {% else %} 'width': "500px", {% endif %} @@ -322,8 +322,8 @@ 'targets': 5, 'render': function(data, type, row, meta) { author_list = data.authors.split(",") - if (author_list.length >= 6) { - author_string = author_list.slice(0, 6).join(",") + ", et al." + if (author_list.length >= 2) { + author_string = author_list.slice(0, 2).join(",") + ", et al." } else{ author_string = data.authors } -- cgit v1.2.3