-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete organisation #15
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b730b09
Add db function to delete organisation
prabhanshuguptagit 1fd71c6
Add delete org model function
prabhanshuguptagit a708212
Add handler to delete organisation
prabhanshuguptagit 7cfa606
Create delete organisation route
prabhanshuguptagit 0f5f1e3
Add delete org button to dashboard
prabhanshuguptagit 2392f4e
Show error/success message on delete
prabhanshuguptagit b571384
Add is-owner? helper
prabhanshuguptagit 917f1d6
Pass transaction to db functions
prabhanshuguptagit e33a249
Fix delete-org on-error handler
prabhanshuguptagit 77a5140
Use find-by-keys in get-permission
prabhanshuguptagit a228ed3
Return 500 if org delete fails
prabhanshuguptagit 98f9abc
Rename show-alert-bottom
prabhanshuguptagit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,45 @@ | ||
(ns villagebookUI.components.main-content | ||
(:require [villagebookUI.store.organisations :as org-store])) | ||
(:require [villagebookUI.store.organisations :as org-store] | ||
[villagebookUI.api.organisation :as org-api] | ||
[villagebookUI.fetchers :as fetchers] | ||
[villagebookUI.components.utils :as utils] | ||
[villagebookUI.store.ui :as ui-store] | ||
[villagebookUI.helpers :as helpers])) | ||
|
||
(declare navbar content-box delete-org-btn delete-org) | ||
|
||
(defn main-content [] | ||
[:div.main-content | ||
[:div.navbar | ||
[:h5 (:name (org-store/get-selected))]]]) | ||
(let [org (org-store/get-selected)] | ||
[:div.main-content | ||
[navbar org] | ||
(if org | ||
[content-box] | ||
[:h5 "Oops, page not found"]) | ||
[utils/alert-bottom (ui-store/get-el-state :alert-bottom)]])) | ||
|
||
(defn- navbar | ||
[org] | ||
[:div.navbar | ||
[:h5 (:name org)] | ||
[delete-org-btn org]]) | ||
|
||
(defn content-box [] | ||
[:div]) | ||
|
||
(defn delete-org-btn | ||
[org] | ||
(if (= (:permission org) "owner") | ||
[:a {:href "#" | ||
:style {:height "30px"} | ||
:on-click #(delete-org org)} | ||
"Delete organisation"])) | ||
|
||
(defn delete-org | ||
[org] | ||
(if (js/confirm (str "Are you sure you want to delete " (:name org) "?")) | ||
(org-api/delete (:id org) | ||
(fn [res] | ||
(helpers/show-alert-bottom! :success res) | ||
(fetchers/fetch-orgs! first)) | ||
(fn [res] | ||
(helpers/show-alert-bottom! :error res))))) |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
(ns villagebookUI.store.core | ||
(:require [villagebookUI.store.user :as user-store] | ||
[villagebookUI.store.session :as session] | ||
[villagebookUI.store.organisations :as org-store])) | ||
[villagebookUI.store.organisations :as org-store] | ||
[villagebookUI.store.ui :as ui])) | ||
|
||
(defn init! [] | ||
(session/init!) | ||
(ui/init!) | ||
(user-store/init!) | ||
(org-store/init!)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
(ns villagebookUI.store.ui | ||
(:require [reagent.core :as r] | ||
[villagebookUI.store.state :refer [state]])) | ||
|
||
(def ui-state | ||
(r/cursor state [:ui])) | ||
|
||
(defn get-el-state [element-key] | ||
(get @ui-state element-key)) | ||
|
||
(defn set! [element-key val] | ||
(swap! ui-state assoc element-key val)) | ||
|
||
(defn init! [] | ||
(reset! ui-state {})) |
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
number?
seems like the wrong check here. are you checking for presence?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking if time is a number and is not nil.