-
-
Save robert-stuttaford/e7ef1e151c157f4a4d24 to your computer and use it in GitHub Desktop.
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
Uncaught RangeError: Maximum call stack size exceeded | |
@ cljs.core.TransientArrayMap.cljs$core$ILookup$_lookup$arity$3 | |
@ core.cljs:6025cljs.core.get.cljs$core$IFn$_invoke$arity$3 | |
@ core.cljs:1728(anonymous function) | |
@ core.cljs:9424(anonymous function) | |
@ core.cljs:4869(anonymous function) | |
@ core.cljs:4869cljs.core.PersistentVector.cljs$core$IReduce$_reduce$arity$3 | |
@ core.cljs:4873cljs.core.reduce.cljs$core$IFn$_invoke$arity$3 | |
@ core.cljs:2197cljs$core$group_by | |
@ core.cljs:9421om.next.db__GT_tree.cljs$core$IFn$_invoke$arity$4 | |
@ next.cljs:1130om$next$db__GT_tree | |
@ next.cljs:1110XMLHttpRequest.send (async)goog.net.XhrIo.send | |
@ xhrio.js:622goog.net.XhrIo.send | |
@ xhrio.js:351michelangelo.client.util.transit_post | |
@ util.cljs:7om.next.Reconciler.om$next$protocols$IReconciler$add_root_BANG_$arity$4 | |
@ next.cljs:1308om$next$protocols$add_root_BANG_ | |
@ protocols.cljs:13om.next.add_root_BANG_.cljs$core$IFn$_invoke$arity$4 | |
@ next.cljs:700om$next$add_root_BANG_ | |
@ next.cljs:687om.next.add_root_BANG_.cljs$core$IFn$_invoke$arity$3 | |
@ next.cljs:694om$next$add_root_BANG_ | |
@ next.cljs:687(anonymous function) | |
@ client.cljs:69 |
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
{:value | |
[{:title "Rethink High School Suites", | |
:slug "rethink-high-school-suites", | |
:status :active, | |
:type :collection, | |
:children | |
[{:title "Rethink Grade 10", | |
:slug "rethink-grade-10", | |
:status :active, | |
:type :suite, | |
:children | |
[{:title "CAPS - Mathematics Grade 10", | |
:slug "caps-maths-grade-10", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 0} | |
{:title "CAPS - Physics and Chemistry Grade 10", | |
:slug "caps-science-grade-10", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 1}], | |
:order 0} | |
{:title "Rethink Grade 11", | |
:slug "rethink-grade-11", | |
:status :active, | |
:type :suite, | |
:children | |
[{:title "CAPS - Chemistry Grade 11", | |
:slug "caps-chemistry-grade-11", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 0} | |
{:title "CAPS - Mathematics Grade 11", | |
:slug "caps-maths-grade-11", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 1} | |
{:title "CAPS - Physics Grade 11", | |
:slug "caps-physics-grade-11", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 2}], | |
:order 1} | |
{:title "Rethink Grade 12", | |
:slug "rethink-grade-12", | |
:status :active, | |
:type :suite, | |
:children | |
[{:title "CAPS - Chemistry Grade 12", | |
:slug "caps-chemistry-grade-12", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 0} | |
{:title "CAPS - Mathematics Grade 12", | |
:slug "caps-maths-grade-12", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 1} | |
{:title "CAPS - Physics Grade 12", | |
:slug "caps-physics-grade-12", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 2}], | |
:order 2} | |
{:title "Rethink Grade 8 and 9", | |
:slug "rethink-grade-8-and-9", | |
:status :active, | |
:type :suite, | |
:children | |
[{:title "CAPS - Mathematics Grade 8 and 9", | |
:slug "caps-maths-grade-8-and-9", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 0} | |
{:title "CAPS - Natural Science Grade 8 and 9", | |
:slug "caps-natural-science-grade-8-and-9", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 1}], | |
:order 3}], | |
:order 0} | |
{:title "Loose suites", | |
:slug "loose-suites", | |
:children | |
({:title "CCI Skills Development", | |
:slug "cci-skills-development", | |
:status :active, | |
:type :suite, | |
:children | |
[{:title "CCI Products Strategy", | |
:slug "cci-products-strategy", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 0} | |
{:title "Era 3 Sales", | |
:slug "cci-era-3-sales", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 1} | |
{:title "HBR Workshops", | |
:slug "cci-hbr-workshops", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 2} | |
{:title "Skills Development: People Management", | |
:slug "cci-skills-people-management", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 3} | |
{:title "Skills Development: Relationship Management", | |
:slug "cci-skills-relationship-management", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 4} | |
{:title "Skills Development: Self-management", | |
:slug "cci-skills-self-management", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 5} | |
{:title "Skills Development: Task Management", | |
:slug "cci-skills-task-management", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 6} | |
{:title "The CCI Values", | |
:slug "cci-organisational-values", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 7} | |
{:title "Value Chain Academy", | |
:slug "tracc-value-chain-academy", | |
:status :draft, | |
:type :bundle, | |
:children [], | |
:order 8}], | |
:order 0}), | |
:loose? true, | |
:type :collection, | |
:order 1}]} |
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
;; output of @reconciler in cljs repl | |
{:builder/content-list | |
[[:content-item/by-slug "rethink-high-school-suites"] | |
[:content-item/by-slug "loose-suites"]], | |
:content-item/by-slug | |
{"caps-science-grade-10" | |
{:title "CAPS - Physics and Chemistry Grade 10", | |
:slug "caps-science-grade-10", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 1}, | |
"caps-chemistry-grade-12" | |
{:title "CAPS - Chemistry Grade 12", | |
:slug "caps-chemistry-grade-12", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 0}, | |
"caps-natural-science-grade-8-and-9" | |
{:title "CAPS - Natural Science Grade 8 and 9", | |
:slug "caps-natural-science-grade-8-and-9", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 1}, | |
"caps-chemistry-grade-11" | |
{:title "CAPS - Chemistry Grade 11", | |
:slug "caps-chemistry-grade-11", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 0}, | |
"rethink-grade-10" | |
{:title "Rethink Grade 10", | |
:slug "rethink-grade-10", | |
:status :active, | |
:type :suite, | |
:children | |
[[:content-item/by-slug "caps-maths-grade-10"] | |
[:content-item/by-slug "caps-science-grade-10"]], | |
:order 0}, | |
"caps-maths-grade-12" | |
{:title "CAPS - Mathematics Grade 12", | |
:slug "caps-maths-grade-12", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 1}, | |
"rethink-high-school-suites" | |
{:title "Rethink High School Suites", | |
:slug "rethink-high-school-suites", | |
:status :active, | |
:type :collection, | |
:children | |
[[:content-item/by-slug "rethink-grade-10"] | |
[:content-item/by-slug "rethink-grade-11"] | |
[:content-item/by-slug "rethink-grade-12"] | |
[:content-item/by-slug "rethink-grade-8-and-9"]], | |
:order 0}, | |
"caps-physics-grade-11" | |
{:title "CAPS - Physics Grade 11", | |
:slug "caps-physics-grade-11", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 2}, | |
"caps-maths-grade-11" | |
{:title "CAPS - Mathematics Grade 11", | |
:slug "caps-maths-grade-11", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 1}, | |
"rethink-grade-11" | |
{:title "Rethink Grade 11", | |
:slug "rethink-grade-11", | |
:status :active, | |
:type :suite, | |
:children | |
[[:content-item/by-slug "caps-chemistry-grade-11"] | |
[:content-item/by-slug "caps-maths-grade-11"] | |
[:content-item/by-slug "caps-physics-grade-11"]], | |
:order 1}, | |
"loose-suites" | |
{:title "Loose suites", | |
:slug "loose-suites", | |
:children | |
({:title "CCI Skills Development", | |
:slug "cci-skills-development", | |
:status :active, | |
:type :suite, | |
:children | |
[{:title "CCI Products Strategy", | |
:slug "cci-products-strategy", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 0} | |
{:title "Era 3 Sales", | |
:slug "cci-era-3-sales", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 1} | |
{:title "HBR Workshops", | |
:slug "cci-hbr-workshops", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 2} | |
{:title "Skills Development: People Management", | |
:slug "cci-skills-people-management", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 3} | |
{:title "Skills Development: Relationship Management", | |
:slug "cci-skills-relationship-management", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 4} | |
{:title "Skills Development: Self-management", | |
:slug "cci-skills-self-management", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 5} | |
{:title "Skills Development: Task Management", | |
:slug "cci-skills-task-management", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 6} | |
{:title "The CCI Values", | |
:slug "cci-organisational-values", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 7} | |
{:title "Value Chain Academy", | |
:slug "tracc-value-chain-academy", | |
:status :draft, | |
:type :bundle, | |
:children [], | |
:order 8}], | |
:order 0}), | |
:loose? true, | |
:type :collection, | |
:order 1}, | |
"rethink-grade-12" | |
{:title "Rethink Grade 12", | |
:slug "rethink-grade-12", | |
:status :active, | |
:type :suite, | |
:children | |
[[:content-item/by-slug "caps-chemistry-grade-12"] | |
[:content-item/by-slug "caps-maths-grade-12"] | |
[:content-item/by-slug "caps-physics-grade-12"]], | |
:order 2}, | |
"caps-physics-grade-12" | |
{:title "CAPS - Physics Grade 12", | |
:slug "caps-physics-grade-12", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 2}, | |
"caps-maths-grade-10" | |
{:title "CAPS - Mathematics Grade 10", | |
:slug "caps-maths-grade-10", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 0}, | |
"caps-maths-grade-8-and-9" | |
{:title "CAPS - Mathematics Grade 8 and 9", | |
:slug "caps-maths-grade-8-and-9", | |
:status :active, | |
:type :bundle, | |
:children [], | |
:order 0}, | |
"rethink-grade-8-and-9" | |
{:title "Rethink Grade 8 and 9", | |
:slug "rethink-grade-8-and-9", | |
:status :active, | |
:type :suite, | |
:children | |
[[:content-item/by-slug "caps-maths-grade-8-and-9"] | |
[:content-item/by-slug "caps-natural-science-grade-8-and-9"]], | |
:order 3}}, | |
:om.next/tables #{:content-item/by-slug}} |
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
(ns michelangelo.client.parser | |
(:require [om.next :as om])) | |
;;; parsing | |
(defmulti mutate om/dispatch) | |
(defmethod mutate 'content-item/expand | |
[{:keys [state]} _ {:keys [slug]}] | |
{:action | |
(fn [] | |
(swap! state update-in | |
[:content-item/by-slug slug :expanded?] (constantly true)))}) | |
(defmethod mutate 'content-item/contract | |
[{:keys [state]} _ {:keys [slug]}] | |
{:action | |
(fn [] | |
(swap! state update-in | |
[:content-item/by-slug slug :expanded?] (constantly false)))}) | |
(defmulti read (fn [env k params] | |
(prn "READ" k) | |
k)) | |
(defmethod read :builder/content-list [{:keys [state query] :as env} _ _] | |
(let [st @state] | |
(if-let [v (get st :builder/content-list)] | |
{:value (om/db->tree query v st) :remote true} | |
{:remote true}))) |
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
(ns michelangelo.client | |
(:require [devtools.core :as devtools] | |
[goog.dom :as gdom] | |
[om.next :as om :refer-macros [defui]] | |
[michelangelo.client.parser :as parser] | |
[michelangelo.client.util :as util] | |
[sablono.core :as html :refer-macros [html]])) | |
(enable-console-print!) | |
;;(devtools/set-pref! :install-sanity-hints true) | |
;;(devtools/install!) | |
(declare content-item) | |
(defui ContentItem | |
static om/Ident | |
(ident [this {:keys [slug]}] | |
[:content-item/by-slug slug]) | |
static om/IQuery | |
(query [this] | |
[:title :slug :status :type {:children '...}]) | |
Object | |
(render [this] | |
(let [{:keys [title slug status type children expanded?] :as props} (om/props this)] | |
(html | |
[:div | |
[:pre (pr-str props)] | |
[:li title " [" (if expanded? "expanded" "contracted") "]" | |
(when children | |
[:ul.ui.list | |
(cond (= :to-load children) | |
[:li [:a {:on-click | |
#(om/transact! this | |
(if expanded? | |
`[(content-item/contract ~props)] | |
`[(content-item/expand ~props)])) | |
:href "javascript:"} | |
"Load more..."]] | |
(seq children) | |
(map content-item children))])]])))) | |
(def content-item (om/factory ContentItem {:key :slug})) | |
(defui Root | |
static om/IQuery | |
(query [this] | |
[{:builder/content-list (om/get-query ContentItem)}]) | |
Object | |
(render [this] | |
(let [{:keys [builder/content-list]} (om/props this)] | |
(html | |
[:.ui.text.container {:style {:padding "2em 1em"}} | |
[:h1.ui.dividing.header "Michelangelo"] | |
[:ul.ui.list | |
(map content-item content-list)]])))) | |
(def reconciler | |
(om/reconciler | |
{:state {} | |
:normalize true | |
:merge-tree (fn [a b] (println "|merge" a b) (merge a b)) | |
:parser (om/parser {:read parser/read :mutate parser/mutate}) | |
:send (util/transit-post "/api")})) | |
(om/add-root! reconciler Root (gdom/getElement "app")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment