mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Replace views/json/_current_user.rabl with an ams injector with serializer
This commit is contained in:
@@ -111,6 +111,10 @@ module InjectionHelper
|
||||
inject_json_ams "savedCreditCards", data, Api::CreditCardSerializer
|
||||
end
|
||||
|
||||
def inject_current_user
|
||||
inject_json_ams "user", spree_current_user, Api::UserSerializer
|
||||
end
|
||||
|
||||
def inject_json(name, partial, opts = {})
|
||||
render partial: "json/injection", locals: { name: name, partial: partial }.merge(opts)
|
||||
end
|
||||
|
||||
3
app/serializers/api/user_serializer.rb
Normal file
3
app/serializers/api/user_serializer.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class Api::UserSerializer < ActiveModel::Serializer
|
||||
attributes :id, :email
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
object spree_current_user
|
||||
attributes :email, :id
|
||||
@@ -43,7 +43,7 @@
|
||||
= yield :scripts
|
||||
|
||||
= inject_current_hub
|
||||
= inject_json "user", "current_user"
|
||||
= inject_current_user
|
||||
= inject_json "railsFlash", "flash"
|
||||
= inject_taxons
|
||||
= inject_properties
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
= javascript_include_tag "darkswarm/all"
|
||||
= yield :scripts
|
||||
|
||||
= inject_json "user", "current_user"
|
||||
= inject_current_user
|
||||
= yield :injection_data
|
||||
|
||||
= render "layouts/i18n_script"
|
||||
|
||||
Reference in New Issue
Block a user