users can now edit vendors.

This commit is contained in:
2022-04-12 15:49:45 -07:00
parent 6ad5541124
commit f73b406abd
3 changed files with 162 additions and 84 deletions

View File

@@ -1,23 +1,21 @@
(ns auto-ap.views.components.layouts
(:require
[reagent.core :as reagent]
[re-frame.core :as re-frame]
[bidi.bidi :as bidi]
[auto-ap.events :as events]
[auto-ap.routes :as routes]
[auto-ap.subs :as subs]
[auto-ap.events :as events]
[auto-ap.views.utils :refer [active-when active-when= login-url dispatch-event appearing css-transition-group bind-field]]
[auto-ap.views.components.dropdown :refer [drop-down drop-down-contents]]
[auto-ap.views.components.modal :as modal]
[auto-ap.entities.vendors :as vendor]
[clojure.string :as str]
[reagent.core :as r]
[auto-ap.views.components.vendor-dialog :as vendor-dialog]
[auto-ap.views.components.buttons :as buttons]))
[auto-ap.views.utils
:refer [active-when appearing bind-field dispatch-event dispatch-event-with-propagation login-url]]
[bidi.bidi :as bidi]
[clojure.string :as str]
[re-frame.core :as re-frame]
[reagent.core :as r]))
(defn navbar-drop-down-contents [{:keys [id]} children ]
(let [toggle-fn (fn [] (re-frame/dispatch [::events/toggle-menu id]))]
(reagent/create-class {:component-did-mount (fn [] (.addEventListener js/document "click" toggle-fn))
(r/create-class {:component-did-mount (fn [] (.addEventListener js/document "click" toggle-fn))
:component-will-unmount (fn [] (.removeEventListener js/document "click" toggle-fn))
:reagent-render
(fn [children]
@@ -25,7 +23,7 @@
(defn navbar-drop-down [{:keys [ header id class]} child]
(let [menu-active? (re-frame/subscribe [::subs/menu-active? id])]
(reagent/create-class
(r/create-class
{:reagent-render (fn [{:keys [header id]} child]
(let [menu-active? @(re-frame/subscribe [::subs/menu-active? id])]
[:div { :class (str "navbar-item has-dropdown " (when menu-active? "is-active " ) " " class)}
@@ -134,9 +132,16 @@
(when-not is-initial-loading
[:div.navbar-end
[:div.navbar-item
[buttons/new-button {:event [::vendor-dialog/started {}]
:name "Vendor"
:class "is-primary"}]]
[drop-down {:header [:a.button.is-outlined {:aria-haspopup true
:type "button"
:on-click (dispatch-event-with-propagation [::events/toggle-menu ::vendor ])}
"Vendors "
[:span " "]
[:span.icon [:i.fa.fa-angle-down {:aria-hidden "true"}]]]
:id ::vendor}
[:<>
[:a.dropdown-item {:on-click (dispatch-event-with-propagation [::vendor-dialog/started {}])} "New"]
[:a.dropdown-item {:on-click (dispatch-event-with-propagation [::vendor-dialog/edit {}])} "Edit"]]]]
(when (> (count @clients) 1)