Skip to content

Commit

Permalink
632/Re-Add Skillset Export (#633)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
ManuelMoeri and Robin481 committed Apr 2, 2024
1 parent 730648a commit 4e14977
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions app/assets/images/download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions app/controllers/skills_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions app/views/skills/index.html.haml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
7 changes: 6 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4e14977

Please sign in to comment.