-
Notifications
You must be signed in to change notification settings - Fork 11
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
Base setup #943
base: feature/calculator-constructor
Are you sure you want to change the base?
Base setup #943
Conversation
app/models/category.rb
Outdated
validates :uk_name, :en_name, presence: true | ||
validates :uk_name, :en_name, | ||
length: { minimum: 3, maximum: 30 }, | ||
format: { with: /\A[\p{L}0-9\s'-]+\z/i }, | ||
uniqueness: { case_sensitive: false }, | ||
allow_blank: true | ||
validates :priority, numericality: { greater_than_or_equal_to: 0 } | ||
|
||
scope :ordered_by_name, -> { order(:uk_name) } | ||
scope :ordered_by_priority, -> { order(:priority) } | ||
scope :unsigned_categories, ->(product) { where.not(id: product.categories_by_prices) } |
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.
повернули
але видаляли бо не до кінця було зрозуміло чи потрібен був цей код для реалізації конструктора
app/models/field.rb
Outdated
has_many :categories, dependent: :destroy | ||
accepts_nested_attributes_for :categories, reject_if: :all_blank, allow_destroy: true |
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.
has_many :categories, dependent: :destroy | |
accepts_nested_attributes_for :categories, reject_if: :all_blank, allow_destroy: true | |
has_many :categories, dependent: :destroy | |
accepts_nested_attributes_for :categories, reject_if: :all_blank, allow_destroy: true |
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.
fixed
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.
fixed
t.string :expression, null: false, default: "" | ||
t.string :uk_label, null: false, default: "" | ||
t.string :en_label, null: false |
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.
ага, додали і для :en_label
remove_columns :fields, :uuid, :selector, :type, :label, :name, :value, :from, :to, :kind, :unit | ||
|
||
add_column :fields, :uk_label, :string, null: false, default: "" | ||
add_column :fields, :en_label, :string, null: false, default: "" | ||
add_column :fields, :var_name, :string, null: false, default: "" | ||
add_column :fields, :field_type, :string, null: false, default: "" |
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.
change_table bulk: true
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.
fixed
@@ -0,0 +1,8 @@ | |||
class ChangeCategories < ActiveRecord::Migration[7.2] | |||
def change | |||
remove_columns :categories, :priority, :preferable |
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.
прибрав
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/calculator-constructor #943 +/- ##
===================================================================
- Coverage 91.16% 64.09% -27.07%
===================================================================
Files 70 71 +1
Lines 973 997 +24
===================================================================
- Hits 887 639 -248
- Misses 86 358 +272 ☔ View full report in Codecov by Sentry. |
app/models/field.rb
Outdated
|
||
self.selector = "#{kind&.first&.upcase}#{index}" | ||
end | ||
FIELD_TYPES = [ |
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.
Роби хешом, а ще тре конвертнеш в масив
<%= f.input :en_name, label: "Calculator Name:", class: 'form-control' %> | ||
|
||
<!-- formula input--> | ||
<div id="formulas" class="space-y-4"> |
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.
досі не гуд
config/database.yml.sample
Outdated
@@ -23,4 +23,4 @@ production: | |||
<<: *default | |||
# database: zero_waste_production | |||
# username: zero_waste | |||
# password: <%= ENV['ZERO_WASTE_DATABASE_PASSWORD'] %> | |||
# password: <%= ENV['ZERO_WASTE_DATABASE_PASSWORD'] %> |
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.
Нова строка
change_table :categories, bulk: true do |t| | ||
t.remove :preferable, type: :boolean | ||
|
||
t.float :price, null: false, default: 0.0 |
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.
Завжди для ціни юзай BigDecimal, чи то Decimal. Загугли
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.
зробив через decimal
пишуть що BigDecimal вже буде юзатись у рубі коді, не в міграціях
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.
Теж
.vscode/settings.json
Outdated
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.
видаляй)
app/models/field.rb
Outdated
|
||
before_create :set_selector, if: -> { selector.blank? } | ||
# enum :kind, { form: 0, parameter: 1, result: 2 } |
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.
kind, FIELD_TYPES
<%= f.input :en_name, label: "Calculator Name:", class: 'form-control' %> | ||
|
||
<!-- formula input--> | ||
<div id="formulas" class="space-y-4"> |
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.
видаляй
@@ -15,6 +15,13 @@ def show | |||
# TODO: fill it | |||
end | |||
|
|||
def new | |||
@calculator = Calculator.new |
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.
тести)
validates :en_name, presence: true | ||
validates :en_name, |
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.
а чому нема укр назви?) також транслейтабл?)
|
||
private | ||
enum :kind, { number: 0, category: 1 } |
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.
юзайте текстові велєю + константи на ті велʼю
|
||
before_create :set_selector, if: -> { selector.blank? } | ||
accepts_nested_attributes_for :categories, reject_if: :all_blank, allow_destroy: true |
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.
це має бути в самому низу
<%= f.input :kind, | ||
collection: Field.kinds.map { |k, _| [k.humanize, k] }, | ||
prompt: "Select Field Type", | ||
label: "Field Type:", | ||
input_html: { data: { field_type_target: "fieldTypeSelect" } } %> |
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.
<%= f.input :kind, | |
collection: Field.kinds.map { |k, _| [k.humanize, k] }, | |
prompt: "Select Field Type", | |
label: "Field Type:", | |
input_html: { data: { field_type_target: "fieldTypeSelect" } } %> | |
<%= f.input( | |
:kind, | |
collection: Field.kinds.map { |k, _| [k.humanize, k] }, | |
prompt: "Select Field Type", | |
label: "Field Type:", | |
input_html: { data: { field_type_target: "fieldTypeSelect" }} | |
) %> |
dev
GitHub Board
Code reviewers
Second Level Review
Summary of issue
to create a foundation for the calculator builder.
Summary of change
the addition of models, updating of the controller, updating of new.html, and creation of new _partials were implemented. Additionally, the cocoon gem was added to enable working with multiple calculator fields.
Testing approach
ToDo
CHECK LIST