Created
June 22, 2015 12:47
-
-
Save mprokopov/d283a060c40252dc247b to your computer and use it in GitHub Desktop.
One-liner for fetching nested item from hash-map by link value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def sidebar-items [{ :name "Dashboard" :color "red" :icon "dashboard" :link "/dashboard" } | |
{ :name "Обращения" :color "blue" :icon "comments-2" :link "/ticket" } | |
{ :submenu [ | |
{ :name "Инциденты" :icon "bug" :link "/incidents" } | |
{ :name "Запросы на обслуж" :icon "basket" :link "/requests" } | |
{ :name "Запросы на изм" :icon "cog" :link "/rfcs" } | |
{ :name "Фидбеки" :icon "comments" :link "/feedbacks" }]} | |
{ :name "Изменения" :icon "cog" :link "/changes" } | |
{ :name "Проблемы" :icon "shit" :color "green" :link "/problems" } | |
{ :name "Знания" :icon "book" :link "/knowledges" } | |
{ :name "Клиенты" :icon "address-book" } | |
{ :name "Управление SLA" :color "red" :icon "cog" | |
:submenu [ | |
{ :name "Сервисы" :icon "cog" :link "/services"}] | |
} | |
{ :name "Агенты" :icon "user-3" :color "pink" } | |
{ :name "Отчеты" :color "indigo" }]) | |
(defn sidebar-item [link] | |
"Selects item by link even nested in :submenu clause" | |
(filter #(= (% :link) link) (mapcat #(tree-seq :submenu :submenu %) sidebar-items))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment