Skip to content

Commit

Permalink
user settings
Browse files Browse the repository at this point in the history
  • Loading branch information
michelson committed May 19, 2024
1 parent 694a75d commit 75169a4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
8 changes: 7 additions & 1 deletion app/controllers/user_settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ def update

def user_attributes
params.require(:user).permit(
:username, :last_name, :first_name, :bio, :avatar, :country, :city,
:username,
:hide_username_from_profile,
:last_name,
:first_name,
:bio, :avatar,
:country,
:city,
:email, :current_password,
:new_follower_email,
:new_follower_app,
Expand Down
3 changes: 3 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class User < ApplicationRecord

normalizes :username, with: -> username { username.parameterize }

validates_presence_of :username, on: :update, message: "can't be blank"

include User::OmniAuthExtension

store_attribute :notification_settings, :new_follower_email, :boolean
Expand All @@ -56,6 +58,7 @@ class User < ApplicationRecord
store_attribute :notification_settings, :new_message_app, :boolean
store_attribute :notification_settings, :like_and_plays_on_your_post_email, :boolean

store_attribute :settings, :hide_username_from_profile, :boolean
store_attribute :settings, :pst_enabled, :boolean
store_attribute :settings, :tbk_commerce_code, :string
store_attribute :settings, :tbk_test_mode, :boolean
Expand Down
6 changes: 5 additions & 1 deletion app/views/labels/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
<%= image_tag @user.avatar_url(:medium), class: "sm:w-48 sm:h-48 w-16 h-16 rounded-full" %>
</div>
<div class="text-default sm:mt-6 space-y-1 sm:space-y-2 flex flex-col justify-start items-start">
<p class="sm:text-3xl text-sm font-extrabold bg-default p-1 inline-block mt-2"> <%= @user.username %> </p>
<% if !@user.hide_username_from_profile %>
<p class="sm:text-3xl text-sm font-extrabold bg-default p-1 inline-block mt-2">
<%= @user.username %>
</p>
<% end %>
<p class="sm:text-lg text-xs font-light bg-default p-1 inline-block"> <%= @user.first_name %> <%= @user.last_name%> </p>
<p class="sm:text-lg text-xs font-light bg-default p-1 inline-block"> <%= @user.country %> <%= @user.city %> </p>
</div>
Expand Down
5 changes: 4 additions & 1 deletion app/views/user_settings/_profile_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
<div class="sm:col-span-6">
<%= form.label gettext("Username") %>

<div class="mt-1 flex rounded-md shadow-sm">
<div class="my-1 flex rounded-md shadow-sm">
<span class="inline-flex items-center px-3 rounded-l-md border border-r-0 border-blue-gray-300 bg-blue-gray-50 text-blue-gray-500 sm:text-sm">
<%= ENV['APP_NAME'] %>
</span>
<%= form.text_field :username, label: false %>
</div>

<%= form.check_box :hide_username_from_profile, label: "Hide username from profile page" %>

</div>

<div class="sm:col-span-3">
Expand Down
2 changes: 1 addition & 1 deletion app/views/user_settings/_security_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="max-w-3xl mx-auto py-10 px-4 sm:px-6 lg:py-12 lg:px-8">
<h1 class="text-3xl font-extrabold text-blue-gray-900">Security</h1>

<%= form_for @user, url: user_setting_path(@user.username, :secutiry),
<%= form_for @user, url: user_setting_path(@user.username, :security),
class: "space-y-8 divide-y divide-gray-200 dark:divide-gray-800" do |form| %>

<div class="grid grid-cols-1 gap-y-6 sm:grid-cols-6 sm:gap-x-6">
Expand Down
10 changes: 8 additions & 2 deletions app/views/users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
<%= image_tag @user.avatar_url(:medium), class: "sm:w-48 sm:h-48 w-16 h-16 rounded-full" %>
</div>
<div class="text-default sm:mt-6 space-y-1 sm:space-y-2 flex flex-col justify-start items-start">
<p class="sm:text-3xl text-sm font-extrabold bg-default p-1 inline-block mt-2"> <%= @user.username %> </p>
<p class="sm:text-lg text-xs font-light bg-default p-1 inline-block"> <%= @user.first_name %> <%= @user.last_name%> </p>
<p class="sm:text-3xl text-sm font-extrabold bg-default p-1 inline-block mt-2">
<%= @user.hide_username_from_profile ? "#{@user.first_name} #{@user.last_name}" : @user.username %>
</p>


<% if !@user.hide_username_from_profile %>
<p class="sm:text-lg text-xs font-light bg-default p-1 inline-block"> <%= @user.first_name %> <%= @user.last_name%> </p>
<% end %>
<p class="sm:text-lg text-xs font-light bg-default p-1 inline-block"> <%= @user.country %> <%= @user.city %> </p>
</div>
</div>
Expand Down

0 comments on commit 75169a4

Please sign in to comment.