This repository has been archived by the owner on Sep 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adicionado as classes de Venda e Produto (Consertos).
- Loading branch information
1 parent
c8663e2
commit fe5a0ab
Showing
113 changed files
with
570 additions
and
13 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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://coffeescript.org/ |
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,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://coffeescript.org/ |
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,3 @@ | ||
// Place all the styles related to the produtos controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
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,84 @@ | ||
body { | ||
background-color: #fff; | ||
color: #333; | ||
margin: 33px; | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; | ||
} | ||
|
||
p, ol, ul, td { | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; | ||
} | ||
|
||
pre { | ||
background-color: #eee; | ||
padding: 10px; | ||
font-size: 11px; | ||
} | ||
|
||
a { | ||
color: #000; | ||
|
||
&:visited { | ||
color: #666; | ||
} | ||
|
||
&:hover { | ||
color: #fff; | ||
background-color: #000; | ||
} | ||
} | ||
|
||
th { | ||
padding-bottom: 5px; | ||
} | ||
|
||
td { | ||
padding: 0 5px 7px; | ||
} | ||
|
||
div { | ||
&.field, &.actions { | ||
margin-bottom: 10px; | ||
} | ||
} | ||
|
||
#notice { | ||
color: green; | ||
} | ||
|
||
.field_with_errors { | ||
padding: 2px; | ||
background-color: red; | ||
display: table; | ||
} | ||
|
||
#error_explanation { | ||
width: 450px; | ||
border: 2px solid red; | ||
padding: 7px 7px 0; | ||
margin-bottom: 20px; | ||
background-color: #f0f0f0; | ||
|
||
h2 { | ||
text-align: left; | ||
font-weight: bold; | ||
padding: 5px 5px 5px 15px; | ||
font-size: 12px; | ||
margin: -7px -7px 0; | ||
background-color: #c00; | ||
color: #fff; | ||
} | ||
|
||
ul li { | ||
font-size: 12px; | ||
list-style: square; | ||
} | ||
} | ||
|
||
label { | ||
display: block; | ||
} |
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,3 @@ | ||
// Place all the styles related to the Vendas controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,74 @@ | ||
class ProdutosController < ApplicationController | ||
before_action :set_produto, only: [:show, :edit, :update, :destroy] | ||
|
||
# GET /produtos | ||
# GET /produtos.json | ||
def index | ||
@produtos = Produto.all | ||
end | ||
|
||
# GET /produtos/1 | ||
# GET /produtos/1.json | ||
def show | ||
end | ||
|
||
# GET /produtos/new | ||
def new | ||
@produto = Produto.new | ||
end | ||
|
||
# GET /produtos/1/edit | ||
def edit | ||
end | ||
|
||
# POST /produtos | ||
# POST /produtos.json | ||
def create | ||
@produto = Produto.new(produto_params) | ||
|
||
respond_to do |format| | ||
if @produto.save | ||
format.html { redirect_to @produto, notice: 'Produto was successfully created.' } | ||
format.json { render :show, status: :created, location: @produto } | ||
else | ||
format.html { render :new } | ||
format.json { render json: @produto.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /produtos/1 | ||
# PATCH/PUT /produtos/1.json | ||
def update | ||
respond_to do |format| | ||
if @produto.update(produto_params) | ||
format.html { redirect_to @produto, notice: 'Produto was successfully updated.' } | ||
format.json { render :show, status: :ok, location: @produto } | ||
else | ||
format.html { render :edit } | ||
format.json { render json: @produto.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /produtos/1 | ||
# DELETE /produtos/1.json | ||
def destroy | ||
@produto.destroy | ||
respond_to do |format| | ||
format.html { redirect_to produtos_url, notice: 'Produto was successfully destroyed.' } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_produto | ||
@produto = Produto.find(params[:id]) | ||
end | ||
|
||
# Never trust parameters from the scary internet, only allow the white list through. | ||
def produto_params | ||
params.require(:produto).permit(:id, :descricao, :precoCompra, :precoVenda) | ||
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
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,2 @@ | ||
module ProdutosHelper | ||
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,2 @@ | ||
module VendasHelper | ||
end |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,5 @@ | ||
class Produto < ApplicationRecord | ||
validates :descricao, presence: { message: 'É um campo obrigatório' } | ||
validates :descricao, length: { minimum: 2, message: ' tem menos de 2 caracteres' } | ||
validates :descricao, length: { maximum: 100, message: ' tem mais de 100 caracteres' } | ||
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 |
---|---|---|
@@ -1,10 +1,8 @@ | ||
class Venda < ApplicationRecord | ||
|
||
belongs_to :Produto | ||
belongs_to :produto | ||
#Entrará Cliente belongs_to :Cliente | ||
|
||
validates :valorVenda, presence: { message: 'É um campo obrigatório' } | ||
validates :valorVenda, numericality: { message: 'É um campo apenas numérico' } | ||
validates :valorVenda, numericality: { greater_than_or_equal_to: 0, message: 'Deve ser maior ou igual a zero' } | ||
|
||
end |
File renamed without changes.
File renamed without changes.
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,37 @@ | ||
<%= form_with(model: produto, local: true) do |form| %> | ||
<% if produto.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(produto.errors.count, "error") %> prohibited this produto from being saved:</h2> | ||
|
||
<ul> | ||
<% produto.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= form.label :id %> | ||
<%= form.number_field :id, id: :produto_id %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :descricao %> | ||
<%= form.text_field :descricao, id: :produto_descricao %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :precoCompra %> | ||
<%= form.text_field :precoCompra, id: :produto_precoCompra %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :precoVenda %> | ||
<%= form.text_field :precoVenda, id: :produto_precoVenda %> | ||
</div> | ||
|
||
<div class="actions"> | ||
<%= form.submit %> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json.extract! produto, :id, :id, :descricao, :precoCompra, :precoVenda, :created_at, :updated_at | ||
json.url produto_url(produto, format: :json) |
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,6 @@ | ||
<h1>Editing Produto</h1> | ||
|
||
<%= render 'form', produto: @produto %> | ||
|
||
<%= link_to 'Show', @produto %> | | ||
<%= link_to 'Back', produtos_path %> |
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,33 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<h1>Produtos</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Id</th> | ||
<th>Descricao</th> | ||
<th>Precocompra</th> | ||
<th>Precovenda</th> | ||
<th colspan="3"></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @produtos.each do |produto| %> | ||
<tr> | ||
<td><%= produto.id %></td> | ||
<td><%= produto.descricao %></td> | ||
<td><%= produto.precoCompra %></td> | ||
<td><%= produto.precoVenda %></td> | ||
<td><%= link_to 'Show', produto %></td> | ||
<td><%= link_to 'Edit', edit_produto_path(produto) %></td> | ||
<td><%= link_to 'Destroy', produto, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<br> | ||
|
||
<%= link_to 'New Produto', new_produto_path %> |
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 @@ | ||
json.array! @produtos, partial: "produtos/produto", as: :produto |
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 @@ | ||
<h1>New Produto</h1> | ||
|
||
<%= render 'form', produto: @produto %> | ||
|
||
<%= link_to 'Back', produtos_path %> |
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,24 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<strong>Id:</strong> | ||
<%= @produto.id %> | ||
</p> | ||
|
||
<p> | ||
<strong>Descricao:</strong> | ||
<%= @produto.descricao %> | ||
</p> | ||
|
||
<p> | ||
<strong>Precocompra:</strong> | ||
<%= @produto.precoCompra %> | ||
</p> | ||
|
||
<p> | ||
<strong>Precovenda:</strong> | ||
<%= @produto.precoVenda %> | ||
</p> | ||
|
||
<%= link_to 'Edit', edit_produto_path(@produto) %> | | ||
<%= link_to 'Back', produtos_path %> |
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 @@ | ||
json.partial! "produtos/produto", produto: @produto |
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,32 @@ | ||
<%= form_with(model: venda, local: true) do |form| %> | ||
<% if venda.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(venda.errors.count, "error") %> prohibited this venda from being saved:</h2> | ||
|
||
<ul> | ||
<% venda.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= form.label :id %> | ||
<%= form.number_field :id, id: :venda_id %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :quantidade %> | ||
<%= form.number_field :quantidade, id: :venda_quantidade %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :valorTotal %> | ||
<%= form.text_field :valorTotal, id: :venda_valorTotal %> | ||
</div> | ||
|
||
<div class="actions"> | ||
<%= form.submit %> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json.extract! venda, :id, :id, :quantidade, :valorTotal, :created_at, :updated_at | ||
json.url venda_url(venda, format: :json) |
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,6 @@ | ||
<h1>Editing Venda</h1> | ||
|
||
<%= render 'form', venda: @venda %> | ||
|
||
<%= link_to 'Show', @venda %> | | ||
<%= link_to 'Back', vendas_path %> |
Oops, something went wrong.