-
Notifications
You must be signed in to change notification settings - Fork 10
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
base: calculators-constructor
Are you sure you want to change the base?
Conversation
app/models/calculator.rb
Outdated
validates :english_additional_notes, length: { maximum: 150 } | ||
validates :ukranian_additional_notes, length: { maximum: 150 } |
There was a problem hiding this comment.
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" %> |
There was a problem hiding this comment.
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" %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
то саме
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
локалізація
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() | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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, просто обʼєкт заюзати
app/models/calculator.rb
Outdated
validates :english_additional_notes, length: { maximum: 500 } | ||
validates :ukranian_additional_notes, length: { maximum: 500 } |
There was a problem hiding this comment.
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" %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
локалізація
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## calculators-constructor #987 +/- ##
===========================================================
+ Coverage 89.14% 89.19% +0.05%
===========================================================
Files 68 68
Lines 1059 1064 +5
===========================================================
+ Hits 944 949 +5
Misses 115 115 ☔ View full report in Codecov by Sentry. |
app/models/calculator.rb
Outdated
validates :ukranian_additional_notes, | ||
length: { | ||
maximum: 500, | ||
tokenizer: ->(string) { ActionController::Base.helpers.strip_tags(string).chars } |
There was a problem hiding this comment.
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 %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<%= tinymce_assets %> | |
<%= tinymce_assets %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align that all
<% if I18n.locale == :uk %> | ||
<%= raw calculator.ukranian_additional_notes %> | ||
<% else %> | ||
<%= raw calculator.english_additional_notes %> | ||
<% end %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<% 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
config/locales/uk/uk.yml
Outdated
@@ -361,6 +361,8 @@ uk: | |||
prohibited_to_update: " перешкоджають оновленню калькулятора" | |||
prohibited_to_save: " перешкоджають збереженню калькулятора" | |||
error: "помилки" | |||
ukranian_additional_notes: "Додаткові нотатки українською" | |||
english_additional_notes: "Додаткові нотатки англійською" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
у нас же нема основних нотаток)
<div class="description-block"> | ||
<%# TODO: ADD text here %> | ||
<div class="description-section"> | ||
<%== calculator.notes %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any XSS protection?
Co-authored-by: Ivan Marynych <[email protected]>
…projects/ZeroWaste into 950-additional-notes
<div class="description-block"> | ||
<%# TODO: ADD text here %> | ||
<div class="description-section"> | ||
<%= sanitize(calculator.notes, tags: %w[p strong em ul li a div span img], attributes: %w[href target class src alt style]) %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
перенеси це в хелпер
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
і не юзай цей %, то зло
<div class="description-block"> | ||
<%# TODO: ADD text here %> | ||
<div class="description-section"> | ||
<%= sanitized_notes(calculator.notes) %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sanitize_content
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.
CHECK LIST