forked from filipg/gonito
Add colors for tags
(Without any visualization for the time being.)
This commit is contained in:
parent
601733eba9
commit
575ec8d4e4
@ -1426,6 +1426,7 @@ convertTagInfoToView tagInfo =
|
|||||||
TagView {
|
TagView {
|
||||||
tagViewName = tagName $ entityVal $ fst tagInfo,
|
tagViewName = tagName $ entityVal $ fst tagInfo,
|
||||||
tagViewDescription = tagDescription $ entityVal $ fst tagInfo,
|
tagViewDescription = tagDescription $ entityVal $ fst tagInfo,
|
||||||
|
tagViewColor = tagColor $ entityVal $ fst tagInfo,
|
||||||
tagViewAccepted = submissionTagAccepted $ entityVal $ snd tagInfo
|
tagViewAccepted = submissionTagAccepted $ entityVal $ snd tagInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1526,12 +1527,14 @@ instance ToSchema EvaluationView where
|
|||||||
data TagView = TagView {
|
data TagView = TagView {
|
||||||
tagViewName :: Text,
|
tagViewName :: Text,
|
||||||
tagViewDescription :: Maybe Text,
|
tagViewDescription :: Maybe Text,
|
||||||
|
tagViewColor :: Maybe Text,
|
||||||
tagViewAccepted :: Maybe Bool }
|
tagViewAccepted :: Maybe Bool }
|
||||||
|
|
||||||
instance ToJSON TagView where
|
instance ToJSON TagView where
|
||||||
toJSON t = object
|
toJSON t = object
|
||||||
[ "name" .= tagViewName t
|
[ "name" .= tagViewName t
|
||||||
, "description" .= tagViewDescription t
|
, "description" .= tagViewDescription t
|
||||||
|
, "color" .= tagViewColor t
|
||||||
, "accepted" .= tagViewAccepted t
|
, "accepted" .= tagViewAccepted t
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1544,9 +1547,10 @@ instance ToSchema TagView where
|
|||||||
& properties .~
|
& properties .~
|
||||||
fromList [ ("name", stringSchema)
|
fromList [ ("name", stringSchema)
|
||||||
, ("description", stringSchema)
|
, ("description", stringSchema)
|
||||||
|
, ("color", stringSchema)
|
||||||
, ("accepted", boolSchema)
|
, ("accepted", boolSchema)
|
||||||
]
|
]
|
||||||
& required .~ [ "name", "description" ]
|
& required .~ [ "name", "color", "description" ]
|
||||||
|
|
||||||
|
|
||||||
data SubmissionView = SubmissionView {
|
data SubmissionView = SubmissionView {
|
||||||
|
@ -20,6 +20,7 @@ instance ToJSON (Entity Tag) where
|
|||||||
toJSON v = object
|
toJSON v = object
|
||||||
[ "name" .= (tagName $ entityVal v)
|
[ "name" .= (tagName $ entityVal v)
|
||||||
, "description" .= (tagDescription $ entityVal v)
|
, "description" .= (tagDescription $ entityVal v)
|
||||||
|
, "color" .= (tagColor $ entityVal v)
|
||||||
, "id" .= (entityKey v)
|
, "id" .= (entityKey v)
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -32,9 +33,10 @@ instance ToSchema (Entity Tag) where
|
|||||||
& properties .~
|
& properties .~
|
||||||
fromList [ ("name", stringSchema)
|
fromList [ ("name", stringSchema)
|
||||||
, ("description", stringSchema)
|
, ("description", stringSchema)
|
||||||
|
, ("color", stringSchema)
|
||||||
, ("id", intSchema)
|
, ("id", intSchema)
|
||||||
]
|
]
|
||||||
& required .~ [ "name", "description", "id" ]
|
& required .~ [ "name", "description", "color", "id" ]
|
||||||
|
|
||||||
listTagsApi :: Swagger
|
listTagsApi :: Swagger
|
||||||
listTagsApi = spec & definitions .~ defs
|
listTagsApi = spec & definitions .~ defs
|
||||||
@ -70,8 +72,8 @@ postTagsR = do
|
|||||||
canTagsBeAdded <- canAddTags
|
canTagsBeAdded <- canAddTags
|
||||||
when canTagsBeAdded $ do
|
when canTagsBeAdded $ do
|
||||||
case result of
|
case result of
|
||||||
FormSuccess (t, d) -> do
|
FormSuccess (t, d, c) -> do
|
||||||
_ <- runDB $ insert $ Tag t d
|
_ <- runDB $ insert $ Tag t d c
|
||||||
return ()
|
return ()
|
||||||
_ -> do
|
_ -> do
|
||||||
return ()
|
return ()
|
||||||
@ -107,12 +109,13 @@ tagsTable :: Table.Table App (Entity Tag)
|
|||||||
tagsTable = mempty
|
tagsTable = mempty
|
||||||
++ Table.text "tag" (\(Entity _ tag) -> tagName tag)
|
++ Table.text "tag" (\(Entity _ tag) -> tagName tag)
|
||||||
++ Table.text "description" (\(Entity _ tag) -> (fromMaybe (""::Text) (tagDescription tag)))
|
++ Table.text "description" (\(Entity _ tag) -> (fromMaybe (""::Text) (tagDescription tag)))
|
||||||
|
++ Table.text "color" (\(Entity _ tag) -> (fromMaybe (""::Text) (tagColor tag)))
|
||||||
|
|
||||||
|
tagForm :: Form (Text, Maybe Text, Maybe Text)
|
||||||
tagForm :: Form (Text, Maybe Text)
|
tagForm = renderBootstrap3 BootstrapBasicForm $ (,,)
|
||||||
tagForm = renderBootstrap3 BootstrapBasicForm $ (,)
|
|
||||||
<$> areq textField (bfs MsgTagName) Nothing
|
<$> areq textField (bfs MsgTagName) Nothing
|
||||||
<*> aopt textField (bfs MsgTagDescription) Nothing
|
<*> aopt textField (bfs MsgTagDescription) Nothing
|
||||||
|
<*> aopt textField (bfs MsgColor) Nothing
|
||||||
|
|
||||||
getToggleSubmissionTagR :: SubmissionTagId -> Handler RepPlain
|
getToggleSubmissionTagR :: SubmissionTagId -> Handler RepPlain
|
||||||
getToggleSubmissionTagR submissionTagId = do
|
getToggleSubmissionTagR submissionTagId = do
|
||||||
|
@ -164,6 +164,7 @@ Out
|
|||||||
Tag
|
Tag
|
||||||
name Text
|
name Text
|
||||||
description Text Maybe
|
description Text Maybe
|
||||||
|
color Text Maybe
|
||||||
UniqueTagName name
|
UniqueTagName name
|
||||||
SubmissionTag
|
SubmissionTag
|
||||||
submission SubmissionId
|
submission SubmissionId
|
||||||
|
@ -107,3 +107,4 @@ InviteToTeam: Invite to team (give the identifier/login of a user)
|
|||||||
Join: Join
|
Join: Join
|
||||||
NoTests: SOMETHING IS WRONG WITH THE CHALLENGE, THERE ARE NO TESTS DEFINED. MAYBE TEST DIRECTORY ARE MISSING OR THE CHALLENGE WAS CREATED/UPDATE IN THE INVALID MANNER
|
NoTests: SOMETHING IS WRONG WITH THE CHALLENGE, THERE ARE NO TESTS DEFINED. MAYBE TEST DIRECTORY ARE MISSING OR THE CHALLENGE WAS CREATED/UPDATE IN THE INVALID MANNER
|
||||||
TestAnnouncements: test announcements
|
TestAnnouncements: test announcements
|
||||||
|
Color: color name or hex value
|
||||||
|
Loading…
Reference in New Issue
Block a user