From aae091f32e7cf7afa6199d714fe4a1625033f3a1 Mon Sep 17 00:00:00 2001 From: Hilary Stohs-Krause Date: Wed, 8 May 2024 12:24:20 -0400 Subject: [PATCH 1/3] Issue 564 No clear indicator in the header re: what page you're currently viewing --- app/assets/stylesheets/application.css | 9 +++++++-- app/helpers/navigation_helper.rb | 5 +++++ app/views/layouts/application.html.erb | 8 ++++---- 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 app/helpers/navigation_helper.rb diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 820998a..7472562 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -45,8 +45,7 @@ hr { } .navigation a { - color: #9b9b9b; - margin-left: 20px; + color: #757575; } .navigation a:hover { @@ -81,6 +80,12 @@ li .heading { .navigation ul li { display: inline; font-size: 18px; + margin-left: 20px; + padding-bottom: 10px; +} + +.navigation ul li.active { + border-bottom: 1px solid #757575; } .row { diff --git a/app/helpers/navigation_helper.rb b/app/helpers/navigation_helper.rb new file mode 100644 index 0000000..511fd85 --- /dev/null +++ b/app/helpers/navigation_helper.rb @@ -0,0 +1,5 @@ +module NavigationHelper + def header_link_class(site_section_path) + return "active" if request.path.split("/").second == site_section_path + end +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 6414e69..9947881 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -21,10 +21,10 @@ From 887976fe6b561482abded9d983a2af71b8f71ac3 Mon Sep 17 00:00:00 2001 From: Hilary Stohs-Krause Date: Wed, 8 May 2024 14:48:01 -0400 Subject: [PATCH 2/3] adds error handling for nonexistent tag show page; styles flash notice and alert --- app/assets/stylesheets/application.css | 24 +++++++++++++++++++++++ app/controllers/submissions_controller.rb | 6 +++++- app/controllers/tags_controller.rb | 11 ++++++++++- app/views/layouts/application.html.erb | 2 +- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 7472562..59e09bf 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -32,6 +32,23 @@ hr { margin: 5px 5px 25px 5px; } +.flash { + font-weight: 500; + margin-top: 20px; + padding: 20px; +} + +.flash.notice { + background-color: #DCF5F9; + border: 1px solid #147694; /* same color as the standard link color */ + +} + +.flash.alert { + background-color: #FCEDE9; + border: 1px solid #9d3515; /* same color as the error color */ +} + .button-add { margin-bottom: 30px; } @@ -42,6 +59,7 @@ hr { .navigation { margin-top: 5%; + position: relative; } .navigation a { @@ -146,9 +164,15 @@ fieldset.fieldset legend { margin-right: 0; } + .navigation ul li.active { + border-bottom: 0; + font-weight: 500; + } + .navigation a { margin-left: 0px; } + .navigation button { margin-left: 0px; } diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index d0eefc5..a964fe7 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -12,6 +12,8 @@ def create else @proposal = @submission.proposal @events = Event.all.order('name ASC') + flash[:alert] = 'Failed to create submission; please check for errors.' + render 'new' end end @@ -24,10 +26,12 @@ def edit def update @submission = Submission.find(params[:id]) @proposal = @submission.proposal + if verify_recaptcha(model: @submission) && @submission.update(submission_params) redirect_to proposal_path(@proposal) else - flash[:alert] = 'Failed to update submission' + flash[:alert] = 'Failed to update submission; please check for errors.' + render 'edit' end end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index c07b0dd..e2c3d7d 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -5,6 +5,15 @@ def index def show @tag = ActsAsTaggableOn::Tag.find_by(name: params[:id]) - @proposals = Proposal.tagged_with(@tag.name) + + if @tag.present? + @proposals = Proposal.tagged_with(@tag.name) + else + notice = + "We don't currently have a tag for \"#{params[:id]}\" - but + you can create a proposal and add it as a new tag." + + redirect_to tags_path, notice: notice + end end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 9947881..e65d82c 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -14,7 +14,7 @@
<% flash.each do |key, value| %> - <%= content_tag :div, value, class: "flash #{key}" %> + <%= content_tag :div, value.html_safe, class: "flash #{key}" %> <% end %>