Skip to content
Browse files

made custom slug validation aware of deleted documents again

  • Loading branch information...
1 parent 8924040 commit 1b54fa1960160de4230323a357a5dcd02ab6d2ba @fmw committed Oct 12, 2012
Showing with 14 additions and 9 deletions.
  1. +14 −9 src/cljs/src/views/editor.cljs
View
23 src/cljs/src/views/editor.cljs
@@ -301,17 +301,22 @@
handle-duplicate-slug-callback))))))
(defn handle-duplicate-custom-slug-callback [e]
- (let [status (. (.-target e) (getStatus))
- slug-el (dom/getElement "slug")
+ (let [slug-el (dom/getElement "slug")
slug-label-el (dom/getElement "slug-label")
- status-el (dom/getElement "status-message")]
+ status-el (dom/getElement "status-message")
+ xhr (.-target e)
+ status (. xhr (getStatus))
+ last-state (first
+ (reader/read-string (. xhr (getResponseText))))]
(cond
- (= status 200) (ui/display-error status-el
- slug-not-unique-err
- slug-el
- slug-label-el)
- :else (when (= (. status-el -textContent) slug-not-unique-err)
- (ui/remove-error status-el slug-el slug-label-el)))))
+ (and (= status 200) (not (= (:action last-state) :delete)))
+ (ui/display-error status-el
+ slug-not-unique-err
+ slug-el
+ slug-label-el)
+ :else
+ (when (= (. status-el -textContent) slug-not-unique-err)
+ (ui/remove-error status-el slug-el slug-label-el)))))
(def *file* (atom {}))

0 comments on commit 1b54fa1

Please sign in to comment.
Something went wrong with that request. Please try again.