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

Added color of certificate element #438

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

pavel-pasechnik
Copy link

Done in this PR:

  1. Added a color attribute to the CertificateTemplateEntry model:

    • The color field was added to the database table using migration:
      • Type: string.
      • Default value: "#000000".
      • The field cannot be NULL.
  2. Added validation for the color attribute:

    • Checks that color is a valid string HEX code of color (e.g., #FFFFFF or #FFF).
    • The HEX_COLOR_REGEX regular expression is used to validate the format.
  3. Implemented the default value setting in the model:

    • If color is not set when the object is created, it is automatically set to "#000000".
  4. Updated the CertificateTemplateEntry model:

    • Added validation for the presence and format of color.
    • Used before_validation to set the default value.
  5. Updated the database:

    • Performed migration to add the color column with the above parameters.
  6. Implemented localization:

    • Added translations for the color field in Russian and Ukrainian:
      • Russian: Цвет.
      • Ukrainian: Колір.

screencapture-localhost-3000-certificate-templates-1-edit-2024-11-26-16_25_30

@pavel-pasechnik
Copy link
Author

Changelog

  • Added support for the color field in SimpleForm via a custom input.
  • Created color_input.rb file in app/inputs, which defines the rendering of <input type="color">.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant