Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/elm/Cambiatus/Enum/Permission.elm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Json.Decode as Decode exposing (Decoder)

{-| Permissions a role can have

- Admin - Role permission that grants full administrative access to the community
- Award - Role permission that allows to award rewards on community actions
- Claim - Role permission that allows to claim actions
- Invite - Role permission that allows to create invitations to the community
Expand All @@ -19,7 +20,8 @@ import Json.Decode as Decode exposing (Decoder)

-}
type Permission
= Award
= Admin
| Award
| Claim
| Invite
| Order
Expand All @@ -30,7 +32,7 @@ type Permission

list : List Permission
list =
[ Award, Claim, Invite, Order, Sell, Transfer, Verify ]
[ Admin, Award, Claim, Invite, Order, Sell, Transfer, Verify ]


decoder : Decoder Permission
Expand All @@ -39,6 +41,9 @@ decoder =
|> Decode.andThen
(\string ->
case string of
"ADMIN" ->
Decode.succeed Admin

"AWARD" ->
Decode.succeed Award

Expand Down Expand Up @@ -70,6 +75,9 @@ decoder =
toString : Permission -> String
toString enum =
case enum of
Admin ->
"ADMIN"

Award ->
"AWARD"

Expand Down Expand Up @@ -106,6 +114,9 @@ This can be useful for generating Strings to use for <select> menus to check whi
fromString : String -> Maybe Permission
fromString enumString =
case enumString of
"ADMIN" ->
Just Admin

"AWARD" ->
Just Award

Expand Down
Loading