Created
November 8, 2018 23:01
-
-
Save Haguilar91/8a8390d14f7852bf159af0965e9ee13d to your computer and use it in GitHub Desktop.
Chunches Modal
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
<div class="modal fade" id="mainModal" tabindex="-1" role="dialog" aria-labelledby="mainModalLabel" aria-hidden="true" > | |
<div class="modal-dialog"> | |
<div class="modal-content"> | |
<div class="modal-header"> | |
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> | |
<h4 class="modal-title" id="mainModalLabel"> | |
<%= yield :title if content_for? :title %> | |
</h4> | |
</div> | |
<%= yield %> | |
</div> | |
</div> | |
</div> |
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
class ModalResponder < ActionController::Responder | |
cattr_accessor :modal_layout | |
self.modal_layout = 'modal' | |
def render(*args) | |
options = args.extract_options! | |
if request.xhr? | |
options.merge! layout: modal_layout | |
end | |
controller.render *args, options | |
end | |
def default_render(*args) | |
render(*args) | |
end | |
def redirect_to(options) | |
if request.xhr? | |
head :ok, location: controller.url_for(options) | |
else | |
controller.redirect_to(options) | |
end | |
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
% title @item.nombre %> | |
<% meta_tag :title, "#{@item.nombre} /\nL. #{@item.price} | Chunches" %> | |
<% meta_tag :description, @item.descripcion %> | |
<% meta_tag :image, @item.imagen %> | |
<% meta_tag :type, "product" %> | |
<% meta_tag :url, "http://test.chunch.es/garaje/items/#{@item.id.to_s}" %> | |
<% meta_tag :appid, "482141061981612" %> | |
<script> | |
window.onload = function() { | |
if (window.jQuery) { | |
// jQuery is loaded | |
alert("Yeah!"); | |
} else { | |
// jQuery is not loaded | |
alert("Doesn't Work"); | |
} | |
} | |
</script> | |
<div class="row" style=padding-top:2em;> | |
<!--spacer--> | |
<div class="col-md-1"></div> | |
<div class="col-md-5"> | |
<!--Card--> | |
<div class="card"> | |
<!--Card image--> | |
<img class="img-fluid" src="<%=@item.imagen%>" alt="Card image cap"> | |
<a class="btn-floating btn-action"></a> | |
<!--Card content--> | |
<div class="card-body"> | |
<!--Text--> | |
<div class="bg-info panel panel-default border-radius rounded" style="padding: 1em; outline: black thick;"> | |
<div class="panel-body"> | |
Verifica que el codigo: <b> <%= @item.codigo %></b> aparezca impreso o escrito encima de la imagen. | |
<button type="button" class="btn btn-outline-elegant btn-sm" data-toggle="modal" data-target="#flipFlop"> | |
? | |
</button> | |
<div class="modal fade" id="flipFlop" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true"> | |
<div class="modal-dialog" role="document"> | |
<div class="modal-content"> | |
<div class="modal-header"> | |
<h4 class="modal-title" align=center id="modalLabel">Código en la foto. </h4> | |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
<span aria-hidden="true">×</span> | |
</button> | |
</div> | |
<div class="modal-body"> | |
<div class="row"> | |
<div class="col-md-6"> | |
<p>Cuando agregas un artículo a Chunches se te generara un código aleatorio.</p> | |
<img src="<%=asset_url('captureagregar.PNG')%>" alt="" style="height:15em; width:auto;" class="img-fluid"> | |
</div> | |
<div class="col-md-6"> | |
<p>Con ese código, escribe o imprime encima del artículo en venta de forma legible, no usar Paint ni Photoshop la foto tiene que ser real.</p> | |
<img src="<%=asset_url('capturearticulo_mini.jpg')%>" alt="" style="height:15em; width:auto;" class="img-fluid"> | |
</div> | |
</div> | |
</div> | |
<div class="modal-footer"> | |
<button type="button" class="btn btn-primary" data-dismiss="modal"><i class="fas fa-sign-out-alt"></i>Cerrar</button> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
<!--/.Card--> | |
</div> | |
<div class="col-md-5"> | |
<div class="card-body"> | |
<!--Title--> | |
<h4 class="card-title"><%= @item.nombre %></h4> | |
<h4 class= "card-title"><i class="fas fa-money-bill" aria-hidden="true"></i><b> L.<%= @item.price %></b></h4> | |
<!--<a class="btn btn-outline-danger" data-toggle="modal" href="/new_transaccion" data-target="#pagosModal"><i class="fas fa-handshake"></i> Pedir informacion de pago</a>--> | |
<!-- Invocando Modal--> | |
<!--Intento 1--> | |
<%= link_to 'Pedir Informacion de pago', new_transaction_path, class: 'btn btn-outline-success my-2 my-sm-0 ', data: { modal: true } %> | |
<div style="display: inline-flex;"> | |
<div class="social-share-button"> | |
<a class="ssb-icon ssb-facebook" href="https://www.facebook.com/sharer/sharer.php?u=http://chunch.es/garaje/items/<%=@item.id.to_s%>" target="popup" onclick="window.open('https://www.facebook.com/sharer/sharer.php?u=http://chunch.es/garaje/items/<%=@item.id.to_s%>','popup','width=555,height=400'); return false;"></a> | |
</div> | |
<%= social_share_button_tag(@item.nombre, :image => @item.imagen, :url => "http://chunch.es/garaje/items/#{@item.id.to_s}") %> | |
</div> | |
</br> | |
<!--Text--> | |
<i class="fa fa-sticky-note" aria-hidden="true"></i> <strong>Estado:</strong><%= @item.itemstate %><br> | |
<i class="fas fa-sort-amount-down"></i> <strong>Categoria:</strong><%= @category_name%><br> | |
<i class="fas fa-warehouse"></i> <strong>Disponibilidad:</strong>5 en bodega.<br> | |
<i class="fas fa-comment-alt" aria-hidden="true"></i> <b>Descripción: | |
</b><br><%=@item.descripcion%> | |
<br><br><br> | |
<h4 class="card-title">Información del Vendedor</h4> | |
<hr> | |
<div class="row"> | |
<div class="col-2 mx-auto" align=center> | |
<%= gravatar_tag @item.usuario_actual, :circle , :size => 55, :secure => true %> | |
</div> | |
<div class="col-10"> | |
<h6>Nombre: <%=@usuario.nombre%> <%=@usuario.apellido%> </h6> | |
<p>Reviews: <%=@slider.count%> Promedio: <%=@slider.average(:rating)%></p> | |
<p>Ciudad: <%=@usuario.ciudad%></p> | |
<% if @usuario.descripcion %> | |
<!-- true --> | |
<p class="quote"><%=@usuario.descripcion%></p> | |
<%else%> | |
<p>No tiene una descripcion, recuerda agregar la tuya <a href="/users/edit">aqui.</a></p> | |
<% end %> | |
</div> | |
</div> | |
<div class="btn-group"> | |
<a href="/garaje/<%=User.find_by_email(@item.usuario_actual).id_and_name%>" class= "btn btn-outline-secondary"> | |
<i class="fa fa-user" aria-hidden="true"></i> Ir al perfil del vendedor | |
</a> | |
<%if current_user.present?%> | |
<% if current_user.email != @usuario.email%> | |
<a href="<%= new_conversation_path(:user_id => User.find_by_email(@item.usuario_actual)) %>" class="btn btn-outline-primary"><i class="fa fa-comments-o" aria-hidden="true"></i> Hablar con vendedor</a> | |
<%end%> | |
</div> | |
<%else%> | |
<p class="mdl-card__supporting-text mdl-color-text--black">Favor Iniciar Sesion para Conversar</p> | |
<%end%> | |
</div> | |
</div> | |
</div> | |
<!--spacer--> | |
<div class="col-md-1"> | |
</div> | |
</div> | |
<hr> | |
<div class="row"> | |
<% if current_user %> | |
<div class="col-md-3 form" style="padding-left: 3em;"> | |
<%= render 'new_comment_form' %> | |
</div> | |
<div class="col-md-9 mx-auto " align=center> | |
<%= render 'show_comments'%> | |
</div> | |
<% else %> | |
<div class="col-md-10 mx-auto " align=center > | |
<%= render 'show_comments'%> | |
</div> | |
<% end %> | |
</div> |
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
class ApplicationController < ActionController::Base | |
before_action :configure_permitted_parameters, if: :devise_controller? | |
protected | |
def configure_permitted_parameters | |
devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:username,:nombre, :apellido, :email,:ciudad, :password, :password_confirmation,:descripcion, :terminos_de_servicio) } | |
devise_parameter_sanitizer.permit(:account_update) { |u| u.permit(:username, :nombre, :apellido, :email, :password,:ciudad, :current_password, :is_female, :date_of_birth, :descripcion) } | |
end | |
def isChunchePrestado item | |
return !Loan.where( :id_articulo => item.id ).blank? | |
end | |
def isLoaner loaner | |
return !Loan.where( :id_prestamista => loaner.id).blank? | |
end | |
def isUserLoaner user | |
return !Lender.where(:user_id => user.id).blank? | |
end | |
before_action :instantiateUser | |
def instantiateUser | |
@user = User.new | |
end | |
def respond_modal_with(*args, &blk) | |
options = args.extract_options! | |
options[:responder] = ModalResponder | |
respond_with *args, options, &blk | |
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
<%= simple_form_for(@transaction, remote: request.xhr?, html: { data: { modal: true } }) do |form| %> | |
<% if transaction.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(transaction.errors.count, "error") %> prohibited this transaction from being saved:</h2> | |
<ul> | |
<% transaction.errors.full_messages.each do |message| %> | |
<li><%= message %></li> | |
<% end %> | |
</ul> | |
</div> | |
<% end %> | |
<%= hidden_field_tag(:id_item, "1") %> | |
<%= hidden_field_tag(:id_comp, "#{current_user.id}") %> | |
<%= hidden_field_tag(:id_vend, "#{User.find_by_email(Item.find_by_id(2).usuario_actual).id}") %> | |
<!--#id_comp integer id_item integer id_vend integer isComplete boolean (0) voucher string>--> | |
<div class="card"> | |
<!--Card image--> | |
<% if (params[:action] != 'new') %> | |
<div class="container"> | |
<img class="item-photo-edit img-fluid" src="<%=@item.display_photo%>" alt="" /> | |
</div> | |
<% end%> | |
<div class="form-group files color"> | |
<label>Sube tu imagen </label> | |
<%= form.file_field :voucher %> | |
</div> | |
</div> | |
<div class="field"> | |
<%= form.label :isComplete %> | |
<%= form.check_box :isComplete %> | |
</div> | |
<div class="actions"> | |
<%= form.submit %> | |
</div> | |
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
class TransactionsController < ApplicationController | |
before_action :authenticate_user! | |
before_action :set_transaction, only: [:show, :edit, :update, :destroy] | |
respond_to :html, :json | |
# GET /transactions | |
# GET /transactions.json | |
def index | |
@transactions = Transaction.all | |
end | |
# GET /transactions/1 | |
# GET /transactions/1.json | |
def show | |
@transaction = Transaction.find_by_id(params[:id]) | |
end | |
# GET /transactions/new | |
def new | |
@transaction = Transaction.new | |
respond_modal_with @transaction | |
#respond_to do |format| | |
# format.html | |
# format.js | |
# end | |
end | |
# GET /transactions/1/edit | |
def edit | |
end | |
# POST /transactions | |
# POST /transactions.json | |
def create | |
respond_to do |format| | |
@transaction = Transaction.new(transaction_params) | |
#@producto=Item.all.where(:id=>params[:item_id]).pluck(:id)params[:item_id] | |
# @transaction.id_item=Item.find_by_id(params[:item_id]).id | |
# @comprador=current_user.id | |
# @vendedor=User.all.where(:email=>@producto.usuario_actual).pluck(:id) | |
# @transaction.id_comp=@comprador | |
#@transaction.id_item=@producto | |
# @transaction.id_vend=@vendedor | |
respond_modal_with @transaction, location: transactions_path | |
if @transaction.save | |
format.html { redirect_to items_url, notice: 'La transaccion ha sido creada.' } | |
format.json { render :show, status: :ok, location: @transaction } | |
else | |
format.html { render :edit } | |
format.json { render json: @transaction.errors, status: :unprocessable_entity } | |
end | |
end | |
end | |
# PATCH/PUT /transactions/1 | |
# PATCH/PUT /transactions/1.json | |
#def update | |
#respond_to do |format| | |
# if @transaction.update(transaction_params) | |
# format.html { redirect_to @transaction, notice: 'Transaction was successfully updated.' } | |
# format.json { render :show, status: :ok, location: @transaction } | |
# else | |
# format.html { render :edit } | |
# format.json { render json: @transaction.errors, status: :unprocessable_entity } | |
# end | |
# end | |
# end | |
# DELETE /transactions/1 | |
# DELETE /transactions/1.json | |
def destroy | |
@transaction.destroy | |
redirect_to transactions_url | |
#respond_to do |format| | |
# format.html { redirect_to transactions_url, notice: 'Transaction was successfully destroyed.' } | |
# format.json { head :no_content } | |
# end | |
end | |
#def new_transaccion | |
# @transaction = Transaction.new | |
# respond_to do |format| | |
# format.html | |
# format.js | |
# end | |
#end | |
private | |
# Use callbacks to share common setup or constraints between actions. | |
def set_transaction | |
@transaction = Transaction.find(params[:id]) | |
end | |
# Never trust parameters from the scary internet, only allow the white list through. | |
def transaction_params | |
params.require(:transaction).permit(:id_vend, :id_comp, :id_item, :voucher, :isComplete) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment