From 1eb06dfb99ec5a575e4f520873e87e082ef38a63 Mon Sep 17 00:00:00 2001 From: taitus Date: Mon, 18 Jan 2021 12:03:21 +0100 Subject: [PATCH] Add AmsifySuggestags settings With 'whiteList' to true, only can add tags related with suggestions. Update 'keepLastOnHoverTag' and 'checkSimilar' to improve usability. --- app/assets/javascripts/sdg/related_list_selector.js | 3 +++ spec/system/sdg_management/relations_spec.rb | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/app/assets/javascripts/sdg/related_list_selector.js b/app/assets/javascripts/sdg/related_list_selector.js index 1eb0ba88d..2abaff9f9 100644 --- a/app/assets/javascripts/sdg/related_list_selector.js +++ b/app/assets/javascripts/sdg/related_list_selector.js @@ -7,6 +7,9 @@ amsify_suggestags._settings({ suggestions: $(".sdg-related-list-selector .input").data("suggestions-list"), + whiteList: true, + keepLastOnHoverTag: false, + checkSimilar: false }); amsify_suggestags.classes.focus = ".sdg-related-list-focus"; amsify_suggestags.classes.sTagsInput = ".sdg-related-list-selector-input"; diff --git a/spec/system/sdg_management/relations_spec.rb b/spec/system/sdg_management/relations_spec.rb index 3fee5de4e..b2a800413 100644 --- a/spec/system/sdg_management/relations_spec.rb +++ b/spec/system/sdg_management/relations_spec.rb @@ -278,5 +278,14 @@ describe "SDG Relations", :js do expect(page).to have_css "td", exact_text: "1.1" end end + + scenario "allows adding only white list suggestions" do + process = create(:legislation_process, title: "SDG process") + + visit sdg_management_edit_legislation_process_path(process) + + fill_in "Sustainable Development Goals and Targets", with: "tag nonexistent," + within(".amsify-suggestags-input-area") { expect(page).not_to have_content "tag nonexistent" } + end end end