|
23 | 23 | add-snippet
|
24 | 24 | add-snippet-from-backend-map
|
25 | 25 | on-snippet-textarea-change
|
| 26 | + on-click-delete-snippet |
26 | 27 | snippet-color
|
27 | 28 | snippet-color-square
|
28 | 29 | highlight-text
|
|
61 | 62 | (let [text (subs (:content log)
|
62 | 63 | (:start_index itm)
|
63 | 64 | (:end_index itm))
|
64 |
| - text (highlight-text idx |
| 65 | + text (highlight-text (str "snippet-" idx) |
65 | 66 | (safe text)
|
66 | 67 | (:user_comment itm)
|
67 | 68 | (:color (nth @snippets idx)))]
|
|
163 | 164 | {:start-index :start_index
|
164 | 165 | :end-index :end_index
|
165 | 166 | :user-comment :comment})))
|
166 |
| - @snippets))}] |
| 167 | + (remove nil? @snippets)))}] |
167 | 168 |
|
168 | 169 | ;; Remember the username, so we can prefill it the next time
|
169 | 170 | ;; TODO See PR #130
|
|
234 | 235 | (fontawesome-icon "fa-thumbs-down")]]))
|
235 | 236 |
|
236 | 237 | (defn snippet [text index color]
|
237 |
| - (let [name (str "snippet-" index)] |
238 |
| - {:title [:<> (snippet-color-square color) "Snippet"] |
239 |
| - :body |
240 |
| - [:textarea |
241 |
| - {:class "form-control" |
242 |
| - :rows "3" |
243 |
| - :placeholder "What makes this snippet relevant?" |
244 |
| - :value text |
245 |
| - :on-change #(do (on-snippet-textarea-change %) |
246 |
| - (vote (keyword name) 1))}] |
247 |
| - :buttons (buttons name)})) |
| 238 | + (when color |
| 239 | + (let [name (str "snippet-" index)] |
| 240 | + {:title [:<> (snippet-color-square color) "Snippet"] |
| 241 | + :body |
| 242 | + [:textarea |
| 243 | + {:class "form-control" |
| 244 | + :rows "3" |
| 245 | + :placeholder "What makes this snippet relevant?" |
| 246 | + :value text |
| 247 | + :on-change #(do (on-snippet-textarea-change %) |
| 248 | + (vote (keyword name) 1))}] |
| 249 | + :buttons |
| 250 | + (conj (buttons name) |
| 251 | + [:button {:type "button" |
| 252 | + :class ["btn btn-vote btn-outline-danger"] |
| 253 | + :on-click #(on-click-delete-snippet %)} |
| 254 | + (fontawesome-icon "fa-trash-can")])}))) |
248 | 255 |
|
249 | 256 | (defn card [title text name placeholder]
|
250 | 257 | [:div {:class "card review-card"}
|
|
0 commit comments