Skip to content

Commit

Permalink
Merge pull request #349 from goinvo/fermion/view-cleanup-sign-out-bug…
Browse files Browse the repository at this point in the history
…-fix

Clean up of unused views, refactor existing forms, fix intermittent sign out bug 🤞🏻
  • Loading branch information
fermion authored Oct 12, 2024
2 parents 93ac590 + 39e8ebf commit ed99d78
Show file tree
Hide file tree
Showing 49 changed files with 308 additions and 1,448 deletions.
71 changes: 0 additions & 71 deletions app/controllers/assignments_controller.rb

This file was deleted.

55 changes: 0 additions & 55 deletions app/controllers/clients_controller.rb

This file was deleted.

54 changes: 0 additions & 54 deletions app/controllers/projects_controller.rb

This file was deleted.

6 changes: 5 additions & 1 deletion app/controllers/settings/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ def create
rescue ActiveRecord::RecordInvalid
@user = @command.user
@user.valid?
render :new

respond_to do |format|
format.html { render :new }
format.turbo_stream
end
end
end

Expand Down
19 changes: 16 additions & 3 deletions app/controllers/settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,24 @@ def show
end

def update
if current_company.update(update_params)
flash[:success] = "Company updated successfully"
# handle avatar changes first
if update_params[:avatar].present?
current_company.assign_attributes(avatar: update_params[:avatar])
current_company.attachment_changes.any? && current_company.save
end

current_company.assign_attributes(update_params.except(:avatar))

if current_company.save
flash[:success] = "Updates saved!"
redirect_to settings_path
else
render :show
flash.now[:error] = "Some information couldn't be saved."

respond_to do |format|
format.turbo_stream
format.html { render :show }
end
end
end

Expand Down
19 changes: 16 additions & 3 deletions app/controllers/users/profile_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@ def show
end

def update
if current_user.update(user_params)
flash[:notice] = 'Your profile was updated successfully'
# handle avatar changes first
if user_params[:avatar].present?
current_user.assign_attributes(avatar: user_params[:avatar])
current_user.attachment_changes.any? && current_user.save
end

current_user.assign_attributes(user_params.except(:avatar))

if current_user.save
flash[:success] = 'Your profile was updated successfully'
redirect_to users_profile_path
else
render :show
flash.now[:error] = 'There was a problem updating your profile'

respond_to do |format|
format.turbo_stream
format.html { render :show }
end
end
end

Expand Down
2 changes: 0 additions & 2 deletions app/helpers/assignments_helper.rb

This file was deleted.

2 changes: 0 additions & 2 deletions app/helpers/clients_helper.rb

This file was deleted.

2 changes: 0 additions & 2 deletions app/helpers/projects_helper.rb

This file was deleted.

13 changes: 13 additions & 0 deletions app/models/company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,17 @@ def can_access?(user:)
membership = memberships.find_by(user: user)
membership.present? && membership.active?
end

def restore_avatar
if avatar.attached? && avatar.changed?
original_picture = avatar.attachment_was
if original_picture
# Detach the current attachment
avatar.detach

# Reattach the original attachment
avatar.attach(original_picture)
end
end
end
end
22 changes: 0 additions & 22 deletions app/views/assignments/_assignment.html.erb

This file was deleted.

2 changes: 0 additions & 2 deletions app/views/assignments/_assignment.json.jbuilder

This file was deleted.

32 changes: 0 additions & 32 deletions app/views/assignments/_form.html.erb

This file was deleted.

8 changes: 0 additions & 8 deletions app/views/assignments/edit.html.erb

This file was deleted.

14 changes: 0 additions & 14 deletions app/views/assignments/index.html.erb

This file was deleted.

1 change: 0 additions & 1 deletion app/views/assignments/index.json.jbuilder

This file was deleted.

7 changes: 0 additions & 7 deletions app/views/assignments/new.html.erb

This file was deleted.

15 changes: 0 additions & 15 deletions app/views/assignments/show.html.erb

This file was deleted.

1 change: 0 additions & 1 deletion app/views/assignments/show.json.jbuilder

This file was deleted.

Loading

0 comments on commit ed99d78

Please sign in to comment.