mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 15:48:11 -05:00
Working on User patching.
This commit is contained in:
parent
7fd87f2605
commit
6d15b5e631
6 changed files with 17 additions and 6 deletions
|
@ -104,10 +104,14 @@ class CocoModel extends Backbone.Model
|
|||
options.patch = true
|
||||
|
||||
attrs = {_id: @id}
|
||||
anythingChanged = false
|
||||
for key in _.keys @attributes
|
||||
unless _.isEqual @attributes[key], @_revertAttributes[key]
|
||||
attrs[key] = @attributes[key]
|
||||
|
||||
anythingChanged = true
|
||||
|
||||
return unless anythingChanged
|
||||
console.debug 'Patching', @, attrs
|
||||
@save(attrs, options)
|
||||
|
||||
fetch: ->
|
||||
|
|
|
@ -36,7 +36,7 @@ module.exports = class ContributeClassView extends View
|
|||
subscription = el.attr('name')
|
||||
|
||||
me.setEmailSubscription subscription+'News', checked
|
||||
me.save()
|
||||
me.patch()
|
||||
@openModalView new SignupModalView() if me.get 'anonymous'
|
||||
el.parent().find('.saved-notification').finish().show('fast').delay(3000).fadeOut(2000)
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ module.exports = class RootView extends CocoView
|
|||
|
||||
saveLanguage: (newLang) ->
|
||||
me.set('preferredLanguage', newLang)
|
||||
res = me.save()
|
||||
res = me.patch()
|
||||
return unless res
|
||||
res.error ->
|
||||
errors = JSON.parse(res.responseText)
|
||||
|
|
|
@ -12,7 +12,7 @@ module.exports = class DiplomatSuggestionView extends View
|
|||
|
||||
subscribeAsDiplomat: ->
|
||||
me.setEmailSubscription 'diplomatNews', true
|
||||
me.save()
|
||||
me.patch()
|
||||
$("#email_translator").prop("checked", 1)
|
||||
@hide()
|
||||
return
|
||||
|
|
|
@ -40,7 +40,7 @@ module.exports = class WizardSettingsModal extends View
|
|||
forms.applyErrorsToForm(@$el, res)
|
||||
return
|
||||
|
||||
res = me.save()
|
||||
res = me.patch()
|
||||
return unless res
|
||||
save = $('#save-button', @$el).text($.i18n.t('common.saving', defaultValue: 'Saving...'))
|
||||
.addClass('btn-info').show().removeClass('btn-danger')
|
||||
|
|
|
@ -74,4 +74,11 @@ describe 'CocoModel', ->
|
|||
request = jasmine.Ajax.requests.mostRecent()
|
||||
params = JSON.parse request.params
|
||||
expect(params.object).toBeUndefined()
|
||||
|
||||
|
||||
it 'does nothing when there\'s nothing to patch', ->
|
||||
b = new BlandClass({_id: 'test', number:1})
|
||||
b.loaded = true
|
||||
b.set('number', 1)
|
||||
b.patch()
|
||||
request = jasmine.Ajax.requests.mostRecent()
|
||||
expect(request).toBeUndefined()
|
||||
|
|
Loading…
Reference in a new issue