diff --git a/app/helpers/actions_helper.rb b/app/helpers/actions_helper.rb index 878e604d2..e29918854 100644 --- a/app/helpers/actions_helper.rb +++ b/app/helpers/actions_helper.rb @@ -7,7 +7,7 @@ module ActionsHelper # A generic helper method to create action links. # These link could be styled to look like buttons, for example. def action_link(label, icon = nil, url = {}, html_options = {}) - add_css_class html_options, 'action btn btn-light' + add_css_class html_options, 'action btn btn-link d-flex align-items-center gap-2' link_to(icon ? action_icon(icon, label) : label, url, html_options) end @@ -39,7 +39,7 @@ def edit_action_link(path = nil) def destroy_action_link(path = nil) path ||= path_args(entry) action_link(ti('link.delete'), 'remove', path, - data: { confirm: ti(:confirm_delete), + data: { turbo_confirm: ti(:confirm_delete), method: :delete, 'turbo-method': :delete }) end diff --git a/app/models/person.rb b/app/models/person.rb index 09a88f47c..071c49c0e 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -96,6 +96,10 @@ def last_updated_at [associations_updatet_at, updated_at].compact.max end + def to_s + name + end + private def picture_size diff --git a/app/views/layouts/person.html.haml b/app/views/layouts/person.html.haml index 3d0602734..a7b6dbb4b 100644 --- a/app/views/layouts/person.html.haml +++ b/app/views/layouts/person.html.haml @@ -4,7 +4,13 @@ =render partial:"people/search", :locals => {person: @person} %div{"data-controller": "profile-tab highlight"} = render "application/tabbar", tabs: person_tabs(@person) do - =link_to image_tag("export.svg")+ "Export", export_cv_person_path(@person), class: "btn text-primary", data: { turbo_frame: "remote_modal" } + %div.dropdown + = button_tag ti(:more_actions), class: "btn dropdown-toggle", data: { "bs-toggle": "dropdown" } + %ul.dropdown-menu + %li + = link_to image_tag("export.svg")+ "Export", export_cv_person_path(@person), class: "btn text-primary", data: { turbo_frame: "remote_modal" } + %li.text-nowrap + = destroy_action_link %turbo-frame#tab-content.d-flex.gap-3{"data-controller": "scroll"} = yield = render template: "layouts/application" \ No newline at end of file diff --git a/config/locales/de.yml b/config/locales/de.yml index 6fac3ab67..8b9ee4da9 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -119,4 +119,10 @@ de: competence_notes: Kompetenzen roles: Funktionen department: Organisationseinheit - skills: Skills \ No newline at end of file + skills: Skills + people: + show: + confirm_delete: Willst du diese Person wirklich löschen? + more_actions: Weitere Aktionen + link: + delete: Person löschen diff --git a/config/locales/en.yml b/config/locales/en.yml index ae3c50e22..b46f71e1a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -91,3 +91,9 @@ en: from: From to: To today: Today + people: + show: + confirm_delete: Are you sure you want to delete this person? + more_actions: More actions + link: + delete: Delete person diff --git a/spec/features/cv_export_spec.rb b/spec/features/cv_export_spec.rb index d6febe027..41871ddc0 100644 --- a/spec/features/cv_export_spec.rb +++ b/spec/features/cv_export_spec.rb @@ -10,7 +10,7 @@ it 'should display 2 export buttons' do visit person_path(people(:bob)) - expect(page.all('a', text: 'Export').count).to eql(2) + expect(page.all('a', text: 'Export').count).to eql(1) end it 'should display range after switch was clicked' do diff --git a/spec/features/people_spec.rb b/spec/features/people_spec.rb index 32942bfbc..7a4f20c8e 100644 --- a/spec/features/people_spec.rb +++ b/spec/features/people_spec.rb @@ -316,5 +316,14 @@ def add_language(language) 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 + + it 'should delete person' do + visit person_path(longmax) + click_button(I18n.t("people.show.more_actions")) + accept_confirm do + click_link(I18n.t("people.show.link.delete"), href: person_path(longmax)) + end + expect(page).to have_selector('.alert', text: I18n.t("crud.destroy.flash.success", model: longmax)) + end end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index b2531af7d..5229018ee 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -45,6 +45,10 @@ self.class.fixtures :all end + config.before(:each, js: true) do + Capybara.page.current_window.resize_to(1920, 1080) + end + if Bullet.enable? config.before(:each) do Bullet.start_request diff --git a/spec/support/people_skills_helper.rb b/spec/support/people_skills_helper.rb index 46e72bc35..90eaf6680 100644 --- a/spec/support/people_skills_helper.rb +++ b/spec/support/people_skills_helper.rb @@ -48,6 +48,7 @@ def validate_interest(interest) star_labels.each_with_index do |label, index| body = page.document.find('body') body.send_keys(:tab) + body.hover if index < interest expect(label).to match_style(color: 'rgb(255, 199, 0)').or(match_style(color: 'rgba(255, 199, 0, 1)')) else