Skip to content

Commit

Permalink
create controller method to load correct picture path, add uploads to…
Browse files Browse the repository at this point in the history
… assets path, move cancel button on edit view and fix view not loading when department name missing
  • Loading branch information
RandomTannenbaum committed Feb 23, 2024
1 parent 1342535 commit a81f39f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
10 changes: 10 additions & 0 deletions app/controllers/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
class PeopleController < CrudController
include ExportController

helper_method :picture_path

self.permitted_attrs = %i[birthdate location
marital_status updated_by name nationality nationality2 title
competence_notes company_id email department_id shortname]
Expand Down Expand Up @@ -40,4 +42,12 @@ def export
type: 'application/vnd.oasis.opendocument.text',
disposition: content_disposition('attachment', filename)
end

def picture_path
if @person.picture.file
@person.picture.url
else
"/default_avatar.png"
end
end
end
7 changes: 4 additions & 3 deletions app/views/people/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
= form_with model: @person do |form|
%div.d-flex.justify-content-between
%div.pe-5
%img.rounded-circle{src: @person.picture, width: '141', height: '141'}
%img.rounded-circle{src: picture_path, width: '141', height: '141'}
-# = form.file_field :picture
%div.pe-5.d-flex
%table
%tbody
Expand Down Expand Up @@ -61,5 +62,5 @@
%div.border.border-dark-subtle.mt-1.p-2.rounded
- @person.language_skills.each do |language|
%div.mb-1= "#{language.language}: #{language.level} - #{language.certificate}"
= form.submit :Speichern, class: "btn btn-primary"
= link_to "Abbrechen", person_path
= form.submit :Speichern, class: "btn btn-primary me-3"
= link_to "Abbrechen", person_path
4 changes: 2 additions & 2 deletions app/views/people/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
%turbo-frame{id: "#{dom_id @person}"}
%div.d-flex.justify-content-between
%div
%img.rounded-circle{src: @person.picture, width: '141', height: '141'}
-# %img.rounded-circle{src: @person.picture, width: '141', height: '141'}
%div.mt-3= link_to "Bearbeiten", edit_person_path
%div.pe-5
%table
Expand All @@ -26,7 +26,7 @@
%td= "#{person_role.role.name} #{person_role.person_role_level.level} #{person_role.percent.to_i}%"
%th.fw-light Organisationseinheit
%tr
%td= @person.department.name
%td= @person.department&.name
%th.fw-light Firma
%tr
%td= @person.company.name
Expand Down
3 changes: 2 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def keycloak_disabled?
KEYCLOAK_ENV_VARS.none? { |e| ENV[e].present? } &&
ENV['KEYCLOAK_DISABLED'].present?
end

config.assets.enabled = true
config.assets.paths << Rails.root.join("uploads")
end
end

0 comments on commit a81f39f

Please sign in to comment.