diff --git a/app/assets/javascripts/publications.js b/app/assets/javascripts/publications.js deleted file mode 100644 index bda7eb449c..0000000000 --- a/app/assets/javascripts/publications.js +++ /dev/null @@ -1,80 +0,0 @@ -var human_diseases=new Array(); - -function addSelectedHumanDisease() { - selected_option_index=$("possible_human_diseases").selectedIndex; - selected_option=$("possible_human_diseases").options[selected_option_index]; - title=selected_option.text; - id=selected_option.value; - - if(checkNotInList(id,human_diseases)) { - addHumanDisease(title,id); - updateHumanDiseases(); - } - else { - alert('The human disease has already been added:\n\n' + - title); - } -} - -function removeHumanDisease(id) { - - for(var i = 0; i < human_diseases.length; i++) - if(human_diseases[i][1] == id) { - human_diseases.splice(i, 1); - break; - } - - // update the page - updateHumanDiseases(); -} - -function updateHumanDiseases() { - human_disease_text=''; - type="Human Disease"; - human_disease_ids=new Array(); - - for (var i=0;i: ' + title - //+ "  (" + contributor + ")" - + '  ' - + '[remove]
'; - human_disease_ids.push(id); - } - - // remove the last line break - if(human_disease_text.length > 0) { - human_disease_text = human_disease_text.slice(0,-5); - } - - // update the page - if(human_disease_text.length == 0) { - $('human_disease_to_list').innerHTML = 'No human diseases'; - } - else { - $('human_disease_to_list').innerHTML = human_disease_text; - } - - clearList('publication_human_disease_ids'); - - select=$('publication_human_disease_ids'); - for (i=0;i + <%= admin_checkbox_setting(:human_diseases_enabled, 1, Seek::Config.human_diseases_enabled, + "Human diseases enabled", "Whether the users can register human diseases in SEEK.", + :onchange=>toggle_appear_javascript('human_diseases_plot')) %> +
+ <%= admin_checkbox_setting(:human_diseases_plot_enabled, 1, Seek::Config.human_diseases_plot_enabled, + "Show plot on SEEK frontpage", "A sunburst plot will be displayed on the frontpage, which contains annotated human diseases and counts.") %> +
+ <%= admin_checkbox_setting(:programmes_enabled, 1, Seek::Config.programmes_enabled, "#{t('programme').pluralize} enabled", "Whether #{t('programme').pluralize} are enabled. #{t('programme').pluralize} allow a collection of #{t('project').pluralize} to be grouped together. This is useful if you have a large number of #{t('project').pluralize} from different initiatives.",onchange: toggle_appear_javascript('programme_details')) %>
@@ -126,7 +134,7 @@ <%= admin_checkbox_setting(:require_cookie_consent, 1, Seek::Config.require_cookie_consent, - "Add a cookie consent banner and a cookie setting page", "Show a banner asking for consent for the use of cookies. SEEK uses an essential cookie for session handling, and optional cookies for tracking if set below. + "Add a cookie consent banner and a cookie setting page", "Show a banner asking for consent for the use of cookies. SEEK uses an essential cookie for session handling, and optional cookies for tracking if set below. Some cookies might be also set by embedded content. This banner will offer 3 choices: Only necessary, Embedded content, All. Setting up this option will also add a cookie setting page accessible from the footer.") %> diff --git a/app/views/assays/_form.html.erb b/app/views/assays/_form.html.erb index 827f93a834..403ec8a2e9 100644 --- a/app/views/assays/_form.html.erb +++ b/app/views/assays/_form.html.erb @@ -64,9 +64,7 @@ <% end %> <% if Seek::Config.human_diseases_enabled %> -
- <%= render :partial=>"assays/select_human_diseases" -%> -
+ <%= f.fancy_multiselect :human_diseases, { possibilities: HumanDisease.order(:title).all, with_new_link: true, hidden: false } %> <% end %> <%= render partial: 'assets/manage_specific_attributes', locals:{f:f} if show_form_manage_specific_attributes? %> diff --git a/app/views/assays/_select_human_diseases.erb b/app/views/assays/_select_human_diseases.erb deleted file mode 100644 index 4dd7290665..0000000000 --- a/app/views/assays/_select_human_diseases.erb +++ /dev/null @@ -1,51 +0,0 @@ -<% - select_truncate_length=120 - available_human_diseases = HumanDisease.order(:title) - existing_json = associations_json_from_assay_human_diseases(@assay.assay_human_diseases) --%> -<%= folding_panel('Human Diseases', false, - help_text: "Here you can associate the #{t('assays.assay').downcase} with specific human diseases.") do %> -

- The following Human Diseases are involved in this <%= "#{@assay_text}" -%>: -

- - <%= associations_list('human_disease_to_list', 'associations/assay_human_disease', existing_json, empty_text: 'No Human Diseases') %> - -
- - <%= select_tag :possible_human_diseases, - options_for_select(available_human_diseases.map { |d| [truncate(h(d.title), length: select_truncate_length), d.id]}), - promt: 'Select Human Disease ...', class: 'form-control' -%> - <%= button_link_to "Include in the #{@assay_text}", 'new', '#', id: 'add-human-disease-btn' %> -
- -<% end %> - - diff --git a/app/views/assets/_resource_list_item.html.erb b/app/views/assets/_resource_list_item.html.erb index 8b79818d77..872bb34167 100644 --- a/app/views/assets/_resource_list_item.html.erb +++ b/app/views/assets/_resource_list_item.html.erb @@ -8,7 +8,7 @@ avatar_partial = get_list_item_avatar_partial(resource) if avatar_partial.nil? #dont show JERM avatar for strain without contributor, as there are strains without contributor and are not harvested - avatar_partial = nil if (resource.kind_of?(Strain) && resource.contributor.try(:person).nil?) || resource.is_a?(Organism) + avatar_partial = nil if (resource.kind_of?(Strain) && resource.contributor.try(:person).nil?) || resource.is_a?(Organism) || resource.is_a?(HumanDisease) avatar_content = avatar_partial.blank? ? nil : render(:partial=> avatar_partial,:locals=>{:resource => resource}) access_based_css_class = "list_item" diff --git a/app/views/data_files/_resource_list_item.html.erb b/app/views/data_files/_resource_list_item.html.erb index dcd81fca39..7a537ad48a 100644 --- a/app/views/data_files/_resource_list_item.html.erb +++ b/app/views/data_files/_resource_list_item.html.erb @@ -3,6 +3,9 @@
<%= render partial:"assets/resource_list_item_contributor_and_creators",object:resource %> + <% if Seek::Config.human_diseases_enabled and !resource.human_diseases.empty? %> + <%= list_item_simple_list resource.human_diseases, "Human Diseases" %> + <% end %> <%= list_item_doi(resource) %> <%= @assay ? (list_item_optional_attribute "Relationship type", resource.relationship_type(@assay).try(:title)) : "" %>
diff --git a/app/views/data_files/edit.html.erb b/app/views/data_files/edit.html.erb index 9d147a8bea..8cb62af221 100644 --- a/app/views/data_files/edit.html.erb +++ b/app/views/data_files/edit.html.erb @@ -27,11 +27,15 @@
+ <% if Seek::Config.human_diseases_enabled %> + <%= f.fancy_multiselect :human_diseases, { possibilities: HumanDisease.order(:title).all, with_new_link: true, hidden: false } %> + <% end %> + <% if Seek::Config.file_templates_enabled %> <%= render :partial => "assets/select_template", :locals => {:resource => (@data_file ? @data_file : DataFile.new), :templates => authorised_assets(FileTemplate, nil, 'edit') } %> <% end %> - + <%= render :partial => 'assets/controlled_vocab_annotations_form_properties', :locals => { :resource => (@data_file ? @data_file : DataFile.new) } -%> <%= render :partial => 'assets/license_selector', :locals => { :resource => @data_file } %> diff --git a/app/views/data_files/multi-steps/_basic_metadata.html.erb b/app/views/data_files/multi-steps/_basic_metadata.html.erb index c021e4f32f..da692c4301 100644 --- a/app/views/data_files/multi-steps/_basic_metadata.html.erb +++ b/app/views/data_files/multi-steps/_basic_metadata.html.erb @@ -25,9 +25,13 @@
-
"> +
"> <%= render :partial => 'projects/project_selector', locals: { resource: @data_file } -%> -
+
<% if Seek::Config.human_diseases_enabled %> +
+ <%= f.fancy_multiselect :human_diseases, { possibilities: HumanDisease.order(:title).all, with_new_link: true, hidden: false } %> +
+ <% end %> <%= render :partial => 'assets/select_tags', locals: {collapsed: true} if DataFile.is_taggable? %> <%if(is_modal)%> Cancel diff --git a/app/views/data_files/show.html.erb b/app/views/data_files/show.html.erb index 2b2585b194..b31dd120a5 100644 --- a/app/views/data_files/show.html.erb +++ b/app/views/data_files/show.html.erb @@ -25,7 +25,14 @@ <% end %> <% end %> - <%= render :partial => "assets/special_auth_code_display", :locals => {:resource => @data_file} %> + <% if Seek::Config.human_diseases_enabled %> +

+ Human Diseases: + <%= human_diseases_link_list @data_file.human_diseases -%> +

+ <% end %> + + <%= render :partial => "assets/special_auth_code_display", :locals => {:resource => @data_file} %> <%= render :partial => "assets/asset_doi", :locals => {:displayed_resource=>@display_data_file} %> diff --git a/app/views/homes/_home_contents.html.erb b/app/views/homes/_home_contents.html.erb index 7431eb2d88..a6b5523702 100644 --- a/app/views/homes/_home_contents.html.erb +++ b/app/views/homes/_home_contents.html.erb @@ -59,6 +59,6 @@
-<% if Seek::Config.human_diseases_enabled %> +<% if Seek::Config.human_diseases_enabled && Seek::Config.human_diseases_plot_enabled %> <%= render :partial => 'human_diseases/overview_plot' %> <% end %> diff --git a/app/views/human_diseases/_overview_plot.html.erb b/app/views/human_diseases/_overview_plot.html.erb index ed9d245f47..4cc1690add 100644 --- a/app/views/human_diseases/_overview_plot.html.erb +++ b/app/views/human_diseases/_overview_plot.html.erb @@ -1,5 +1,7 @@ <% - dataframe = get_human_diseases_plot_data() + data = get_human_diseases_plot_data() + tagged = data[:tagged] + untagged = data[:untagged] %>
+ + Untagged:
+ <%= untagged.map{ |key, value| key.to_s.humanize + ': ' + value.to_s }.join(', ') %> +
@@ -22,20 +28,21 @@ var data = [ <% plots = [ - { key: :projects, annotation: { x: 0.145, y: 1.05 } }, - { key: :publications, annotation: { x: 0.5, y: 1.05 } }, - { key: :models, annotation: { x: 0.86, y: 1.05 } }, + { key: :projects, annotation: { x: 0.105, y: 1.05 } }, + { key: :publications, annotation: { x: 0.37, y: 1.05 } }, + { key: :models, annotation: { x: 0.63, y: 1.05 } }, + { key: :data_files, annotation: { x: 0.895, y: 1.05 } }, ] index = -1 %> <% plots.each do |plot| %> { type: 'sunburst', - ids: [ <%== dataframe.map{ |c| '"' + c[:id] + '"' }.join(', ') %> ], - labels: [ <%== dataframe.map{ |c| '"' + + '"' }.join(', ') %> ], - parents: [ <%== dataframe.map{ |c| '"' + c[:parent] + '"' }.join(', ') %> ], - values: [ <%== dataframe.map{ |c| c[plot[:key]] }.join(', ') %> ], - hovertext: [ <%== dataframe.map{ |c| '"' + c[:title] + '"' }.join(', ') %> ], + ids: [ <%== tagged.map{ |c| '"' + c[:id] + '"' }.join(', ') %> ], + labels: [ <%== tagged.map{ |c| '"' + + '"' }.join(', ') %> ], + parents: [ <%== tagged.map{ |c| '"' + c[:parent] + '"' }.join(', ') %> ], + values: [ <%== tagged.map{ |c| c[plot[:key]] }.join(', ') %> ], + hovertext: [ <%== tagged.map{ |c| '"' + c[:title] + '"' }.join(', ') %> ], outsidetextfont: { size: 20, color: '#377eb8' }, leaf: { opacity: 1 }, marker: { line: { width: 2 } }, @@ -48,7 +55,7 @@ var layout = { margin: { l: 0, r: 0, b: 0, t: 50 }, sunburstcolorway: [ '#217290', '#EC7063', '#5499C7', '#01d28e', '#f4d03f', '#8e44ad'], - grid: { rows: 1, columns:3, pattern: 'independent' }, + grid: { rows: 1, columns: 4, pattern: 'independent' }, annotations: [ <% plots.each do |plot| %> { diff --git a/app/views/projects/asset_report/_linked_publication_row.html.erb b/app/views/projects/asset_report/_linked_publication_row.html.erb index 4a3ae0cc95..13b1ea74c6 100644 --- a/app/views/projects/asset_report/_linked_publication_row.html.erb +++ b/app/views/projects/asset_report/_linked_publication_row.html.erb @@ -46,7 +46,7 @@ <% end -%> - <% human_diseases=pub.related_human_diseases -%> + <% human_diseases=pub.human_diseases -%> <% if human_diseases.empty? -%> None defined <% else %> diff --git a/config/routes.rb b/config/routes.rb index e632e6f4f0..c66ccc0867 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -494,7 +494,7 @@ get :retrieve_nels_sample_metadata get :has_matching_sample_type end - resources :people, :programmes, :projects, :investigations, :assays, :samples, :studies, :publications, :events, :collections, :workflows, :file_templates, :placeholders, only: [:index] + resources :people, :programmes, :projects, :investigations, :assays, :samples, :studies, :publications, :events, :collections, :workflows, :file_templates, :placeholders, :human_diseases, only: [:index] end resources :presentations, concerns: [:has_content_blobs, :publishable, :has_versions, :asset] do @@ -607,7 +607,7 @@ post :request_contact post :upload_pdf end - resources :people, :programmes, :projects, :investigations, :assays, :studies, :models, :data_files, :documents, :presentations, :organisms, :events, :collections, :workflows, :human_diseases, only: [:index] + resources :people, :programmes, :projects, :investigations, :assays, :studies, :models, :data_files, :documents, :presentations, :organisms, :human_diseases, :events, :collections, :workflows, :human_diseases, only: [:index] end resources :events, concerns: [:asset] do @@ -639,7 +639,7 @@ collection do post :search_ajax end - resources :projects, :programmes, :assays, :studies, :models, :publications, only: [:index] + resources :projects, :programmes, :assays, :studies, :models, :publications, :data_files, only: [:index] member do get :tree end diff --git a/db/migrate/20200703120513_add_human_diseases_to_data_files.rb b/db/migrate/20200703120513_add_human_diseases_to_data_files.rb new file mode 100644 index 0000000000..4f101e19aa --- /dev/null +++ b/db/migrate/20200703120513_add_human_diseases_to_data_files.rb @@ -0,0 +1,11 @@ +class AddHumanDiseasesToDataFiles < ActiveRecord::Migration[5.2] + def change + create_table "data_files_human_diseases", id: false, force: :cascade do |t| + t.integer "human_disease_id" + t.integer "data_file_id" + end + + add_index "data_files_human_diseases", ["human_disease_id", "data_file_id"], name: "index_diseases_data_files_on_disease_id_and_data_file_id", using: :btree + add_index "data_files_human_diseases", ["data_file_id"], name: "index_diseases_data_files_on_data_file_id", using: :btree + end + end diff --git a/db/schema.rb b/db/schema.rb index 22e12632eb..76feb5e35d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -430,6 +430,13 @@ t.integer "event_id" end + create_table "data_files_human_diseases", id: false, force: :cascade do |t| + t.integer "human_disease_id" + t.integer "data_file_id" + t.index ["data_file_id"], name: "index_diseases_data_files_on_data_file_id" + t.index ["human_disease_id", "data_file_id"], name: "index_diseases_data_files_on_disease_id_and_data_file_id" + end + create_table "data_files_projects", id: false, force: :cascade do |t| t.integer "project_id" t.integer "data_file_id" diff --git a/lib/seek/config_setting_attributes.yml b/lib/seek/config_setting_attributes.yml index e23642e9df..7c5ba287d3 100644 --- a/lib/seek/config_setting_attributes.yml +++ b/lib/seek/config_setting_attributes.yml @@ -53,6 +53,7 @@ modelling_analysis_enabled: allow_publications_fulltext: allow_edit_of_registered_publ: human_diseases_enabled: +human_diseases_plot_enabled: jerm_enabled: email_enabled: jws_enabled: diff --git a/test/unit/filterer_test.rb b/test/unit/filterer_test.rb index a45cdbb54a..00bc614c6d 100644 --- a/test/unit/filterer_test.rb +++ b/test/unit/filterer_test.rb @@ -9,6 +9,7 @@ class FiltererTest < ActiveSupport::TestCase assert_includes data_file_filters, :tag assert_includes data_file_filters, :created_at assert_includes data_file_filters, :project + assert_includes data_file_filters, :human_disease assert_not_includes data_file_filters, :assay_class assert_includes assay_filters, :query @@ -16,6 +17,7 @@ class FiltererTest < ActiveSupport::TestCase assert_includes assay_filters, :created_at assert_includes assay_filters, :project assert_includes assay_filters, :assay_class + assert_includes assay_filters, :human_disease assert_not_includes assay_filters, :published_year Banana = Class.new(ApplicationRecord)