Browse Source

Prevent same doc from being enabled twice

Fixes #301.
Thibaut 10 years ago
parent
commit
cb1473f748

+ 1 - 0
assets/javascripts/app/app.coffee

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

+ 3 - 0
assets/javascripts/collections/collection.coffee

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