-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from TreinaDev/unit_type_refat
Refatoração de tipo de unidade
- Loading branch information
Showing
24 changed files
with
245 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
class UnitType < ApplicationRecord | ||
has_many :units, dependent: :destroy | ||
belongs_to :condo | ||
|
||
validates :description, :metreage, presence: true | ||
validates :metreage, numericality: { greater_than: 0 } | ||
validates :description, :metreage, :fraction, presence: true | ||
validates :metreage, :fraction, numericality: { greater_than: 0 } | ||
|
||
def p_metreage | ||
def metreage_to_square_meters | ||
"#{metreage}m²" | ||
end | ||
|
||
def fraction_to_percentage | ||
"#{fraction}%" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
<%= form_with(model: @unit_type) do |f| %> | ||
<div> | ||
<%= f.label :description %> | ||
<%= f.text_area :description%> | ||
</div> | ||
<%= form_with(model: [@condo, @unit_type]) do |f| %> | ||
<div class="form-row d-flex p-2"> | ||
<div class="form-group col-md-4 pe-3"> | ||
<%= f.label :description %> | ||
<%= f.text_area :description, class:"form-control"%> | ||
</div> | ||
|
||
<div> | ||
<%= f.label :metreage %> | ||
<%= f.number_field :metreage, step: 0.01%> | ||
<div class="form-group col-md-4 pe-3"> | ||
<%= f.label :metreage %> | ||
<%= f.number_field :metreage, step: 0.01, class:"form-control"%> | ||
</div> | ||
|
||
<div class="form-group col-md-4 pe-3"> | ||
<%= f.label :fraction %> (Valor em porcentagem) | ||
<%= f.number_field :fraction, step: 0.00001, class:"form-control"%> | ||
</div> | ||
</div> | ||
|
||
<div> | ||
<%= f.submit %> | ||
<%= f.submit class:"btn btn-dark"%> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
pt-BR: | ||
notices: | ||
condo: | ||
created: 'Condomínio cadastrado com sucesso' | ||
updated: 'Condomínio atualizado com sucesso' | ||
alerts: | ||
condo: | ||
not_created: 'Erro ao cadastrar Condomínio' | ||
not_updated: 'Erro ao atualizar Condomínio' | ||
name: 'Nome' | ||
registration_number: 'CNPJ' | ||
activerecord: | ||
models: | ||
condo: | ||
one: 'Condomínio' | ||
other: 'Condomínios' | ||
attributes: | ||
condo: | ||
name: 'Nome' | ||
registration_number: 'CNPJ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddFractionToUnitType < ActiveRecord::Migration[7.1] | ||
def change | ||
add_column :unit_types, :fraction, :integer | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddCondoIdToUnitTypes < ActiveRecord::Migration[7.1] | ||
def change | ||
add_reference :unit_types, :condo, null: false, foreign_key: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class ChangeFractionToDecimal < ActiveRecord::Migration[7.1] | ||
def change | ||
change_column :unit_types, :fraction, :decimal, precision: 10, scale: 5 | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.