Prevent same doc from being enabled twice

Fixes #301.
pull/303/merge
Thibaut 9 years ago
parent 37454b1e4d
commit cb1473f748

@ -100,6 +100,7 @@
return return
enableDoc: (doc, _onSuccess, onError) -> enableDoc: (doc, _onSuccess, onError) ->
return if @docs.contains(doc)
onSuccess = => onSuccess = =>
@disabledDocs.remove(doc) @disabledDocs.remove(doc)
@docs.add(doc) @docs.add(doc)

@ -38,6 +38,9 @@ class app.Collection
all: -> all: ->
@models @models
contains: (model) ->
@models.indexOf(model) >= 0
findBy: (attr, value) -> findBy: (attr, value) ->
for model in @models for model in @models
return model if model[attr] is value return model if model[attr] is value

Loading…
Cancel
Save