                  [?p :created-at ?created-at]
                  [?p :expired ?expired]]]
     (mapv (partial zipmap [:id :domain :username :password :user-id :created-at :expired])
-         (d/q query db))))
-
-
+          (d/q query db))))
+
+(defn add-password [owner]
+  (let [stage (om/get-state owner :stage)
+        username (om/get-state owner :username-input-text)
+        domain (om/get-state owner :domain-input-text)
+        password (om/get-state owner :password-input-text)]
+    (go
+      (<! (s/transact
+           stage
+           ["eve@tresor.net" #uuid "11db6582-e734-4464-a710-6a2bfb502229" "master"]
+           [{:db/id (uuid)
+             :domain domain
+             :username username
+             :password password
+             :user-id (uuid "kordano@topiq.es")
+             :created-at (js/Date.)
+             :expired (js/Date. 2015 0 0)}]
+           '(fn [old params] (:db-after (d/transact old params)))))
+      (<! (s/commit! stage {"eve@tresor.net" {#uuid "11db6582-e734-4464-a710-6a2bfb502229" #{"master"}}})))))
+
+
+(defn handle-text-change [e owner text]
+  (om/set-state! owner text (.. e -target -value)))
 
 
 ;; --- html templating ---

  [pw owner]
  {[:.pw-domain] (content (:domain pw))
   [:.pw-username] (content (:username pw))
   [:.pw-password] (content (:password pw))
   [:.pw-created-at] (content (.toLocaleString (:created-at pw)))
   [:.pw-expired] (content (.toLocaleString (:expired pw)))})


(deftemplate passwords "templates/passwords.html"
  [app owner]
  {[:#password-list] (content (map #(password % owner) (get-passwords app)))})


;; --- views ---

(defn password-view
  "Main list view showing domain, account, password, creation and expiry date"
  [app owner]
  (reify
    om/IRender
    (render [this]
      (passwords app owner))))


;; --- *hust* (start-all-services) *hust* ---


  (-> @stage :volatile :val-atom deref)




 )
