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 notes to constructor #987

Open
wants to merge 7 commits into
base: calculators-constructor
Choose a base branch
from

Conversation

alexy78
Copy link
Contributor

@alexy78 alexy78 commented Nov 28, 2024

Resolves:

Code reviewers

Second Level Review

Summary of issue

The current form for the calculator does not include fields for creating additional notes.

Summary of change

This update introduces two new Ukrainian and English note fields in the calculator form. The changes include creating a YAML file for TinyMCE styling, adding a Stimulus controller to handle TinyMCE initialization, creating a partial for the TinyMCE form, and writing tests for the new fields.

Знімок екрана 2024-11-28 о 16 47 00 Знімок екрана 2024-11-28 о 16 47 06

CHECK LIST

  • СI passed
  • Сode coverage >=95%
  • PR is reviewed manually again (to make sure you have 100% ready code)
  • All reviewers agreed to merge the PR
  • I've checked new feature as logged in and logged out user if needed
  • PR meets all conventions

Comment on lines 38 to 39
validates :english_additional_notes, length: { maximum: 150 }
validates :ukranian_additional_notes, length: { maximum: 150 }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а шо коротке таке? може довше зробити?

<%= tinymce_assets %>
<div data-controller="tinymce">
<div class="pt-4">
<%= f.label :ukranian_additional_notes, "Ukrainian Additional Notes" %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l18n?

</div>

<div class="pt-4 pb-4">
<%= f.label :english_additional_notes, "English Additional Notes" %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

то саме

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

локалізація

Comment on lines 1 to 16
import { Controller } from '@hotwired/stimulus'

export default class extends Controller {
static targets = ['input']

connect() {
let config = Object.assign({ target: this.inputTarget }, TinyMCERails.configuration.default )
tinymce.init(config)

}

disconnect () {
tinymce.remove()
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

порівняй тут гарно код і винеси конфіги в getter, також юзай 2 пробіли, а не 4 і думаю можна без object assign, просто обʼєкт заюзати

Comment on lines 38 to 39
validates :english_additional_notes, length: { maximum: 500 }
validates :ukranian_additional_notes, length: { maximum: 500 }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ну диви, ти молодець, що додала валідацію, але тут не враховані теги, тобто я напишу одну букву, а довжина її буде 7 символів, бо буде огорнута в як мінімум тег p, отож потрібно дещо специфічну валіадацію зробити

</div>

<div class="pt-4 pb-4">
<%= f.label :english_additional_notes, "English Additional Notes" %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

локалізація

Copy link

codecov bot commented Dec 1, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 86.60%. Comparing base (679ae88) to head (953013a).
Report is 30 commits behind head on calculators-constructor.

Files with missing lines Patch % Lines
app/models/calculator.rb 50.00% 2 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                     @@
##           calculators-constructor     #987      +/-   ##
===========================================================
- Coverage                    86.74%   86.60%   -0.14%     
===========================================================
  Files                           68       68              
  Lines                         1056     1060       +4     
===========================================================
+ Hits                           916      918       +2     
- Misses                         140      142       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

validates :ukranian_additional_notes,
length: {
maximum: 500,
tokenizer: ->(string) { ActionController::Base.helpers.strip_tags(string).chars }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use method to do that and test it

@@ -0,0 +1,14 @@
<%= tinymce_assets %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<%= tinymce_assets %>
<%= tinymce_assets %>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

align that all

Comment on lines +4 to +8
<% if I18n.locale == :uk %>
<%= raw calculator.ukranian_additional_notes %>
<% else %>
<%= raw calculator.english_additional_notes %>
<% end %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<% if I18n.locale == :uk %>
<%= raw calculator.ukranian_additional_notes %>
<% else %>
<%= raw calculator.english_additional_notes %>
<% end %>
<%== calculator.notes %>

then you have:
uk_notes
en_notes
and Translatable concern in a model

@@ -361,6 +361,8 @@ uk:
prohibited_to_update: " перешкоджають оновленню калькулятора"
prohibited_to_save: " перешкоджають збереженню калькулятора"
error: "помилки"
ukranian_additional_notes: "Додаткові нотатки українською"
english_additional_notes: "Додаткові нотатки англійською"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

у нас же нема основних нотаток)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
3 participants