Reworking flash messages hooray

This commit is contained in:
Will Marshall
2014-06-06 16:41:28 +10:00
parent 37f197205f
commit c9d0091cd9
14 changed files with 36 additions and 26 deletions

View File

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

View File

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

View File

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