From c3064645107c5946ab40d90d0c454777cfc9f7a8 Mon Sep 17 00:00:00 2001 From: Bilel KIHAL Date: Tue, 6 Aug 2024 10:10:46 +0200 Subject: [PATCH 1/4] fix: identifier for organizations is ror and for persons is orcid --- app/views/agents/_form.html.haml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/agents/_form.html.haml b/app/views/agents/_form.html.haml index 2e8aa35d4..58176c894 100644 --- a/app/views/agents/_form.html.haml +++ b/app/views/agents/_form.html.haml @@ -55,8 +55,9 @@ %tr %th = t("agents.form.identifiers") + %td.top - %div.agents-identifiers{'data-form-options-display-target':"option1", class: is_organization?(agent) && 'd-none'} + %div.agents-identifiers{'data-form-options-display-target':"option2", class: !is_organization?(agent) && 'd-none'} = render NestedFormInputsComponent.new do |c| - c.template do = agent_identifier_input('NEW_RECORD', name_prefix) @@ -68,7 +69,7 @@ - c.row do = agent_identifier_input(i.to_s.upcase, name_prefix, identifier.notation) - %div.agents-identifiers{'data-form-options-display-target':"option2", class: !is_organization?(agent) && 'd-none'} + %div.agents-identifiers{'data-form-options-display-target':"option1", class: is_organization?(agent) && 'd-none'} = render NestedFormInputsComponent.new do |c| - c.template do = agent_identifier_input('NEW_RECORD', name_prefix, is_organization: false) From 420b2619e942094889a84e6477a207be43433d0e Mon Sep 17 00:00:00 2001 From: Bilel KIHAL Date: Tue, 6 Aug 2024 10:41:38 +0200 Subject: [PATCH 2/4] disable multiple identifiers for agents in agents form --- app/controllers/agents_controller.rb | 1 + app/views/agents/_form.html.haml | 31 ++++++++-------------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/app/controllers/agents_controller.rb b/app/controllers/agents_controller.rb index 7ee6f3808..97a25f0d5 100644 --- a/app/controllers/agents_controller.rb +++ b/app/controllers/agents_controller.rb @@ -273,6 +273,7 @@ def agent_params v end end + p[:identifiers] = p[:identifiers].reject{ |key, value| value["notation"].empty? } identifiers_schemaAgency = params[:agentType].eql?('person') ? 'ORCID' : 'ROR' p[:identifiers]&.each_value do |identifier| identifier[:schemaAgency] = identifiers_schemaAgency diff --git a/app/views/agents/_form.html.haml b/app/views/agents/_form.html.haml index 58176c894..2dcf66fb6 100644 --- a/app/views/agents/_form.html.haml +++ b/app/views/agents/_form.html.haml @@ -55,32 +55,19 @@ %tr %th = t("agents.form.identifiers") - + - identifier = agent&.identifiers&.first %td.top %div.agents-identifiers{'data-form-options-display-target':"option2", class: !is_organization?(agent) && 'd-none'} - = render NestedFormInputsComponent.new do |c| - - c.template do - = agent_identifier_input('NEW_RECORD', name_prefix) - - - c.empty_state do - = hidden_field_tag agent_field_name('', name_prefix+"[#{Array(agent.identifiers).size}]") - - - Array(agent.identifiers).each_with_index do |identifier, i| - - c.row do - = agent_identifier_input(i.to_s.upcase, name_prefix, identifier.notation) + - if identifier&.schemaAgency&.eql?('ROR') + = agent_identifier_input('0', name_prefix, identifier.notation) + - else + = agent_identifier_input('0', name_prefix) %div.agents-identifiers{'data-form-options-display-target':"option1", class: is_organization?(agent) && 'd-none'} - = render NestedFormInputsComponent.new do |c| - - c.template do - = agent_identifier_input('NEW_RECORD', name_prefix, is_organization: false) - - - c.empty_state do - = hidden_field_tag agent_field_name('', name_prefix+"[#{Array(agent.identifiers).size}]") - - - Array(agent.identifiers).each_with_index do |identifier, i| - - c.row do - = agent_identifier_input(i.to_s.upcase, name_prefix, identifier.notation, is_organization: false) - + - if identifier&.schemaAgency&.eql?('ORCID') + = agent_identifier_input('1', name_prefix, identifier.notation, is_organization: false) + - else + = agent_identifier_input('1', name_prefix, is_organization: false) - if show_affiliations %tr{'data-form-options-display-target':"option1", class: is_organization?(agent) && 'd-none'} From 588f8279e0c9c4cd1ec0c005f79da4e1e6c6faa5 Mon Sep 17 00:00:00 2001 From: Bilel KIHAL Date: Tue, 6 Aug 2024 10:47:44 +0200 Subject: [PATCH 3/4] remove the restriction for certain submission fields to create only organization type or person type agents --- app/views/agents/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/agents/_form.html.haml b/app/views/agents/_form.html.haml index 2dcf66fb6..3a688a6ca 100644 --- a/app/views/agents/_form.html.haml +++ b/app/views/agents/_form.html.haml @@ -9,7 +9,7 @@ = hidden_field_tag :deletable, deletable if deletable = hidden_field_tag agent_field_name(:id, name_prefix), agent.id if agent.id - - if is_organization?(agent) && params[:parent_id] + - if params[:show_affiliations].eql?('false') = hidden_field_tag agent_field_name(:agentType, name_prefix), agent.agentType - else %tr From 75ec22251b14e190a2f58999346e2353fffd7d5a Mon Sep 17 00:00:00 2001 From: Syphax Date: Thu, 8 Aug 2024 07:15:15 +0200 Subject: [PATCH 4/4] fix agent tests after changing agent identifier to not be a list --- test/application_system_test_case.rb | 16 ++++++++++------ test/fixtures/agents.yml | 2 -- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index a33ff79e4..9ed6c19be 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -104,7 +104,6 @@ def tom_select(selector, values, open_to_add: false) element = find(ts_wrapper_selector) element.click - return unless page.has_selector?("#{ts_wrapper_selector} > .ts-dropdown") if multiple @@ -152,10 +151,10 @@ def agent_search(name) end def agent_fill(agent, parent_id: nil, is_affiliation: false) - id = agent.id ? "/#{agent.id}": '' + id = agent.id ? "/#{agent.id}" : '' form = all("form[action=\"/agents#{id}\"]").first - within form do - choose "", option: agent.agentType, allow_label_click: true unless is_affiliation + within form do + choose "", option: agent.agentType, allow_label_click: true unless is_affiliation fill_in 'name', with: agent.name if agent.agentType.eql?('organization') @@ -168,8 +167,13 @@ def agent_fill(agent, parent_id: nil, is_affiliation: false) fill_in 'email', with: agent.email end - list_inputs ".agents-identifiers", - "[identifiers]", agent.identifiers + identifier = agent.identifiers.first + + if agent.agentType.eql?('organization') + fill_in "_identifiers_0_notation", with: identifier['notation'] + else + fill_in "_identifiers_1_notation", with: identifier['notation'] + end if is_affiliation || agent.agentType.eql?('organization') refute_selector ".agents-affiliations" diff --git a/test/fixtures/agents.yml b/test/fixtures/agents.yml index 7c1a33704..73554419d 100644 --- a/test/fixtures/agents.yml +++ b/test/fixtures/agents.yml @@ -4,8 +4,6 @@ agent1: email: "jonh@test.com" identifiers: - notation: "0000-0001-2345-6789" - - notation: "0000-0001-2345-6788" - - notation: "0000-0001-2345-6788" affiliations: - name: "Research Institute X" agentType: "organization"