Add way to see changes in quickpay
This commit is contained in:
parent
e8e4fc6855
commit
5b922ceab5
6 changed files with 44 additions and 5 deletions
17
app/assets/javascripts/quickpay.js
Normal file
17
app/assets/javascripts/quickpay.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
ready = function() {
|
||||
$('[data-quickpay]').on("ajax:success", function (e, data, status, xhr) {
|
||||
var img = $("<img>", {
|
||||
src: $(this).closest(".overviewthumbnail").find(".avatar").attr("src").replace("large", "small"),
|
||||
class: [ "img-responsive img-circle img-thumbnail" ]
|
||||
})
|
||||
$(img).hide().prependTo($("#last")).fadeIn();
|
||||
if ($("#last").find("img").size() > 10) {
|
||||
$("#last").find("img").last().remove();
|
||||
}
|
||||
}).on("ajax:error", function (e, xhr, status, error) {
|
||||
alert("Error while using quickpay ... sorry.");
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(ready);
|
||||
$(document).on('page:load', ready);
|
3
app/assets/stylesheets/last.css.scss
Normal file
3
app/assets/stylesheets/last.css.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
#last img {
|
||||
margin-bottom: 10px;
|
||||
}
|
|
@ -25,6 +25,7 @@ class OrdersController < ApplicationController
|
|||
|
||||
def overview
|
||||
@users = User.members.publik.order(:name)
|
||||
@last = Order.order(:created_at).reverse_order.includes(:user).limit(10).map(&:user)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -29,11 +29,22 @@ class UsersController < ApplicationController
|
|||
order = @user.orders.build
|
||||
order.order_items.build(count: 1, product: @user.dagschotel)
|
||||
if order.save
|
||||
flash[:success] = "Quick pay succeeded."
|
||||
respond_to do |format|
|
||||
format.js { head :ok }
|
||||
format.html {
|
||||
flash[:success] = "Quick pay succeeded."
|
||||
redirect_to root_path
|
||||
}
|
||||
end
|
||||
else
|
||||
flash[:error] = order.errors.full_messages.first
|
||||
respond_to do |format|
|
||||
format.js { head :unprocessable_entity }
|
||||
format.html {
|
||||
flash[:error] = order.errors.full_messages.first
|
||||
redirect_to root_path
|
||||
}
|
||||
end
|
||||
end
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
.warning.center
|
||||
%h1 TESTFASE | GELIEVE STREEPJES TE BLIJVEN ZETTEN | TESTFASE
|
||||
.row
|
||||
= render @users
|
||||
.col-md-1
|
||||
%h5 Recent
|
||||
#last
|
||||
- @last.each do |user|
|
||||
= image_tag user.avatar(:small), class: "img-responsive img-circle img-thumbnail"
|
||||
.col-md-11
|
||||
.row
|
||||
= render @users
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.col-md-2.overviewthumbnail
|
||||
- unless user.dagschotel.nil?
|
||||
= link_to quickpay_user_path(user) do
|
||||
= link_to quickpay_user_path(user), remote: true, data: { quickpay: true } do
|
||||
= image_tag user.dagschotel.avatar(:dagschotel), class: "img-circle dagschotel"
|
||||
= link_to image_tag(user.avatar(:large) , class: "img-circle avatar"), new_user_order_path(user)
|
||||
= link_to user.name , new_user_order_path(user), class: "btn btn-info", style: get_color_style(user)
|
||||
|
|
Loading…
Reference in a new issue