vendor/assets/javascripts/iugu-ux/components/base_resource.js.coffee in iugu-ux-1.0.9 vs vendor/assets/javascripts/iugu-ux/components/base_resource.js.coffee in iugu-ux-1.0.10
- old
+ new
@@ -40,24 +40,20 @@
generateRemoveFunction: (relation) ->
@["removeFrom#{@properCasedRelationName relation.key}"] = (object) ->
@get(relation.key).destroy(object)
- sync: (method, model, options) ->
- @configureAjax()
- Backbone.sync method, model, options
-
toJSON: (options) ->
_.omit( _.clone( super(options) ), @virtual_attributes )
url: ->
base = super
base = @appendLocaleInfo(base)
save: (attributes, options) ->
if @isValid(true)
- super null, @handleViewContext options
+ super attributes, @handleViewContext options
handleViewContext: (options) ->
return options unless options.context
options.context.enableLoader()
options.wait = true
@@ -75,18 +71,22 @@
options
destroy: (options) ->
super @handleViewContext options
+ getAjaxParameters: ->
+ return if ajax_params? then ajax_params else {}
+
configureAjax: ->
app.ajaxSetup
headers:
Authorization: $.base64.encode api_token
+ data: @getAjaxParameters()
appendLocaleInfo: (uri) ->
uri + (if uri.indexOf('?') then '?' else '&') + 'hl=' + encodeURIComponent( i18n.locale )
request: ( type, url, options ) ->
- @configureAjax()
options = _.extend options,
type: type
+
app.ajax url, options