Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to display navbar #691

Merged
merged 5 commits into from
Sep 13, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/controllers/announcements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class AnnouncementsController < ApplicationController
before_action :authenticate_user!, except: [:new, :create]
before_action :set_announcement, only: [:show, :edit, :update, :destroy]

layout "without_navbar", only: [:new, :create, :show]
layout :determine_layout, only: [:new, :create, :show]
svileshina marked this conversation as resolved.
Show resolved Hide resolved

def index
@announcements = Announcement.order(created_at: :desc)
Expand Down Expand Up @@ -47,6 +47,10 @@ def set_announcement
@announcement = Announcement.find(params[:id])
end

def determine_layout
"without_navbar" unless @system_setting.display_navbar
svileshina marked this conversation as resolved.
Show resolved Hide resolved
end

def announcement_params
params.require(:announcement).permit(
:name,
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/community_resources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class CommunityResourcesController < ApplicationController
before_action :authenticate_user!, except: [:new, :create]
before_action :set_community_resource, only: [:show, :edit, :update, :destroy]

layout "without_navbar", only: [:new, :create, :show]
layout :determine_layout, only: [:new, :create, :show]

def index
@community_resources = CommunityResource.includes(:organization).references(:organization).order(created_at: :desc)
Expand Down Expand Up @@ -56,6 +56,10 @@ def set_form_dropdowns
@available_tags = Category.visible.pluck(:name) + @community_resource&.tag_list || []
end

def determine_layout
"without_navbar" unless @system_setting.display_navbar
end

def community_resource_params
params.require(:community_resource).permit(
:description,
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/public_pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
class PublicPagesController < PublicController
layout "without_navbar", only: [:announcements, :community_resources]
layout :determine_layout

def about
@about_us_text = HtmlSanitizer.new(@system_setting.about_us_text).sanitize_for_rails
end

def determine_layout
"without_navbar" unless @system_setting.display_navbar
end

def announcements
@announcements = Announcement.where(is_approved: true).published
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/system_settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def system_setting_params
:allow_sms,
:exchange_type,
:separate_asks_offers,
:display_navbar,

:announcements_module,
:community_resources_module,
Expand Down
1 change: 1 addition & 0 deletions app/views/system_settings/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<%= f.input :exchange_type, as: :select, collection: @exchange_types %>
<%= f.input :separate_asks_offers, as: :radio_buttons, label: "Separate ask and offer forms" %>
<%= f.input :allow_sms, as: :radio_buttons %>
<%= f.input :display_navbar, as: :radio_buttons, hint: "Display the navbar on the Community Resources and Annoucements pages" %>
<%= f.input :community_resources_module, as: :radio_buttons %>
<%= f.input :announcements_module, as: :radio_buttons %>
<%= f.input :positions_module, as: :radio_buttons %>
Expand Down
4 changes: 4 additions & 0 deletions app/views/system_settings/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<strong>Separate ask and offer forms</strong>
</p>

<p>
<%= yes_no(@system_setting.display_navbar) %>
<strong>Display the navbar</strong> on the Community Resources and Annoucements pages
</p>

<hr>
<div class="subtitle is-5">Modules</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddDisplayNavbarToSystemSettings < ActiveRecord::Migration[6.0]
def change
add_column :system_settings, :display_navbar, :boolean, default: false
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2020_06_25_153314) do
ActiveRecord::Schema.define(version: 2020_09_06_172102) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -445,6 +445,7 @@
t.string "confirmation_page_text_body"
t.string "confirmation_page_text_link_header"
t.string "confirmation_page_text_footer"
t.boolean "display_navbar", default: false
end

create_table "taggings", id: :serial, force: :cascade do |t|
Expand Down
1 change: 1 addition & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
User.where(email: "#{ENV["SYSTEM_EMAIL"]}").first_or_create!(
password: "#{ENV["SYSTEM_PASSWORD"]}",
confirmed_at: Time.current,
role: "sys_admin"
)

# create categories -- these are then editable by admin users
Expand Down