Add flash messages on quickpay
This commit is contained in:
parent
5b922ceab5
commit
8906ca7e39
4 changed files with 23 additions and 29 deletions
|
@ -1,5 +1,7 @@
|
|||
ready = function() {
|
||||
$('[data-quickpay]').on("ajax:success", function (e, data, status, xhr) {
|
||||
|
||||
// Last Image
|
||||
var img = $("<img>", {
|
||||
src: $(this).closest(".overviewthumbnail").find(".avatar").attr("src").replace("large", "small"),
|
||||
class: [ "img-responsive img-circle img-thumbnail" ]
|
||||
|
@ -8,7 +10,25 @@ ready = function() {
|
|||
if ($("#last").find("img").size() > 10) {
|
||||
$("#last").find("img").last().remove();
|
||||
}
|
||||
}).on("ajax:error", function (e, xhr, status, error) {
|
||||
$(".alert").fadeOut();
|
||||
|
||||
// Flash Message
|
||||
var div = $("<div>", {
|
||||
class: [ "alert alert-success alert-dismissable" ]
|
||||
});
|
||||
$(div).append($("<button>", {
|
||||
text: 'x',
|
||||
class: "close",
|
||||
data: { dismiss: "alert" }
|
||||
}));
|
||||
$(div).append($("<strong>", {
|
||||
text: "Success! "
|
||||
}));
|
||||
$(div).append(data.message);
|
||||
|
||||
$("#flash").append(div);
|
||||
|
||||
}) .on("ajax:error", function (e, xhr, status, error) {
|
||||
alert("Error while using quickpay ... sorry.");
|
||||
});
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ class UsersController < ApplicationController
|
|||
order.order_items.build(count: 1, product: @user.dagschotel)
|
||||
if order.save
|
||||
respond_to do |format|
|
||||
format.js { head :ok }
|
||||
format.js { render json: { message: "Quick pay succeeded for #{@user.name}." }, status: :ok }
|
||||
format.html {
|
||||
flash[:success] = "Quick pay succeeded."
|
||||
redirect_to root_path
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
#flash
|
||||
- if flash[:error]
|
||||
.alert.alert-danger.alert-dismissable
|
||||
%button.close{"aria-hidden" => "true", "data-dismiss" => "alert", type: "button"} ×
|
||||
%strong Error!
|
||||
= flash[:error]
|
||||
- if flash[:success]
|
||||
.alert.alert-success.alert-dismissable
|
||||
%button.close{"aria-hidden" => "true", "data-dismiss" => "alert", type: "button"} ×
|
||||
%strong Success!
|
||||
= flash[:success]
|
||||
- if flash[:notice]
|
||||
.alert.alert-info.alert-dismissable
|
||||
%button.close{"aria-hidden" => "true", "data-dismiss" => "alert", type: "button"} ×
|
||||
%strong Notice!
|
||||
= flash[:notice]
|
||||
- if flash[:warning]
|
||||
.alert.alert-warning.alert-dismissable
|
||||
%button.close{"aria-hidden" => "true", "data-dismiss" => "alert", type: "button"} ×
|
||||
%strong Warning!
|
||||
= flash[:warning]
|
||||
- if flash[:alert]
|
||||
.alert.alert-danger.alert-dismissable
|
||||
%button.close{"aria-hidden" => "true", "data-dismiss" => "alert", type: "button"} ×
|
||||
%strong Error!
|
||||
= flash[:alert]
|
|
@ -1,6 +1,6 @@
|
|||
.col-md-2.overviewthumbnail
|
||||
- unless user.dagschotel.nil?
|
||||
= link_to quickpay_user_path(user), remote: true, data: { quickpay: true } do
|
||||
= link_to quickpay_user_path(user), remote: true, data: { quickpay: true, type: "json" } 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