Revert "Reworking flash messages hooray"

This reverts commit c9d0091cd9.
This commit is contained in:
Rohan Mitchell
2014-06-06 16:59:47 +10:00
parent c9d0091cd9
commit be644bdcc3
14 changed files with 26 additions and 36 deletions

View File

@@ -1,11 +1,10 @@
Darkswarm.directive "ofnFlash", (flash, $timeout, RailsFlashLoader)->
# Mappings between flash types (left) and Foundation classes
Darkswarm.directive "ofnFlash", (flash, $timeout)->
typePairings =
info: "info"
info: "standard"
error: "alert"
success: "success"
scope: {}
restrict: 'E'
restrict: 'AE'
templateUrl: "flash.html"
controller: ($scope)->
$scope.closeAlert = (index)->
@@ -22,4 +21,3 @@ Darkswarm.directive "ofnFlash", (flash, $timeout, RailsFlashLoader)->
$scope.flashes.shift()
flash.subscribe(show)
RailsFlashLoader.initFlash()

View File

@@ -0,0 +1,9 @@
Darkswarm.factory 'Flash', (flash)->
new class Flash
loadFlash: (rails_flash)->
for type, message of rails_flash
switch type
when "notice"
flash.info = message
else
flash[type] = message

View File

@@ -6,7 +6,11 @@ Darkswarm.factory "OfnMap", (enterprisesForMap, MapModal)->
# Adding methods to each enterprise
extend: (enterprise)->
new class MapMarker
icon: "/test.opng"
constructor: ->
@[k] = v for k, v of enterprise
reveal: =>
console.log @
MapModal.open @

View File

@@ -1,4 +1,4 @@
Darkswarm.factory 'Order', ($resource, order, $http, Navigation, storage, CurrentHub, RailsFlashLoader)->
Darkswarm.factory 'Order', ($resource, order, $http, flash, Navigation, storage, CurrentHub)->
new class Order
errors: {}
secrets: {}
@@ -24,8 +24,8 @@ Darkswarm.factory 'Order', ($resource, order, $http, Navigation, storage, Curren
Navigation.go data.path
.error (response, status)=>
@errors = response.errors
RailsFlashLoader.loadFlash(response.flash)
flash.error = response.flash?.error
flash.success = response.flash?.notice
# Rails wants our Spree::Address data to be provided with _attributes
preprocess: ->

View File

@@ -1,7 +0,0 @@
Darkswarm.factory 'RailsFlashLoader', (flash, railsFlash)->
new class RailsFlashLoader
initFlash: ->
@loadFlash railsFlash
loadFlash: (rails_flash)->
for type, message of rails_flash
flash[type] = message

View File

@@ -2,8 +2,7 @@
.small-12.columns.producer-hero
%h3.producer-name
%i.ofn-i_036-producers
{{ enterprise.name }}
{{ enterprise.id }}
{{ producer.name }}
%img.producer-hero-img{"ng-src" => "{{enterprise.promo_image}}"}
.row

View File

@@ -37,7 +37,7 @@ class ApplicationController < ActionController::Base
session[:expired_order_cycle_id] = current_order_cycle.id
current_order.empty!
current_order.set_order_cycle! nil
flash[:info] = "The order cycle you've selected has just closed. Please try again!"
flash[:notice] = "The order cycle you've selected has just closed. Please try again!"
redirect_to root_url
end
end

View File

@@ -35,7 +35,7 @@ class CheckoutController < Spree::CheckoutController
end
end
if @order.state == "complete" || @order.completed?
flash[:success] = t(:order_processed_successfully)
flash.notice = t(:order_processed_successfully)
respond_to do |format|
format.html do
respond_with(@order, :location => order_path(@order))

View File

@@ -5,7 +5,7 @@ class UserPasswordsController < Spree::UserPasswordsController
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
if resource.errors.empty?
set_flash_message(:success, :send_instructions) if is_navigational_format?
set_flash_message(:notice, :send_instructions) if is_navigational_format?
respond_with resource, :location => spree.login_path
else
respond_to do |format|

View File

@@ -4,7 +4,7 @@ class UserRegistrationsController < Spree::UserRegistrationsController
def create
@user = build_resource(params[:spree_user])
if resource.save
set_flash_message(:success, :signed_up)
set_flash_message(:notice, :signed_up)
sign_in(:spree_user, @user)
session[:spree_user_signup] = true
associate_user

View File

@@ -1,2 +0,0 @@
object OpenStruct.new(flash)
attributes :info, :success, :error

View File

@@ -21,12 +21,12 @@
= inject_json "currentHub", "current_hub"
= inject_json "currentOrder", "current_order"
= inject_json "user", "current_user"
= inject_json "railsFlash", "flash"
.off-canvas-wrap{offcanvas: true}
.inner-wrap
= render partial: "shared/menu/menu"
= display_flash_messages
%ofn-flash
%section{ role: "main" }

View File

@@ -16,6 +16,6 @@ describe BaseController do
oc.stub(:closed?).and_return true
get :index
response.should redirect_to root_url
flash[:info].should == "The order cycle you've selected has just closed. Please try again!"
flash[:notice].should == "The order cycle you've selected has just closed. Please try again!"
end
end

View File

@@ -146,17 +146,6 @@ feature "As a consumer I want to check out my cart", js: true do
place_order
page.should have_content "Your order has been processed successfully"
end
it "shows the payment processing failed message when submitted with an invalid credit card" do
toggle_payment
fill_in 'Card Number', with: "9999999988887777"
select 'February', from: 'secrets.card_month'
select (Date.today.year+1).to_s, from: 'secrets.card_year'
fill_in 'Security Code', with: '123'
place_order
page.should have_content "Payment could not be processed, please check the details you entered"
end
end
end
end