Move inline form to users#show

This commit is contained in:
benji 2015-09-10 14:12:05 +02:00
parent 0da73da377
commit f5d3a58bbb
5 changed files with 21 additions and 14 deletions

View file

@ -18,7 +18,11 @@
//= require_tree .
ready = function() {
$(".select2-selector").select2();
$(".select2-selector").select2({
width: 'resolve',
allowClear: true,
placeholder: "Ontvanger"
});
}
$(document).ready(ready)

View file

@ -3,6 +3,7 @@ class UsersController < ApplicationController
def show
@user = User.find(params[:id])
@transaction = Transaction.new
respond_to do |format|
format.html
format.json { render json: TransactionDatatable.new(

View file

@ -0,0 +1,14 @@
= render 'partials/form_errors', object: @transaction
= form_for @transaction, html: { class: "pure-form" } do |f|
- if current_user.penning
= f.collection_select :debtor, User.all, :name, :name,
{ selected: @transaction.debtor.try(:name) || current_user.name }, { class: 'select2-selector'}
- else
= f.hidden_field :debtor, value: current_user.name
= f.select :creditor,
options_from_collection_for_select(User.all.order(:name), :name, :name),
{ include_blank: true },
{ class: 'select2-selector', size: 50 }
= f.text_field :message, required: true, placeholder: "Message", size: 75
= f.number_field :euros, value: (@transaction.amount.zero? ? nil : @transaction.amount/100), placeholder: "Bedrag", step: 0.01, min: 0.01
= f.submit "Send it!", class: "pure-button pure-button-primary"

View file

@ -1,13 +0,0 @@
= render 'partials/form_errors', object: @transaction
= simple_form_for @transaction do |f|
- if current_user.penning
= f.collection_select :debtor, User.all, :name, :name,
{ selected: @transaction.debtor.try(:name) || current_user.name }, { class: 'select2-selector'}
- else
= f.hidden_field :debtor, value: current_user.name
= f.collection_select :creditor, User.all, :name, :name,
{ selected: @transaction.creditor.try(:name) || User.zeus.name }, { class: 'select2-selector' }
= f.input :message, required: true
= f.input :euros, input_html: { value: @transaction.amount/100}
.pure-controls
= f.button :submit, "Send it!"

View file

@ -1,4 +1,5 @@
%h2= @user.name
= render 'transactions/new'
%table#transactions.display{data: { source: user_path(@user) }}
%thead
%tr