From 4e149771229ef2342dd3d342d7d5794ee45466ec Mon Sep 17 00:00:00 2001 From: Manuel <109959820+ManuelMoeri@users.noreply.github.com> Date: Tue, 2 Apr 2024 14:41:24 +0200 Subject: [PATCH] 632/Re-Add Skillset Export (#633) * Add route and new button * Create route and implement export * Remove unused span * Add needed class * Re-trigger pipeline-tests * Remove 1 * Switch path name to rails-style-path --------- Co-authored-by: Robin Steiner --- app/assets/images/download.svg | 1 + app/controllers/skills_controller.rb | 12 ++++++------ app/views/skills/index.html.haml | 8 +++++--- config/routes.rb | 7 ++++++- 4 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 app/assets/images/download.svg diff --git a/app/assets/images/download.svg b/app/assets/images/download.svg new file mode 100644 index 000000000..6a171ea82 --- /dev/null +++ b/app/assets/images/download.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/controllers/skills_controller.rb b/app/controllers/skills_controller.rb index d9504c640..24b98b024 100644 --- a/app/controllers/skills_controller.rb +++ b/app/controllers/skills_controller.rb @@ -25,6 +25,12 @@ def unrated_by_person render json: entries, each_serializer: SkillMinimalSerializer, include: '*' end + def export + send_data Csv::Skillset.new(fetch_entries).export, + type: :csv, + disposition: disposition + end + private def filter_by_rated(skill) @@ -43,12 +49,6 @@ def fetch_entries SkillsFilter.new(entries, params[:category], params[:title], params[:defaultSet]).scope end - def export - send_data Csv::Skillset.new(fetch_entries).export, - type: :csv, - disposition: disposition - end - def disposition content_disposition('attachment', filename('skillset', nil, 'csv')) end diff --git a/app/views/skills/index.html.haml b/app/views/skills/index.html.haml index 62c54f3bc..e609ac4f2 100644 --- a/app/views/skills/index.html.haml +++ b/app/views/skills/index.html.haml @@ -1,6 +1,8 @@ -%div.d-flex.justify-content-end - =link_to image_tag("plus-lg.svg", class: "text-primary")+ "Neuer Skill", new_skill_path, class: "btn text-primary", data: { turbo_frame: "remote_modal" } - +%div.d-flex.justify-content-end.align-items-center + %div + =link_to image_tag("download.svg")+ "Export", export_skills_path, class: "btn text-primary" + %div + =link_to image_tag("plus-lg.svg", class: "text-primary")+ "Neuer Skill", new_skill_path, class: "btn text-primary", data: { turbo_frame: "remote_modal" } .row.bg-light-subtle.border.border-top.border-5.border-secondary.border-top-0.border-start-0.border-end-0 .col-2.d-flex.align-items-center %strong= t "skills.table.skill" diff --git a/config/routes.rb b/config/routes.rb index 9c883a220..0e7dc3c91 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -28,7 +28,12 @@ end end - resources :skills + + resources :skills do + collection do + get 'export', to: 'skills#export' + end + end # Outdated api routes namespace :api do