From 84a85fe1a48925307cffa33ff328eca2abd424f6 Mon Sep 17 00:00:00 2001 From: Michael Kohl Date: Mon, 19 Jul 2021 18:42:36 +0700 Subject: [PATCH] Remove `color_field` input type from profiles (#14239) * Move brand color validation to Users::Setting * Fix specs * Remove color_field as ProfileField input type --- app/models/profile_field.rb | 3 +- app/validators/profile_validator.rb | 4 --- app/views/users/_profile.html.erb | 14 --------- spec/fixtures/files/profile_fields.csv | 4 +-- .../profile_fields/import_from_csv_spec.rb | 30 +++++++++---------- 5 files changed, 17 insertions(+), 38 deletions(-) diff --git a/app/models/profile_field.rb b/app/models/profile_field.rb index 0273ede16..383c8dbd7 100644 --- a/app/models/profile_field.rb +++ b/app/models/profile_field.rb @@ -5,8 +5,7 @@ class ProfileField < ApplicationRecord enum input_type: { text_field: 0, text_area: 1, - check_box: 2, - color_field: 3 + check_box: 2 } enum display_area: { diff --git a/app/validators/profile_validator.rb b/app/validators/profile_validator.rb index 678b8146d..1c9f76e58 100644 --- a/app/validators/profile_validator.rb +++ b/app/validators/profile_validator.rb @@ -42,10 +42,6 @@ class ProfileValidator < ActiveModel::Validator true # checkboxes are always valid end - def color_field_valid?(_record, _attribute) - true # we do not currently validate color fields here - end - def text_area_valid?(record, attribute) text = record.public_send(attribute) text.nil? || text.size <= MAX_TEXT_AREA_LENGTH diff --git a/app/views/users/_profile.html.erb b/app/views/users/_profile.html.erb index fee68612b..dc1a690ac 100644 --- a/app/views/users/_profile.html.erb +++ b/app/views/users/_profile.html.erb @@ -107,20 +107,6 @@ - <% elsif field["input_type"] == "color_field" %> - -
- <%= f.public_send("text_field", "profile[#{field.attribute_name}]", - value: profile.public_send(field.attribute_name), - placeholder: field["placeholder_text"], - class: "crayons-textfield js-color-field") %> - <%= f.public_send(field["input_type"], - "profile[#{field.attribute_name}]", - value: profile.public_send(field.attribute_name), - class: "crayons-color-selector js-color-field ml-2") %> -
<% else %>