-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
now change add comment will change annotation color
- Loading branch information
Showing
7 changed files
with
75 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(ns ubinote.ui.trigger | ||
(:require | ||
[toucan2.core :as tc] | ||
[ubinote.api.util :as api.u] | ||
[ubinote.models.annotation :as annotation])) | ||
|
||
(defn update-annotation-color-trigger | ||
[annotation-id new-class] | ||
{:trigger-update-annotation-color {:annotation-id annotation-id | ||
:new-class new-class}}) | ||
|
||
(defn update-annotation-color-if-needed | ||
[annotation-id resp] | ||
(let [cmt-count (tc/count :m/comment :annotation_id annotation-id)] | ||
(cond-> resp | ||
;; removed all comments | ||
(zero? cmt-count) | ||
(api.u/htmx-trigger (update-annotation-color-trigger annotation-id (annotation/annotation-color-class false))) | ||
|
||
;; just added a new comment | ||
(= 1 cmt-count) | ||
(api.u/htmx-trigger (update-annotation-color-trigger annotation-id (annotation/annotation-color-class true)))))) |