From e1f53d47492c08ff66a6dc3482cc605c8ea38452 Mon Sep 17 00:00:00 2001 From: Manuel <109959820+ManuelMoeri@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:00:41 +0200 Subject: [PATCH] feature/697 no skills added message (#726) * Add removing and styling of message * Add test for message --- app/assets/stylesheets/styles.scss | 4 +++ app/javascript/controllers/index.js | 34 +++++++++---------- .../controllers/people_controller.js | 9 +++++ app/views/people/_cv.html.haml | 7 ++-- spec/features/people_spec.rb | 13 +++++++ 5 files changed, 47 insertions(+), 20 deletions(-) create mode 100644 app/javascript/controllers/people_controller.js diff --git a/app/assets/stylesheets/styles.scss b/app/assets/stylesheets/styles.scss index f9c597caf..b9950c658 100644 --- a/app/assets/stylesheets/styles.scss +++ b/app/assets/stylesheets/styles.scss @@ -361,3 +361,7 @@ a > img { width: 16px; height: 16px; } + +.x-img { + cursor: pointer; +} \ No newline at end of file diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js index 8f74d917c..23d64230d 100644 --- a/app/javascript/controllers/index.js +++ b/app/javascript/controllers/index.js @@ -13,6 +13,9 @@ application.register("dropdown", DropdownController) import DynamicFieldsController from "./dynamic_fields_controller" application.register("dynamic-fields", DynamicFieldsController) +import FilterController from "./filter_controller" +application.register("filter", FilterController) + import HighlightController from "./highlight_controller" application.register("highlight", HighlightController) @@ -25,35 +28,32 @@ application.register("lang-selection", LangSelectionController) import NationalityTwoController from "./nationality_two_controller" application.register("nationality-two", NationalityTwoController) +import PeopleController from "./people_controller" +application.register("people", PeopleController) + +import PeopleSkillsController from "./people_skills_controller" +application.register("people-skills", PeopleSkillsController) + +import PeopleSkillsFilterController from "./people_skills_filter_controller" +application.register("people-skills-filter", PeopleSkillsFilterController) + import ProfileTabController from "./profile_tab_controller" application.register("profile-tab", ProfileTabController) import RemoteModalController from "./remote_modal_controller" application.register("remote-modal", RemoteModalController) +import ScrollController from "./scroll_controller" +application.register("scroll", ScrollController) + import SearchController from "./search_controller" application.register("search", SearchController) -import SkillsFilterController from "./skills_filter_controller" -application.register("skills-filter", SkillsFilterController) - -import DropdownLinksController from "./dropdown_controller" -application.register("dropdown", DropdownLinksController) - -import PeopleSkillsController from "./people_skills_controller" -application.register("people-skills", PeopleSkillsController) - import SkillsEmptySpaceController from "./skills_empty_space_controller" application.register("skills-empty-space", SkillsEmptySpaceController) -import PeopleSkillsFilterController from "./people_skills_filter_controller" -application.register("people-skills-filter", PeopleSkillsFilterController) - -import ScrollController from "./scroll_controller" -application.register("scroll", ScrollController) +import SkillsFilterController from "./skills_filter_controller" +application.register("skills-filter", SkillsFilterController) import SkillsetSelectedController from "./skillset_selected_controller" application.register("skillset-selected", SkillsetSelectedController) - -import FilterController from "./filter_controller" -application.register("filter", FilterController) diff --git a/app/javascript/controllers/people_controller.js b/app/javascript/controllers/people_controller.js new file mode 100644 index 000000000..264b63dd6 --- /dev/null +++ b/app/javascript/controllers/people_controller.js @@ -0,0 +1,9 @@ +import { Controller } from "@hotwired/stimulus"; + +export default class extends Controller { + static targets = ["message"] + + remove() { + this.messageTarget.remove(); + } +} \ No newline at end of file diff --git a/app/views/people/_cv.html.haml b/app/views/people/_cv.html.haml index 303be0ec6..51749a010 100644 --- a/app/views/people/_cv.html.haml +++ b/app/views/people/_cv.html.haml @@ -2,9 +2,10 @@ = link_to image_tag("export.svg") + "Export", export_cv_person_path(@person), data: { turbo_frame: "remote_modal" } %div.w-100{data: { "scroll-target": "parent"}} - if @person.people_skills.count == 0 - %span - %p.alert.alert-info= t('profile.no_skills_rated_msg') - + %span{"data-controller": "people", "data-people-target": "message"} + %p.alert.alert-info.d-flex.justify-content-between + = t('profile.no_skills_rated_msg') + = image_tag("x.svg", "data-action": "click->people#remove", class: "x-img") = render('profile') = render('core_competences') = render('people/person_relations/index', list: @person.educations.list, id: "educations") diff --git a/spec/features/people_spec.rb b/spec/features/people_spec.rb index 14055de8f..32942bfbc 100644 --- a/spec/features/people_spec.rb +++ b/spec/features/people_spec.rb @@ -304,4 +304,17 @@ def add_language(language) expect(Person.all.find_by(name: "Hansjakobli")).to be_nil end end + + describe 'Visit person', type: :feature, js: true do + let(:longmax) { people(:longmax) } + + before(:each) do + sign_in auth_users(:user), scope: :auth_user + end + + it 'should display message when no skills are rated' do + visit person_path(longmax) + expect(page).to have_selector('p.alert.alert-info.d-flex.justify-content-between', text: I18n.t('profile.no_skills_rated_msg')) + end + end end