Skip to content

Commit

Permalink
Merge pull request #298 from Purple-Stock/staging
Browse files Browse the repository at this point in the history
add new field
  • Loading branch information
puppe1990 authored Sep 2, 2024
2 parents a2fe5aa + 146e0f9 commit 84995e3
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/controllers/productions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def set_tailors

def production_params
params.require(:production).permit(
:tailor_id, :cut_date, :expected_delivery_date,
:cut_date, :tailor_id, :service_order_number, :expected_delivery_date,
:confirmed, :paid, :consider, :observation,
production_products_attributes: [:id, :product_id, :quantity, :pieces_delivered, :pieces_missing, :_destroy]
)
Expand Down
5 changes: 5 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def pt_datetime_format(time)
time.to_datetime.strftime('%d-%m-%Y %H:%M:%S')
end

def pt_only_date_format(time)
return 'N/A' if time.nil?
time.to_datetime.strftime('%d-%m-%Y')
end

# date format "%d/%m/%Y %H:%m"
def display_status(status)
if status
Expand Down
8 changes: 7 additions & 1 deletion app/views/productions/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%# app/views/productions/_form.html.erb %>

<%= form_with(model: [@account, production], local: true) do |form| %>
<%= form_with(model: production, local: true) do |form| %>
<% if production.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(production.errors.count, "error") %> prohibited this production from being saved:</h2>
Expand All @@ -12,6 +12,11 @@
</div>
<% end %>

<div class="form-group">
<%= form.label :service_order_number %>
<%= form.text_field :service_order_number, class: 'form-control' %>
</div>

<div class="form-group">
<%= form.label :number %>
<%= form.number_field :number, class: 'form-control' %>
Expand Down Expand Up @@ -79,6 +84,7 @@
</div>

<%= form.submit class: 'btn btn-primary' %>
<%= link_to 'Verify', verify_account_production_path(@account, production), class: 'btn btn-secondary', method: :get if production.persisted? %>
<% end %>

<%# app/views/productions/_production_product_fields.html.erb %>
Expand Down
10 changes: 7 additions & 3 deletions app/views/productions/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@
<div class="card-body">
<%= form_with(model: @production, local: true) do |form| %>
<div class="row mb-3">
<div class="col-md-4">
<div class="col-md-3">
<%= form.label :service_order_number, model_class.human_attribute_name(:service_order_number), class: 'form-label' %>
<%= form.text_field :service_order_number, class: 'form-control' %>
</div>
<div class="col-md-3">
<%= form.label :tailor_id, model_class.human_attribute_name(:tailor), class: 'form-label' %>
<%= form.collection_select :tailor_id, @tailors, :id, :name, { prompt: 'Select a tailor' }, { class: 'form-control' } %>
</div>
<div class="col-md-4">
<div class="col-md-3">
<%= form.label :cut_date, model_class.human_attribute_name(:cut_date), class: 'form-label' %>
<%= form.date_field :cut_date, class: 'form-control', readonly: true %>
</div>
<div class="col-md-4">
<div class="col-md-3">
<%= form.label :expected_delivery_date, model_class.human_attribute_name(:expected_delivery_date), class: 'form-label' %>
<%= form.date_field :expected_delivery_date, class: 'form-control' %>
</div>
Expand Down
10 changes: 7 additions & 3 deletions app/views/productions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@
<div class="card-body">
<%= form_with(model: @production, local: true) do |form| %>
<div class="row mb-3">
<div class="col-md-4">
<div class="col-md-3">
<%= form.label :service_order_number, model_class.human_attribute_name(:service_order_number), class: 'form-label' %>
<%= form.text_field :service_order_number, class: 'form-control' %>
</div>
<div class="col-md-3">
<%= form.label :tailor_id, model_class.human_attribute_name(:tailor), class: 'form-label' %>
<%= form.collection_select :tailor_id, @tailors, :id, :name, { prompt: 'Select a tailor' }, { class: 'form-control select2' } %>
</div>
<div class="col-md-4">
<div class="col-md-3">
<%= form.label :cut_date, model_class.human_attribute_name(:cut_date), class: 'form-label' %>
<%= form.date_field :cut_date, class: 'form-control' %>
</div>
<div class="col-md-4">
<div class="col-md-3">
<%= form.label :expected_delivery_date, model_class.human_attribute_name(:expected_delivery_date), class: 'form-label' %>
<%= form.date_field :expected_delivery_date, class: 'form-control' %>
</div>
Expand Down
12 changes: 10 additions & 2 deletions app/views/productions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,20 @@
</div>
<div class="card-body">
<dl class="row">
<dt class="col-sm-3"><%= model_class.human_attribute_name(:service_order_number) %>:</dt>
<dd class="col-sm-9"><%= @production.service_order_number %></dd>
<dt class="col-sm-3"><%= model_class.human_attribute_name(:cut_date) %>:</dt>
<dd class="col-sm-9"><%= @production.cut_date %></dd>
<dd class="col-sm-9"><%= pt_only_date_format(@production.cut_date) %></dd>
<dt class="col-sm-3"><%= model_class.human_attribute_name(:expected_delivery_date) %>:</dt>
<dd class="col-sm-9"><%= @production.expected_delivery_date %></dd>
<dd class="col-sm-9"><%= pt_only_date_format(@production.expected_delivery_date) %></dd>
<dt class="col-sm-3"><%= model_class.human_attribute_name(:consider)%>:</dt>
<dd class="col-sm-9"><%= @production.consider ? 'Sim' : 'Não' %></dd>
<dt class="col-sm-3"><%= model_class.human_attribute_name(:confirmed) %>:</dt>
<dd class="col-sm-9"><%= @production.confirmed ? 'Sim' : 'Não' %></dd>
<dt class="col-sm-3"><%= model_class.human_attribute_name(:paid) %>:</dt>
<dd class="col-sm-9"><%= @production.paid ? 'Sim' : 'Não' %></dd>
<dt class="col-sm-3"><%= model_class.human_attribute_name(:observation) %>:</dt>
<dd class="col-sm-9"><%= @production.observation %></dd>
</dl>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions config/locales/pt-BR.models.productions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pt-BR:
production_product: "Produto da Produção"
attributes:
production:
service_order_number: "Número da Ordem de Serviço"
tailor: "Costureiro"
cut_date: "Data de Corte"
delivery_date: "Data de Entrega"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddServiceOrderNumberToProductions < ActiveRecord::Migration[7.0]
def change
add_column :productions, :service_order_number, :string
end
end

0 comments on commit 84995e3

Please sign in to comment.