|
| 1 | +(ns planwise.client.projects2.components.create |
| 2 | + (:require [re-frame.core :refer [subscribe dispatch] :as rf] |
| 3 | + [planwise.client.asdf :as asdf] |
| 4 | + [reagent.core :as r] |
| 5 | + [re-com.core :as rc] |
| 6 | + [planwise.client.components.common2 :as common2] |
| 7 | + [planwise.client.routes :as routes] |
| 8 | + [planwise.client.utils :as utils] |
| 9 | + [planwise.client.ui.common :as ui] |
| 10 | + [planwise.client.ui.rmwc :as m] |
| 11 | + [planwise.client.mapping :refer [static-image fullmap-region-geo]] |
| 12 | + [planwise.client.components.common :as common])) |
| 13 | +(def project-templates |
| 14 | + [{:description "Plan facilities based on ground access" |
| 15 | + :icon "directions_walk" |
| 16 | + :key "plan" |
| 17 | + :defaults {:name "ground"}} |
| 18 | + {:description "Plan diagonostic devices & sample referrals" |
| 19 | + :icon "call_split" |
| 20 | + :key "diagnosis" |
| 21 | + :defaults {:name "sample"}}]) |
| 22 | + |
| 23 | +(defn project-section-template-selector |
| 24 | + [] |
| 25 | + [ui/fixed-width (common2/nav-params) |
| 26 | + (let [templates (subscribe [:projects2/templates]) |
| 27 | + scratch-template (first (filter #(not (contains? % :description)) @templates)) |
| 28 | + sample-templates (filter #(contains? % :description) @templates)] |
| 29 | + (dispatch [:projects2/get-templates-list]) |
| 30 | + [:div.template-container |
| 31 | + (if (some? sample-templates) |
| 32 | + [:h2 "Start from a template"]) |
| 33 | + (if (some? sample-templates) |
| 34 | + [:div.row |
| 35 | + (map (fn [template] |
| 36 | + [:a.action {:key (:key template) :onClick #(dispatch [:projects2/new-project (:defaults template)])} |
| 37 | + [m/Icon {} (:icon template)] |
| 38 | + [:div (:description template)]]) |
| 39 | + sample-templates)]) |
| 40 | + [:hr] |
| 41 | + [:h2 "Start from scratch"] |
| 42 | + [:div.row |
| 43 | + [:a.action {:onClick #(dispatch [:projects2/new-project (:defaults scratch-template)])} |
| 44 | + [m/Icon {} "folder_open"] |
| 45 | + [:div "Follow a wizard through all available settings"]]]])]) |
0 commit comments