From 142edb664e9a89cb8156f2c6124a6ca03b16c6cd Mon Sep 17 00:00:00 2001 From: Alessandro Minali Date: Wed, 19 Aug 2020 13:58:43 +0000 Subject: [PATCH] Remove 'dynamic_form' (#888) Old, unmaintained dep for trivial code. --- Gemfile | 1 - Gemfile.lock | 2 -- app/assets/stylesheets/application.css | 25 ++++++----------------- app/helpers/application_helper.rb | 12 +++++++---- app/views/login/set_new_password.html.erb | 2 +- app/views/messages/_form.html.erb | 2 +- app/views/settings/index.html.erb | 2 +- app/views/signup/invited.html.erb | 2 +- app/views/stories/_form_errors.html.erb | 2 +- app/views/users/show.html.erb | 2 +- 10 files changed, 20 insertions(+), 32 deletions(-) diff --git a/Gemfile b/Gemfile index 041f3fd3..63e28358 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,6 @@ gem "activerecord-typedstore" gem 'sprockets-rails', '2.3.3' # js -gem "dynamic_form" gem "jquery-rails", "~> 4.3" gem "json" gem "uglifier", ">= 1.3.0" diff --git a/Gemfile.lock b/Gemfile.lock index 636ffbe6..19c45319 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,7 +88,6 @@ GEM crass (1.0.6) database_cleaner (1.8.5) diff-lcs (1.4.4) - dynamic_form (1.1.4) erubi (1.9.0) exception_notification (4.4.3) actionmailer (>= 4.0, < 7) @@ -284,7 +283,6 @@ DEPENDENCIES capybara commonmarker (~> 0.14) database_cleaner - dynamic_form exception_notification factory_bot_rails faker diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 5ea69575..1e7d69c9 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1156,8 +1156,7 @@ table.data pre { div.flash-error, div.flash-notice, -div.flash-success, -div.errorExplanation { +div.flash-success { position: relative; padding: 7px 15px; margin-bottom: 18px; @@ -1175,8 +1174,7 @@ div.errorExplanation { } div.flash-error a, div.flash-notice a, -div.flash-success a, -div.errorExplanation a { +div.flash-success a { font-weight: bold; color: #404040; } @@ -1187,20 +1185,17 @@ div.flash-success p a { } div.flash-error p, div.flash-notice p, -div.flash-success p, -div.errorExplanation p { +div.flash-success p { margin-bottom: 0; } div.flash-error div, div.flash-notice div, -div.flash-success div, -div.errorExplanation div { +div.flash-success div { margin-top: 5px; margin-bottom: 2px; line-height: 28px; } -div.flash-error, -div.errorExplanation { +div.flash-error { background-color: #fdcfcc; background-repeat: repeat-x; background-image: linear-gradient(top, #ee5f5b, #c43c35); @@ -1227,19 +1222,11 @@ div.flash-notice { div.flash-error h2, div.flash-notice h2, -div.flash-success h2, -div.errorExplanation h2 { +div.flash-success h2 { font-size: 1.25em; margin: 0; } - -/* for error_messages_for() */ -div.fieldWithErrors { - display: inline; -} - - /* select2 deuglification */ .select2-container-multi.select2-container-active .select2-choices { diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0c6869fc..1f19c73b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -21,14 +21,18 @@ module ApplicationHelper }, " ") end - def errors_for(object, _message = nil) + def errors_for(object) html = "" unless object.errors.blank? - html << "
\n" + html << "
" + html << "

#{pluralize(object.errors.count, 'error')} prohibited this \ + #{object.class.name.downcase} from being saved

" + html << "

There were the problems with the following fields:

" + html << "
    " object.errors.full_messages.each do |error| - html << error << "
    " + html << "
  • #{error}
  • " end - html << "
\n" + html << "
" end raw(html) diff --git a/app/views/login/set_new_password.html.erb b/app/views/login/set_new_password.html.erb index 7c762858..c1a36d11 100644 --- a/app/views/login/set_new_password.html.erb +++ b/app/views/login/set_new_password.html.erb @@ -4,7 +4,7 @@ <%= form_with url: set_new_password_path, autocomplete: 'off', local: true do |f| %> - <%= error_messages_for(@reset_user) %> + <%= errors_for(@reset_user) %> <%= f.hidden_field "token", :value => params[:token] %> diff --git a/app/views/messages/_form.html.erb b/app/views/messages/_form.html.erb index 8bf96cb4..4a3f8d38 100644 --- a/app/views/messages/_form.html.erb +++ b/app/views/messages/_form.html.erb @@ -1,5 +1,5 @@ <%= form_with model: @new_message, url: new_message, method: :post, local: true do |f| %> - <%= error_messages_for @new_message %> + <%= errors_for @new_message %> <% if replying %> <%= f.hidden_field :recipient_username %> diff --git a/app/views/settings/index.html.erb b/app/views/settings/index.html.erb index a7b5ef9b..63de925c 100644 --- a/app/views/settings/index.html.erb +++ b/app/views/settings/index.html.erb @@ -11,7 +11,7 @@ <%= form_with model: @edit_user, url: settings_path, method: :post, id: 'edit_user', local: true do |f| %> - <%= error_messages_for f.object %> + <%= errors_for f.object %>
<%= f.label :username, "Username:", :class => "required" %> diff --git a/app/views/signup/invited.html.erb b/app/views/signup/invited.html.erb index 491364b7..2a32571d 100644 --- a/app/views/signup/invited.html.erb +++ b/app/views/signup/invited.html.erb @@ -11,7 +11,7 @@ alerts. Your username can be changed later.

- <%= error_messages_for(@new_user) %> + <%= errors_for(@new_user) %> <% if not Rails.application.open_signups? %> <%= f.hidden_field "invitation_code", :value => @invitation.code, :name => :invitation_code %> diff --git a/app/views/stories/_form_errors.html.erb b/app/views/stories/_form_errors.html.erb index f7afb195..c23c1aef 100644 --- a/app/views/stories/_form_errors.html.erb +++ b/app/views/stories/_form_errors.html.erb @@ -1,7 +1,7 @@
<% if story.errors.any? %> - <%= error_messages_for story %> + <%= errors_for story %> <% elsif !story.errors.any? && story.public_similar_stories.any? %>

Note: This story was already submitted <%= time_ago_in_words_label(story.most_recent_similar.created_at) %>, but may be submitted again.

diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 8dc47d6a..71dcf43d 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -191,7 +191,7 @@ mod_notes: ModNote.for(@showing_user).limit(10), } %> <%= form_with model: @mod_note, method: :post, local: true do |f| %> - <%= error_messages_for @mod_note %> + <%= errors_for @mod_note %> <%= f.hidden_field :username %>
<%= f.label :note, "New Note:", :class => "required" %>