From 785b8fd78f0f5d39c3dae517c4433d4d730414d5 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 8 Oct 2019 10:57:35 +0200 Subject: [PATCH 1/2] Remove simple form from mail_templates --- app/views/admin/mail_templates/edit.html.haml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/views/admin/mail_templates/edit.html.haml b/app/views/admin/mail_templates/edit.html.haml index c423fe418..e515cf7f3 100644 --- a/app/views/admin/mail_templates/edit.html.haml +++ b/app/views/admin/mail_templates/edit.html.haml @@ -4,17 +4,23 @@ %h3 = @mail_template.class.const_get(:DISPLAYED_NAME) - = simple_form_for @mail_template, + = form_for @mail_template, as: 'mail_template', url: admin_procedure_mail_template_path(@procedure, @mail_template.class.const_get(:SLUG)), method: :put do |f| .row .col-md-6 - = f.input :subject, label: "Objet de l'email" - = f.input :body, label: "Corps de l'email", input_html: { class: 'wysihtml5' } + .form-group.string.optional.mail_template_subject + = f.label :subject, "Objet de l'email", class: 'control-label string optional' + = f.text_field :subject, class: 'form-control string optional' + + .form-group.text.optional.mail_template_body + = f.label :body, "Corps de l'email", class: 'control-label string optional' + = f.text_area :body, class: 'wysihtml5 form-control text optional' + .text-right = link_to "Annuler", admin_procedure_mail_templates_path(@procedure), class: "btn btn-default" - = f.button :submit, 'Mettre à jour', class: "btn-success" + = f.submit 'Mettre à jour', class: "btn btn-default btn-success" = link_to "Prévisualiser", preview_procedure_mail_template_path(@procedure, @mail_template.class.const_get(:SLUG)), class: "btn btn-primary", target: "_blank" .row From f31c184b56f9dfc2a60dabeea713d1a8b31d81aa Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 8 Oct 2019 10:58:28 +0200 Subject: [PATCH 2/2] [fix #1537] Remove simple_form gem --- Gemfile | 1 - Gemfile.lock | 4 - config/initializers/simple_form.rb | 169 ------------------- config/initializers/simple_form_bootstrap.rb | 154 ----------------- 4 files changed, 328 deletions(-) delete mode 100644 config/initializers/simple_form.rb delete mode 100644 config/initializers/simple_form_bootstrap.rb diff --git a/Gemfile b/Gemfile index 1690262c7..a7b346436 100644 --- a/Gemfile +++ b/Gemfile @@ -68,7 +68,6 @@ gem 'sassc-rails' # Use SCSS for stylesheets gem 'scenic' gem 'select2-rails' gem 'sentry-raven' -gem 'simple_form' gem 'skylight' gem 'smart_listing' gem 'spreadsheet_architect' diff --git a/Gemfile.lock b/Gemfile.lock index 92aa4b718..1336fb19c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -616,9 +616,6 @@ GEM shellany (0.0.1) shoulda-matchers (4.0.1) activesupport (>= 4.2.0) - simple_form (4.1.0) - actionpack (>= 5.0) - activemodel (>= 5.0) simple_xlsx_reader (1.0.4) nokogiri rubyzip @@ -809,7 +806,6 @@ DEPENDENCIES select2-rails sentry-raven shoulda-matchers - simple_form simple_xlsx_reader skylight smart_listing diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb deleted file mode 100644 index f306c195a..000000000 --- a/config/initializers/simple_form.rb +++ /dev/null @@ -1,169 +0,0 @@ -# Use this setup block to configure all options available in SimpleForm. -SimpleForm.setup do |config| - # Wrappers are used by the form builder to generate a - # complete input. You can remove any component from the - # wrapper, change the order or even add your own to the - # stack. The options given below are used to wrap the - # whole input. - config.wrappers :default, class: :input, - hint_class: :field_with_hint, error_class: :field_with_errors do |b| - ## Extensions enabled by default - # Any of these extensions can be disabled for a - # given input by passing: `f.input EXTENSION_NAME => false`. - # You can make any of these extensions optional by - # renaming `b.use` to `b.optional`. - - # Determines whether to use HTML5 (:email, :url, ...) - # and required attributes - b.use :html5 - - # Calculates placeholders automatically from I18n - # You can also pass a string as f.input placeholder: "Placeholder" - b.use :placeholder - - ## Optional extensions - # They are disabled unless you pass `f.input EXTENSION_NAME => true` - # to the input. If so, they will retrieve the values from the model - # if any exists. If you want to enable any of those - # extensions by default, you can change `b.optional` to `b.use`. - - # Calculates maxlength from length validations for string inputs - # and/or database column lengths - b.optional :maxlength - - # Calculate minlength from length validations for string inputs - b.optional :minlength - - # Calculates pattern from format validations for string inputs - b.optional :pattern - - # Calculates min and max from length validations for numeric inputs - b.optional :min_max - - # Calculates readonly automatically from readonly attributes - b.optional :readonly - - ## Inputs - b.use :label_input - b.use :hint, wrap_with: { tag: :span, class: :hint } - b.use :error, wrap_with: { tag: :span, class: :error } - - ## full_messages_for - # If you want to display the full error message for the attribute, you can - # use the component :full_error, like: - # - # b.use :full_error, wrap_with: { tag: :span, class: :error } - end - - # The default wrapper to be used by the FormBuilder. - config.default_wrapper = :default - - # Define the way to render check boxes / radio buttons with labels. - # Defaults to :nested for bootstrap config. - # inline: input + label - # nested: label > input - config.boolean_style = :nested - - # Default class for buttons - config.button_class = 'btn' - - # Method used to tidy up errors. Specify any Rails Array method. - # :first lists the first message for each field. - # Use :to_sentence to list all errors for each field. - # config.error_method = :first - - # Default tag used for error notification helper. - config.error_notification_tag = :div - - # CSS class to add for error notification helper. - config.error_notification_class = 'error_notification' - - # ID to add for error notification helper. - # config.error_notification_id = nil - - # Series of attempts to detect a default label method for collection. - # config.collection_label_methods = [ :to_label, :name, :title, :to_s ] - - # Series of attempts to detect a default value method for collection. - # config.collection_value_methods = [ :id, :to_s ] - - # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none. - # config.collection_wrapper_tag = nil - - # You can define the class to use on all collection wrappers. Defaulting to none. - # config.collection_wrapper_class = nil - - # You can wrap each item in a collection of radio/check boxes with a tag, - # defaulting to :span. - # config.item_wrapper_tag = :span - - # You can define a class to use in all item wrappers. Defaulting to none. - # config.item_wrapper_class = nil - - # How the label text should be generated altogether with the required text. - # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" } - - # You can define the class to use on all labels. Default is nil. - # config.label_class = nil - - # You can define the default class to be used on forms. Can be overriden - # with `html: { :class }`. Defaulting to none. - # config.default_form_class = nil - - # You can define which elements should obtain additional classes - # config.generate_additional_classes_for = [:wrapper, :label, :input] - - # Whether attributes are required by default (or not). Default is true. - # config.required_by_default = true - - # Tell browsers whether to use the native HTML5 validations (novalidate form option). - # These validations are enabled in SimpleForm's internal config but disabled by default - # in this configuration, which is recommended due to some quirks from different browsers. - # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations, - # change this configuration to true. - config.browser_validations = false - - # Collection of methods to detect if a file type was given. - # config.file_methods = [ :mounted_as, :file?, :public_filename ] - - # Custom mappings for input types. This should be a hash containing a regexp - # to match as key, and the input type that will be used when the field name - # matches the regexp as value. - # config.input_mappings = { /count/ => :integer } - - # Custom wrappers for input types. This should be a hash containing an input - # type as key and the wrapper that will be used for all inputs with specified type. - # config.wrapper_mappings = { string: :prepend } - - # Namespaces where SimpleForm should look for custom input classes that - # override default inputs. - # config.custom_inputs_namespaces << "CustomInputs" - - # Default priority for time_zone inputs. - # config.time_zone_priority = nil - - # Default priority for country inputs. - # config.country_priority = nil - - # When false, do not use translations for labels. - # config.translate_labels = true - - # Automatically discover new inputs in Rails' autoload path. - # config.inputs_discovery = true - - # Cache SimpleForm inputs discovery - # config.cache_discovery = !Rails.env.development? - - # Default class for inputs - # config.input_class = nil - - # Define the default class of the input wrapper of the boolean input. - config.boolean_label_class = 'checkbox' - - # Defines if the default input wrapper class should be included in radio - # collection wrappers. - # config.include_default_input_wrapper_class = true - - # Defines which i18n scope will be used in Simple Form. - # config.i18n_scope = 'simple_form' -end diff --git a/config/initializers/simple_form_bootstrap.rb b/config/initializers/simple_form_bootstrap.rb deleted file mode 100644 index c7705e8e7..000000000 --- a/config/initializers/simple_form_bootstrap.rb +++ /dev/null @@ -1,154 +0,0 @@ -# Use this setup block to configure all options available in SimpleForm. -SimpleForm.setup do |config| - config.error_notification_class = 'alert alert-danger' - config.button_class = 'btn btn-default' - config.boolean_label_class = nil - - config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| - b.use :html5 - b.use :placeholder - b.optional :maxlength - b.optional :minlength - b.optional :pattern - b.optional :min_max - b.optional :readonly - b.use :label, class: 'control-label' - - b.use :input, class: 'form-control' - b.use :error, wrap_with: { tag: 'span', class: 'help-block' } - b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } - end - - config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| - b.use :html5 - b.use :placeholder - b.optional :maxlength - b.optional :minlength - b.optional :readonly - b.use :label, class: 'control-label' - - b.use :input - b.use :error, wrap_with: { tag: 'span', class: 'help-block' } - b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } - end - - config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| - b.use :html5 - b.optional :readonly - - b.wrapper tag: 'div', class: 'checkbox' do |ba| - ba.use :label_input - end - - b.use :error, wrap_with: { tag: 'span', class: 'help-block' } - b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } - end - - config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| - b.use :html5 - b.optional :readonly - b.use :label, class: 'control-label' - b.use :input - b.use :error, wrap_with: { tag: 'span', class: 'help-block' } - b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } - end - - config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| - b.use :html5 - b.use :placeholder - b.optional :maxlength - b.optional :minlength - b.optional :pattern - b.optional :min_max - b.optional :readonly - b.use :label, class: 'col-sm-3 control-label' - - b.wrapper tag: 'div', class: 'col-sm-9' do |ba| - ba.use :input, class: 'form-control' - ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } - ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } - end - end - - config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| - b.use :html5 - b.use :placeholder - b.optional :maxlength - b.optional :minlength - b.optional :readonly - b.use :label, class: 'col-sm-3 control-label' - - b.wrapper tag: 'div', class: 'col-sm-9' do |ba| - ba.use :input - ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } - ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } - end - end - - config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| - b.use :html5 - b.optional :readonly - - b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr| - wr.wrapper tag: 'div', class: 'checkbox' do |ba| - ba.use :label_input - end - - wr.use :error, wrap_with: { tag: 'span', class: 'help-block' } - wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' } - end - end - - config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| - b.use :html5 - b.optional :readonly - - b.use :label, class: 'col-sm-3 control-label' - - b.wrapper tag: 'div', class: 'col-sm-9' do |ba| - ba.use :input - ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } - ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } - end - end - - config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| - b.use :html5 - b.use :placeholder - b.optional :maxlength - b.optional :minlength - b.optional :pattern - b.optional :min_max - b.optional :readonly - b.use :label, class: 'sr-only' - - b.use :input, class: 'form-control' - b.use :error, wrap_with: { tag: 'span', class: 'help-block' } - b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } - end - - config.wrappers :multi_select, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| - b.use :html5 - b.optional :readonly - b.use :label, class: 'control-label' - b.wrapper tag: 'div', class: 'form-inline' do |ba| - ba.use :input, class: 'form-control' - ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } - ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } - end - end - # Wrappers for forms and inputs using the Bootstrap toolkit. - # Check the Bootstrap docs (http://getbootstrap.com) - # to learn about the different styles for forms and inputs, - # buttons and other elements. - config.default_wrapper = :vertical_form - config.wrapper_mappings = { - check_boxes: :vertical_radio_and_checkboxes, - radio_buttons: :vertical_radio_and_checkboxes, - file: :vertical_file_input, - boolean: :vertical_boolean, - datetime: :multi_select, - date: :multi_select, - time: :multi_select - } -end