Remove usage of deprecated functions from lentes library.

This commit is contained in:
Andrey Antukh 2016-06-22 22:23:24 +03:00
parent 73b901954a
commit f80ac704a7
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
32 changed files with 62 additions and 68 deletions

View file

@ -80,11 +80,11 @@
(defn focus-form-data (defn focus-form-data
[type] [type]
(-> (l/in [:forms type]) (-> (l/in [:forms type])
(l/focus-atom st/state))) (l/derive st/state)))
(defn focus-form-errors (defn focus-form-errors
[type] [type]
(-> (l/in [:errors type]) (-> (l/in [:errors type])
(l/focus-atom st/state))) (l/derive st/state)))

View file

@ -19,7 +19,7 @@
(def auth-l (def auth-l
(-> (l/key :auth) (-> (l/key :auth)
(l/focus-atom state))) (l/derive state)))
(defn initial-state (defn initial-state
[] []

View file

@ -44,7 +44,7 @@
(def route-l (def route-l
(-> (l/key :route) (-> (l/key :route)
(l/focus-atom st/state))) (l/derive st/state)))
;; --- Error Handling ;; --- Error Handling

View file

@ -27,11 +27,11 @@
(def form-data (def form-data
(-> (l/in [:forms :recovery]) (-> (l/in [:forms :recovery])
(l/focus-atom st/state))) (l/derive st/state)))
(def form-errors (def form-errors
(-> (l/in [:errors :recovery]) (-> (l/in [:errors :recovery])
(l/focus-atom st/state))) (l/derive st/state)))
(def set-value! (def set-value!
(partial udf/assign-field-value :recovery)) (partial udf/assign-field-value :recovery))

View file

@ -27,11 +27,11 @@
(def form-data (def form-data
(-> (l/in [:forms :recovery-request]) (-> (l/in [:forms :recovery-request])
(l/focus-atom st/state))) (l/derive st/state)))
(def form-errors (def form-errors
(-> (l/in [:errors :recovery-request]) (-> (l/in [:errors :recovery-request])
(l/focus-atom st/state))) (l/derive st/state)))
(def set-value! (def set-value!
(partial udf/assign-field-value :recovery-request)) (partial udf/assign-field-value :recovery-request))

View file

@ -27,11 +27,11 @@
(def form-data (def form-data
(-> (l/in [:forms :register]) (-> (l/in [:forms :register])
(l/focus-atom st/state))) (l/derive st/state)))
(def form-errors (def form-errors
(-> (l/in [:errors :register]) (-> (l/in [:errors :register])
(l/focus-atom st/state))) (l/derive st/state)))
(def set-value! (def set-value!
(partial udf/assign-field-value :register)) (partial udf/assign-field-value :register))

View file

@ -33,17 +33,17 @@
(def ^:private dashboard-l (def ^:private dashboard-l
(-> (l/key :dashboard) (-> (l/key :dashboard)
(l/focus-atom st/state))) (l/derive st/state)))
(def ^:private collections-by-id-l (def ^:private collections-by-id-l
(-> (comp (l/key :colors-by-id) (-> (comp (l/key :colors-by-id)
(ul/merge library/+color-collections-by-id+)) (ul/merge library/+color-collections-by-id+))
(l/focus-atom st/state))) (l/derive st/state)))
(defn- focus-collection (defn- focus-collection
[collid] [collid]
(-> (l/key collid) (-> (l/key collid)
(l/focus-atom collections-by-id-l))) (l/derive collections-by-id-l)))
;; --- Page Title ;; --- Page Title

View file

@ -21,7 +21,7 @@
(def header-l (def header-l
(as-> (l/in [:dashboard]) $ (as-> (l/in [:dashboard]) $
(l/focus-atom $ s/state))) (l/derive $ s/state)))
(defn- header-link (defn- header-link
[section content] [section content]

View file

@ -27,7 +27,7 @@
(def dashboard-l (def dashboard-l
(as-> (l/in [:dashboard]) $ (as-> (l/in [:dashboard]) $
(l/focus-atom $ st/state))) (l/derive $ st/state)))
;; --- Page Title ;; --- Page Title

View file

@ -54,24 +54,24 @@
(def ^:private dashboard-l (def ^:private dashboard-l
(-> (l/key :dashboard) (-> (l/key :dashboard)
(l/focus-atom st/state))) (l/derive st/state)))
(def ^:private collections-by-id-l (def ^:private collections-by-id-l
(-> (l/key :images-by-id) (-> (l/key :images-by-id)
(l/focus-atom st/state))) (l/derive st/state)))
(def ^:private images-ordering-l (def ^:private images-ordering-l
(-> (l/in [:dashboard :images-order]) (-> (l/in [:dashboard :images-order])
(l/focus-atom st/state))) (l/derive st/state)))
(def ^:private images-filtering-l (def ^:private images-filtering-l
(-> (l/in [:dashboard :images-filter]) (-> (l/in [:dashboard :images-filter])
(l/focus-atom st/state))) (l/derive st/state)))
(defn- focus-collection (defn- focus-collection
[collid] [collid]
(-> (l/key collid) (-> (l/key collid)
(l/focus-atom collections-by-id-l))) (l/derive collections-by-id-l)))
;; --- Page Title ;; --- Page Title

View file

@ -64,15 +64,15 @@
(def projects-by-id-l (def projects-by-id-l
(as-> (l/key :projects-by-id) $ (as-> (l/key :projects-by-id) $
(l/focus-atom $ s/state))) (l/derive $ s/state)))
(def project-ordering-l (def project-ordering-l
(as-> (l/in [:dashboard :project-order]) $ (as-> (l/in [:dashboard :project-order]) $
(l/focus-atom $ s/state))) (l/derive $ s/state)))
(def project-filtering-l (def project-filtering-l
(as-> (l/in [:dashboard :project-filter]) $ (as-> (l/in [:dashboard :project-filter]) $
(l/focus-atom $ s/state))) (l/derive $ s/state)))
;; --- Sort Widget ;; --- Sort Widget

View file

@ -15,7 +15,7 @@
(def ^:const ^:private lightbox-l (def ^:const ^:private lightbox-l
(-> (l/key :lightbox) (-> (l/key :lightbox)
(l/focus-atom st/state))) (l/derive st/state)))
;; --- Lightbox (Component) ;; --- Lightbox (Component)

View file

@ -14,7 +14,7 @@
(def ^:const ^:private message-l (def ^:const ^:private message-l
(-> (l/key :message) (-> (l/key :message)
(l/focus-atom st/state))) (l/derive st/state)))
;; --- Notification Component ;; --- Notification Component

View file

@ -21,7 +21,7 @@
(def ^:private section-l (def ^:private section-l
(-> (l/in [:route :id]) (-> (l/in [:route :id])
(l/focus-atom st/state))) (l/derive st/state)))
(defn- header-link (defn- header-link
[section content] [section content]

View file

@ -28,11 +28,11 @@
(def formdata (def formdata
(-> (l/in [:forms :profile/password]) (-> (l/in [:forms :profile/password])
(l/focus-atom st/state))) (l/derive st/state)))
(def formerrors (def formerrors
(-> (l/in [:errors :profile/password]) (-> (l/in [:errors :profile/password])
(l/focus-atom st/state))) (l/derive st/state)))
(def assign-field-value (def assign-field-value
(partial udf/assign-field-value :profile/password)) (partial udf/assign-field-value :profile/password))

View file

@ -28,18 +28,18 @@
(def formdata (def formdata
(-> (l/in [:forms :profile/main]) (-> (l/in [:forms :profile/main])
(l/focus-atom st/state))) (l/derive st/state)))
(def formerrors (def formerrors
(-> (l/in [:errors :profile/main]) (-> (l/in [:errors :profile/main])
(l/focus-atom st/state))) (l/derive st/state)))
(def assign-field-value (def assign-field-value
(partial udf/assign-field-value :profile/main)) (partial udf/assign-field-value :profile/main))
(def ^:private profile-l (def ^:private profile-l
(-> (l/key :profile) (-> (l/key :profile)
(l/focus-atom st/state))) (l/derive st/state)))
;; --- Profile Form ;; --- Profile Form

View file

@ -16,7 +16,7 @@
(defn- focus-shape (defn- focus-shape
[id] [id]
(-> (l/in [:shapes-by-id id]) (-> (l/in [:shapes-by-id id])
(l/focus-atom st/state))) (l/derive st/state)))
(defn- shape-render (defn- shape-render
[own id] [own id]

View file

@ -19,11 +19,11 @@
(def ^:const selected-shapes-l (def ^:const selected-shapes-l
(-> (l/in [:workspace :selected]) (-> (l/in [:workspace :selected])
(l/focus-atom st/state))) (l/derive st/state)))
(def ^:const drawing-state-l (def ^:const drawing-state-l
(-> (l/in [:workspace :drawing]) (-> (l/in [:workspace :drawing])
(l/focus-atom st/state))) (l/derive st/state)))
;; --- Events ;; --- Events

View file

@ -52,7 +52,7 @@
(def profile-l (def profile-l
(as-> (l/key :profile) $ (as-> (l/key :profile) $
(l/focus-atom $ s/state))) (l/derive $ s/state)))
(defn user-render (defn user-render
[own] [own]

View file

@ -14,7 +14,6 @@
[uxbox.main.data.workspace :as dw] [uxbox.main.data.workspace :as dw]
[uxbox.main.data.shapes :as uds] [uxbox.main.data.shapes :as uds]
[uxbox.common.geom.point :as gpt] [uxbox.common.geom.point :as gpt]
[uxbox.util.lens :as ul]
[goog.events :as events]) [goog.events :as events])
(:import goog.events.EventType)) (:import goog.events.EventType))
@ -22,49 +21,49 @@
(def ^:const workspace-l (def ^:const workspace-l
(as-> (l/in [:workspace]) $ (as-> (l/in [:workspace]) $
(l/focus-atom $ st/state))) (l/derive $ st/state)))
(def ^:const project-l (def ^:const project-l
(letfn [(getter [state] (letfn [(getter [state]
(let [project (get-in state [:workspace :project])] (let [project (get-in state [:workspace :project])]
(get-in state [:projects-by-id project])))] (get-in state [:projects-by-id project])))]
(as-> (l/getter getter) $ (as-> (l/lens getter) $
(l/focus-atom $ st/state)))) (l/derive $ st/state))))
(def ^:const page-l (def ^:const page-l
(letfn [(getter [state] (letfn [(getter [state]
(let [page (get-in state [:workspace :page])] (let [page (get-in state [:workspace :page])]
(get-in state [:pages-by-id page])))] (get-in state [:pages-by-id page])))]
(as-> (ul/getter getter) $ (as-> (l/lens getter) $
(l/focus-atom $ st/state)))) (l/derive $ st/state))))
(def ^:const selected-shapes-l (def ^:const selected-shapes-l
(as-> (l/in [:selected]) $ (as-> (l/in [:selected]) $
(l/focus-atom $ workspace-l))) (l/derive $ workspace-l)))
(def ^:const toolboxes-l (def ^:const toolboxes-l
(as-> (l/in [:toolboxes]) $ (as-> (l/in [:toolboxes]) $
(l/focus-atom $ workspace-l))) (l/derive $ workspace-l)))
(def ^:const flags-l (def ^:const flags-l
(as-> (l/in [:flags]) $ (as-> (l/in [:flags]) $
(l/focus-atom $ workspace-l))) (l/derive $ workspace-l)))
(def ^:const shapes-by-id-l (def ^:const shapes-by-id-l
(as-> (l/key :shapes-by-id) $ (as-> (l/key :shapes-by-id) $
(l/focus-atom $ st/state))) (l/derive $ st/state)))
(def ^:const zoom-l (def ^:const zoom-l
(-> (l/in [:workspace :zoom]) (-> (l/in [:workspace :zoom])
(l/focus-atom st/state))) (l/derive st/state)))
(def ^:const alignment-l (def ^:const alignment-l
(letfn [(getter [flags] (letfn [(getter [flags]
(and (contains? flags :grid/indexed) (and (contains? flags :grid/indexed)
(contains? flags :grid/alignment) (contains? flags :grid/alignment)
(contains? flags :grid)))] (contains? flags :grid)))]
(-> (l/getter getter) (-> (l/lens getter)
(l/focus-atom flags-l)))) (l/derive flags-l))))
;; --- Scroll Stream ;; --- Scroll Stream

View file

@ -23,7 +23,7 @@
(def ^:const ^:private clipboard-l (def ^:const ^:private clipboard-l
(-> (l/key :clipboard) (-> (l/key :clipboard)
(l/focus-atom st/state))) (l/derive st/state)))
;; --- Clipboard Dialog Component ;; --- Clipboard Dialog Component

View file

@ -33,7 +33,7 @@
(def ^:private collections-by-id-l (def ^:private collections-by-id-l
(-> (comp (l/in [:colors-by-id]) (-> (comp (l/in [:colors-by-id])
(ul/merge library/+color-collections-by-id+)) (ul/merge library/+color-collections-by-id+))
(l/focus-atom st/state))) (l/derive st/state)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Component ;; Component

View file

@ -29,7 +29,7 @@
(defn- focus-shape (defn- focus-shape
[id] [id]
(as-> (l/in [:shapes-by-id id]) $ (as-> (l/in [:shapes-by-id id]) $
(l/focus-atom $ st/state))) (l/derive $ st/state)))
(defn- colorpicker-render (defn- colorpicker-render
[own {:keys [x y shape attr] :as opts}] [own {:keys [x y shape attr] :as opts}]

View file

@ -32,8 +32,8 @@
(letfn [(getter [state] (letfn [(getter [state]
(let [selected (get-in state [:workspace :selected])] (let [selected (get-in state [:workspace :selected])]
(mapv #(get-in state [:shapes-by-id %]) selected)))] (mapv #(get-in state [:shapes-by-id %]) selected)))]
(-> (l/getter getter) (-> (l/lens getter)
(l/focus-atom st/state)))) (l/derive st/state))))
;; --- Selection Handlers (Component) ;; --- Selection Handlers (Component)

View file

@ -31,7 +31,7 @@
rerender the whole toolbox on each workspace rerender the whole toolbox on each workspace
change." change."
(as-> (l/in [:workspace :drawing]) $ (as-> (l/in [:workspace :drawing]) $
(l/focus-atom $ st/state))) (l/derive $ st/state)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Draw Tools ;; Draw Tools

View file

@ -29,7 +29,7 @@
(def ^:const history-l (def ^:const history-l
(as-> (l/in [:workspace :history]) $ (as-> (l/in [:workspace :history]) $
(l/focus-atom $ st/state))) (l/derive $ st/state)))
;; --- History Item (Component) ;; --- History Item (Component)

View file

@ -31,7 +31,7 @@
rerender the whole toolbox on each workspace rerender the whole toolbox on each workspace
change." change."
(as-> (l/in [:workspace :drawing]) $ (as-> (l/in [:workspace :drawing]) $
(l/focus-atom $ st/state))) (l/derive $ st/state)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Icons ;; Icons

View file

@ -32,7 +32,7 @@
(defn- focus-page (defn- focus-page
[pageid] [pageid]
(as-> (l/in [:pages-by-id pageid]) $ (as-> (l/in [:pages-by-id pageid]) $
(l/focus-atom $ st/state))) (l/derive $ st/state)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Components ;; Components

View file

@ -106,8 +106,8 @@
(let [selected (get-in state [:workspace :selected])] (let [selected (get-in state [:workspace :selected])]
(when (= 1 (count selected)) (when (= 1 (count selected))
(get-in state [:shapes-by-id (first selected)]))))] (get-in state [:shapes-by-id (first selected)]))))]
(as-> (l/getter getter) $ (-> (l/lens getter)
(l/focus-atom $ st/state)))) (l/derive st/state))))
(defn options-toolbox-render (defn options-toolbox-render
[own] [own]

View file

@ -25,7 +25,6 @@
[uxbox.main.ui.icons :as i] [uxbox.main.ui.icons :as i]
[uxbox.common.ui.mixins :as mx] [uxbox.common.ui.mixins :as mx]
[uxbox.main.ui.lightbox :as lbx] [uxbox.main.ui.lightbox :as lbx]
[uxbox.util.lens :as ul]
[uxbox.util.data :refer (read-string parse-int)] [uxbox.util.data :refer (read-string parse-int)]
[uxbox.util.dom :as dom])) [uxbox.util.dom :as dom]))
@ -35,8 +34,8 @@
(letfn [(getter [state] (letfn [(getter [state]
(let [project (get-in state [:workspace :project])] (let [project (get-in state [:workspace :project])]
(stpr/project-pages state project)))] (stpr/project-pages state project)))]
(as-> (ul/getter getter) $ (as-> (l/lens getter) $
(l/focus-atom $ st/state)))) (l/derive $ st/state))))
;; --- Component ;; --- Component

View file

@ -6,13 +6,9 @@
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com> ;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
(ns uxbox.util.lens (ns uxbox.util.lens
(:refer-clojure :exclude [derive merge]) (:refer-clojure :exclude [merge])
(:require [lentes.core :as l])) (:require [lentes.core :as l]))
(defn getter
[f]
(l/lens f #(throw (ex-info "Not implemented" {}))))
(defn merge (defn merge
[data] [data]
(l/lens (l/lens

View file

@ -18,7 +18,7 @@
(def auth-l (def auth-l
(-> (l/key :auth) (-> (l/key :auth)
(l/focus-atom state))) (l/derive state)))
(defn initial-state (defn initial-state
[] []