 (ns hatti.ona.forms
   (:require [chimera.js-interop :refer [format]]
             [chimera.urls :refer [last-url-param]]
+            [ona.utils.urls :as urls]
+            [ona.utils.i18n :refer [translate]]
             [chimera.date :as chimera-date]
             [cljs.pprint :refer [cl-format]]
             [clojure.string :as string]
             [hatti.constants :refer [_submission_time
                                      _submitted_by
                                      _last_edited
-                                     _id]]))
+                                     _id
+                                     _media_all_received]]))
 
 ;; CONSTANTS
 (def currency-regex #"£|$")

    (or (image? field)
        (video? field)) (let [image (:download_url answer)
                              thumb (or (:small_download_url answer) image)
                              fname (last-url-param (:filename answer))]
                          (cond
                            (string? answer) answer
                            compact? (format "<a href='%s' target='_blank'>
                                      <i class='fa fa-external-link'></i>
                                      %s </a>" image fname)
                            (nil? thumb) answer
                            :else [:a {:href image :target "_blank"}
                                   (if (image? field)
                                     [:img {:width "80px" :src thumb}]

  (and (string? appearance-value)
       (re-matches #"^search\(.*\)$" appearance-value)))

(defn media-files-upload-error-component
  "Displays tip question and tooltip msg for failed media files uploads"
  [answer & {:keys [hlp-url translation-txt record-modal?]}]
  (if record-modal?
    [:span.image-name answer
     [:a.tooltip {:href hlp-url :target "_blank"}
      [:span.tip-info translation-txt]
      [:span.tip-question "?"]]]
    (format "<span class='image-name'> %s </span>
          <a class='tooltip' href=%s target='_blank'>
          <span class='tip-info'>%s</span>
          <span class='tip-question'>?</span></a>"
            answer hlp-url translation-txt)))

(defn format-answer
  "String representation for a particular field datapoint (answer).
   re-formatting depends on field type, eg. name->label substitution.
   Optional: compact? should be true if a short string needs to be returned."
  [field answer & {:keys [language compact? label field-key media record-modal?]
                   :or {field-key :name record-modal? false}}]
  (cond
    (string/blank? answer) no-answer
    (select-one? field) (let [option (->> (:children field)
