Skip to content

Commit 3a9888a

Browse files
committed
unified validation display
1 parent 245056d commit 3a9888a

5 files changed

Lines changed: 35 additions & 24 deletions

File tree

resources/sass/form.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ div.form-input-container {
3030
@extend .form-text-input;
3131
}
3232

33+
.json-editor {
34+
border: 1px solid black;
35+
}
36+
3337
// Toggle
3438

3539
/* The switch - the box around the slider */

src/com/yetanalytics/lrs_admin_ui/handlers.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@
809809
::db/statements-upload-analyzed? false)
810810
json-errors (assoc-in [::db/statements-upload-manual-errors :json] json-errors)
811811
(not json-errors) (assoc-in [::db/statements-upload-manual-errors :json] []))
812-
:dispatch-later [{:ms 3000
812+
:dispatch-later [{:ms 1500
813813
:dispatch [:statements-upload/validate-manual-xapi]
814814
:event-id :manual-xapi-validate}]})))
815815

src/com/yetanalytics/lrs_admin_ui/subs.cljs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,13 @@
266266
:statements-upload/manual-json-buffer
267267
:<- [:statements-upload/editor-contents]
268268
:<- [:statements-upload/manual-errors]
269-
(fn [[json errors]]
269+
:<- [:statements-upload/analyzed?]
270+
(fn [[json errors analyzed?]]
270271
{:json (or json "")
271272
:errors errors
272-
:status (if (seq errors) :error :valid)}))
273+
:status (cond (not analyzed?) :loading
274+
(seq errors) :error
275+
:else :valid)}))
273276

274277
(reg-sub
275278
:statements-upload/analyzed?

src/com/yetanalytics/lrs_admin_ui/views/browser.cljs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@
270270
[:div
271271
[json-file-picker]
272272
[:br]
273+
[:h5 {:class "content-title"}
274+
"Manual Statement Entry"]
273275
[manual-json-editor {:buffer buffer
274276
:set-json #(dispatch [:statements-upload/set-editor-contents %])}]
275277
[:br]
@@ -288,7 +290,7 @@
288290
" "
289291
(get % "event"))}
290292
{:name @(subscribe [:lang/get :statements-upload.event-log.header.duration])
291-
:selector #(str (get % "duration"))}
293+
:selector #(str (get % "duration") " ms")}
292294
{:name @(subscribe [:lang/get :statements-upload.event-log.header.timestamp])
293295
:selector #(time/ms->local (get % "timestamp"))}]
294296
data events

src/com/yetanalytics/lrs_admin_ui/views/form/editor.cljs

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -143,25 +143,27 @@
143143
(fn []
144144
(let [{:keys [status errors]} @buffer]
145145
[:div {:class "validation-display-wrapper"}
146-
(if (= :valid status)
147-
[v/validation-static-display
148-
status
149-
"Valid"]
150-
;; Error or Warning
151-
(let [message (format-error-message errors status)
152-
dis-msg (format-error-details-message status)
153-
display [v/validation-item-display
154-
status
155-
dis-msg
156-
display-ref
157-
:message
158-
error-details-display
159-
errors]]
160-
[v/validation-display
161-
status
162-
message
163-
display-ref
164-
display]))]))))
146+
(case status
147+
:valid [v/validation-static-display
148+
status
149+
"Valid"]
150+
:loading [v/validation-static-display
151+
status
152+
"Validating..."]
153+
:error (let [message (format-error-message errors status)
154+
dis-msg (format-error-details-message status)
155+
display [v/validation-item-display
156+
status
157+
dis-msg
158+
display-ref
159+
:message
160+
error-details-display
161+
errors]]
162+
[v/validation-display
163+
status
164+
message
165+
display-ref
166+
display]))]))))
165167

166168
(defn manual-json-editor
167169
"Create a JSON CodeMirror editor similar to buffered-json-editor
@@ -175,7 +177,7 @@
175177
[{:keys [buffer
176178
set-json]}]
177179
(let [{:keys [json]} @buffer]
178-
[:div
180+
[:div.json-editor
179181
(when (not (clojure.string/blank? json))
180182
[raw-text-upload-validation-display
181183
buffer])

0 commit comments

Comments
 (0)