Commit d06c6fa1 authored by Mart Lubbers's avatar Mart Lubbers

Merge branch 'master' of gitlab.science.ru.nl:clean-and-itasks/iTasks-SDK into...

Merge branch 'master' of gitlab.science.ru.nl:clean-and-itasks/iTasks-SDK into 217-buttons-on-a-tabset-should-be-moved-to-the-actual-tabbar-header
parents 3bc85426 7d5cb944
Pipeline #12974 passed with stage
in 10 minutes and 37 seconds
......@@ -6,3 +6,5 @@
*.prp
*.exe
.sass-cache
BasicAPIExamples.icl
.ctest-results.json
test:
before_script:
- install_clean.sh bundle-complete && install_clean_nightly.sh test && apt-get update -qq && apt-get install -y -qq build-essential libsqlite3-dev libmariadbclient-dev-compat
image: "camilstaps/clean:nightly"
script:
- bash ci-tests.bash
......@@ -72,6 +72,18 @@ where
choices = ["string" +++ toString i\\i<-[0..20]]
```
## Panels
In some cases, such as when you apply a title, the user interface is automatically lifted to a panel.
However, this can also be done manually with the option of making the panel fullscreenable.
```clean
toPanel :: Bool -> Layout
:: InPanel = InPanel Bool
```
If the boolean flag is set to true, the panel includes a small icon (![](Libraries/iTasks/UI/WebPublic/css/icons/fullscreen.png)) on the bottom right that, when clicked, makes the panel full screen.
If the small icon is clicked again, the panel shrinks back to the original size again.
## Conclusion
In this guide we have shown how you how to decorate tasks with layout combinators so that you can change the way they appear in the client.
......
......@@ -33,7 +33,7 @@ import Incidone.OP.Concepts
}
:: ActionTasks
= E.c: ActionTasks
= E.c: ActionTasks
([ContactNo] [IncidentNo] -> Task (c,ActionStatus)) //Configuration task
(c (Shared ActionStatus) -> Task ()) & iTask c //An action item that needs to be configured before it can be deployed
......@@ -97,7 +97,7 @@ import Incidone.OP.Concepts
:: CommunicationMeanSuggestion
= CommunicateUsingPhone
| CommunicateUsingVHF
| CommunicateUsingP2000
| CommunicateUsingP2000
| CommunicateUsingEmail
:: UserActionListDefinition =
......
......@@ -166,7 +166,7 @@ contactOptions (Just group) = sdsFocus group contactsWithGroupShort
forIncident :: IncidentNo (ActionDefinition (ContactNo,IncidentNo)) -> ActionDefinition ContactNo
forIncident incidentNo item=:{ActionDefinition|task} = {ActionDefinition|item & task = task`}
where
task` contactNo status = task (contactNo,incidentNo) status
task` contactNo status = task (contactNo,incidentNo) status
addDefaultStatus :: (Task c) -> ([ContactNo] [IncidentNo] -> Task (c,ActionStatus)) | iTask c
addDefaultStatus task = \initContacts initIncidents -> task @ \c -> (c,{ActionStatus|defaultValue & contacts = initContacts, incidents = initIncidents})
......@@ -228,7 +228,7 @@ gEq{|ActionTasks|} x y = True
gDefault{|ActionTasks|} = ActionTasks (\_ _ -> return ((),defaultValue)) (\_ _ -> return ())
gText{|ActionTasks|} _ _ = ["Action item task definition"]
gEditor{|ActionTasks|} = emptyEditor
gEditor{|ActionTasks|} = emptyEditor
instance toString ActionProgress
where
......@@ -280,7 +280,7 @@ predefinedTodoItem :: String ItemMeta -> CatalogAction
predefinedTodoItem identity meta=:{ItemMeta|title,description}
= {CatalogAction|identity=identity,meta=meta,tasks=ActionTasks configer todoItemTask}
where
configer initContacts initIncidents
configer initContacts initIncidents
= return ((),{ActionStatus|title=title,description=description,progress=ActionActive,contacts=initContacts,incidents=initIncidents})
userTodoItem :: String ItemMeta -> CatalogAction
......@@ -293,14 +293,14 @@ alertItemTask contactNo status = communicationItemTask contactNo status
configureAlertItemTask :: [ContactNo] [IncidentNo] -> Task ((ContactNo, Maybe P2000Message),ActionStatus)
configureAlertItemTask initContacts initIncidents = configureCommunicationItemTask "Alert" initContacts initIncidents
configureUserAlertItemTask :: ItemMeta CommunicationActionDefinition [ContactNo] [IncidentNo] -> Task ((ContactNo,Maybe P2000Message),ActionStatus)
configureUserAlertItemTask :: ItemMeta CommunicationActionDefinition [ContactNo] [IncidentNo] -> Task ((ContactNo,Maybe P2000Message),ActionStatus)
configureUserAlertItemTask meta def initContacts initIncidents = configureUserCommunicationItemTask "Alert" meta def initContacts initIncidents
blankAlertItem :: CatalogAction
blankAlertItem = {CatalogAction|identity="blank-alert",meta={ItemMeta|title="Alert item",description=Nothing},tasks=ActionTasks configureAlertItemTask alertItemTask}
predefinedAlertItem :: String ItemMeta (ContactNo,Maybe P2000Message) -> CatalogAction
predefinedAlertItem identity meta=:{ItemMeta|title,description} config
predefinedAlertItem :: String ItemMeta (ContactNo,Maybe P2000Message) -> CatalogAction
predefinedAlertItem identity meta=:{ItemMeta|title,description} config
= {CatalogAction|identity=identity,meta=meta,tasks=ActionTasks configer alertItemTask}
where
configer initContacts initIncidents
......@@ -312,19 +312,19 @@ userAlertItem identity meta def
//Inform items
informItemTask :: (ContactNo,Maybe P2000Message) (Shared ActionStatus) -> Task ()
informItemTask contactNo status = communicationItemTask contactNo status
informItemTask contactNo status = communicationItemTask contactNo status
configureInformItemTask :: [ContactNo] [IncidentNo] -> Task ((ContactNo,Maybe P2000Message),ActionStatus)
configureInformItemTask initContacts initIncidents = configureCommunicationItemTask "Inform" initContacts initIncidents
configureInformItemTask initContacts initIncidents = configureCommunicationItemTask "Inform" initContacts initIncidents
configureUserInformItemTask :: ItemMeta CommunicationActionDefinition [ContactNo] [IncidentNo] -> Task ((ContactNo,Maybe P2000Message),ActionStatus)
configureUserInformItemTask :: ItemMeta CommunicationActionDefinition [ContactNo] [IncidentNo] -> Task ((ContactNo,Maybe P2000Message),ActionStatus)
configureUserInformItemTask meta def initContacts initIncidents = configureUserCommunicationItemTask "Inform" meta def initContacts initIncidents
blankInformItem :: CatalogAction
blankInformItem = {CatalogAction|identity="blank-inform",meta={ItemMeta|title="Inform item",description=Nothing}
,tasks=ActionTasks configureInformItemTask informItemTask}
predefinedInformItem :: String ItemMeta (ContactNo,Maybe P2000Message) -> CatalogAction
predefinedInformItem :: String ItemMeta (ContactNo,Maybe P2000Message) -> CatalogAction
predefinedInformItem identity meta=:{ItemMeta|title,description} config
= {CatalogAction|identity=identity,meta=meta,tasks=ActionTasks configer informItemTask}
where
......@@ -335,7 +335,7 @@ userInformItem :: String ItemMeta CommunicationActionDefinition -> CatalogAction
userInformItem identity meta def
= {CatalogAction|identity=identity,meta=meta,tasks=ActionTasks (configureUserInformItemTask meta def) informItemTask}
//List items
//List items
listItemTask :: (String,ActionPlan) (Shared ActionStatus) -> Task ()
listItemTask (title,plan) status
= upd (\s -> {ActionStatus|s & title = title}) status
......@@ -351,7 +351,7 @@ where
where
configureDelayed configer task list
= configer initContacts initIncidents
>>= \(config,status) ->
>>= \(config,status) ->
set status (selfActionStatus list)
>>| task config (selfActionStatus list)
initStatus {ItemMeta|title,description}
......@@ -361,11 +361,11 @@ where
/*
= [(Detached (initAttributes identity (initStatus [] [])) True, \list -> task (selfActionStatus list)) //TODO: Maybe inherit contact+incident from parent
\\ item=:{CatalogAction|identity,task=ConfigurableAction configer task} <- init]
*/
*/
configureListItemTask :: [ContactNo] [IncidentNo] -> Task ((String,ActionPlan),ActionStatus)
configureListItemTask initContacts initIncidents
= enterActionStatus initContacts initIncidents
= enterActionStatus initContacts initIncidents
@ \s -> ((s.ActionStatus.title, {ActionPlan|immediateActions=return [],suggestedActions=return []}),s)
blankListItem :: CatalogAction
......@@ -375,7 +375,7 @@ predefinedListItem :: String ItemMeta ActionPlan -> CatalogAction
predefinedListItem identity meta=:{ItemMeta|title,description} plan
= {CatalogAction|identity=identity,meta=meta,tasks=ActionTasks configer listItemTask}
where
configer initContacts initIncidents
configer initContacts initIncidents
= updateInitialActionStatus meta initContacts initIncidents
@ \s -> ((s.ActionStatus.title, plan),s)
......@@ -386,7 +386,7 @@ where
task c status = listItemTask (title,plan c) status
//TODO: Filter actions by their rules and watch data changes
userListItem :: String ItemMeta UserActionListDefinition -> CatalogAction
userListItem :: String ItemMeta UserActionListDefinition -> CatalogAction
userListItem identity meta=:{ItemMeta|title,description} {immediateActions,additionalActions}
= {CatalogAction|identity=identity,meta=meta,tasks=ActionTasks configer listItemTask}
where
......@@ -406,7 +406,7 @@ where
//These tasks are used both by alert and inform actions
configureCommunicationItemTask :: String [ContactNo] [IncidentNo] -> Task ((ContactNo,Maybe P2000Message),ActionStatus)
configureCommunicationItemTask type initContacts initIncidents
configureCommunicationItemTask type initContacts initIncidents
= (enterChoiceWithShared ("Select the contact to "+++ toLowerCase type) [] allContactsShort
-&&-
enterChoiceWithShared ("Select the incident to "+++toLowerCase type +++" about") [] openIncidentsShort
......@@ -416,28 +416,28 @@ configureCommunicationItemTask type initContacts initIncidents
,contacts=removeDup [contactIdentity c:initContacts]
,incidents=removeDup [incidentIdentity i:initIncidents]})
configureUserCommunicationItemTask :: String ItemMeta CommunicationActionDefinition [ContactNo] [IncidentNo] -> Task ((ContactNo,Maybe P2000Message),ActionStatus)
configureUserCommunicationItemTask type meta {CommunicationActionDefinition|contactReference=Just ref,p2000Template} initContacts initIncidents
= findReferencedContacts ref
>>- \contacts ->
configureUserCommunicationItemTask :: String ItemMeta CommunicationActionDefinition [ContactNo] [IncidentNo] -> Task ((ContactNo,Maybe P2000Message),ActionStatus)
configureUserCommunicationItemTask type meta {CommunicationActionDefinition|contactReference=Just ref,p2000Template} initContacts initIncidents
= findReferencedContacts ref
>>- \contacts ->
(enterChoiceAs ("Select the contact to " +++ toLowerCase type) [] contacts contactIdentity @ (\c -> (c,p2000Template)))
-&&-
updateInitialActionStatus meta initContacts initIncidents
configureUserCommunicationItemTask type _ _ initContacts initIncidents
configureUserCommunicationItemTask type _ _ initContacts initIncidents
= configureCommunicationItemTask type initContacts initIncidents
communicationItemTask :: (ContactNo,Maybe P2000Message) (Shared ActionStatus) -> Task ()
communicationItemTask (contactNo,mbP2000Template) status
//View action description
= viewSharedInformation () [ViewAs (\{ActionStatus|description} -> description)] status
= viewSharedInformation () [ViewAs (\{ActionStatus|description} -> description)] status
-&&- ((
//View contact communication means
(viewContactCommunicationMeans contactNo
>^* [OnAction ActionEdit (always (doOrClose (manageContactCommunicationMeans True contactNo) <<@ InWindow))]
)
//Manage list of communication attempts and initiate communications
-&&- attemptCommunication contactNo
-&&- attemptCommunication contactNo
) <<@ ArrangeWithSideBar 0 LeftSide 200 True) <<@ ArrangeWithSideBar 0 TopSide 50 True
@! ()
where
......@@ -464,7 +464,7 @@ where
addP2000Message status attempts
= createCommunication P2000Message Out (Just contactNo)
>>- \communicationNo ->
maybe (return ()) (initMessageFromTemplate communicationNo contactNo) mbP2000Template
maybe (return ()) (initMessageFromTemplate communicationNo contactNo) mbP2000Template
>>| doOrClose (composeP2000Message communicationNo) <<@ InWindow
>>- \mbCommunication -> case mbCommunication of
Nothing
......@@ -541,7 +541,7 @@ where
addActionToFolders a folders = [(match,if (match a) (add a folder) folder) \\ (match,folder) <- folders]
where
add item=:(i,(iNo,pNo,action)) folder
add item=:(i,(iNo,pNo,action)) folder
# (added,nodes) = inject item (choiceTreeChildren folder)
# nodes = if added nodes (nodes ++ [node i iNo action])
# type = case folder.ChoiceTree.type of
......@@ -689,7 +689,7 @@ manageCurrentSubActionItems status list
@! ()
where
//Filter the list for detached items
subTaskItems list = mapRead toActionStatusesTL (taskListMeta list)
subTaskItems list = mapRead toActionStatusesTL (taskListMeta list)
format {ActionStatus|title,progress}
= {ActionStatusShort|progress=formatProgress progress,title=title}
......@@ -785,7 +785,7 @@ where
removeCatalogItem item
= viewInformation (Title "Remove") [] ("Remove " <+++ item.UserCatalogAction.identity <+++ "?")
>>? \nx ->
>>? \nx ->
upd (\xs -> [x \\ x <- xs | x.UserCatalogAction.identity <> item.UserCatalogAction.identity]) userActionCatalog @! ()
exportCatalog
......@@ -810,7 +810,7 @@ where
) (\e -> viewInformation "Failed import action catalog" [] e @! ())
) <<@ Title "Import actions"
where
instructions = toString
instructions = toString
(PTag [] [Text "Please select a JSON export file to upload.",BrTag []
,Text "The file needs to be formatted like ",ATag [HrefAttr "/demo-content/actioncatalog.json",TargetAttr "_blank"] [Text "actioncatalog.json"]
])
......
implementation module Incidone.ContactPosition
import iTasks, iTasks.UI.Editor, iTasks.UI.Editor.Controls, iTasks.UI.Editor.Modifiers, iTasks.UI.Definition
import qualified Data.Map as DM
import Data.Functor, Data.List, Text
import Data.Functor, Data.List, Text
import qualified Text.Parsers.ZParsers.ParsersKernel as PK
import qualified Text.Parsers.ZParsers.ParsersDerived as PD
import qualified Control.Applicative as CA
......@@ -15,7 +15,7 @@ import Incidone.Util.TaskPatterns
derive JSONEncode ContactPosition
derive JSONDecode ContactPosition
gEditor{|ContactPosition|} = bijectEditorValue printPosition parsePosition textField
gEditor{|ContactPosition|} = bijectEditorValue printPosition parsePosition textField
gText{|ContactPosition|} _ val = [maybe "" printPosition val]
derive gDefault ContactPosition
......
......@@ -7,7 +7,7 @@ import Text.HTML
selectVideoWallContent :: Task ()
selectVideoWallContent
= (header ||- selectContent) <<@ (ArrangeWithSideBar 0 TopSide 30 False)
= (header ||- selectContent) <<@ (ArrangeWithSideBar 0 TopSide 30 False)
@! ()
where
header
......
......@@ -38,7 +38,7 @@ answerPhoneCall communicationNo
>>| connectInboundPhoneCall communicationNo
||- ((manageCommunicationContact communicationNo
-&&-
manageVoiceCallContent PhoneCall communicationNo) <<@ ArrangeWithSideBar 0 LeftSide 300 True)
manageVoiceCallContent PhoneCall communicationNo) <<@ ArrangeWithSideBar 0 LeftSide 300 True)
<<@ ArrangeWithSideBar 0 TopSide 60 False
<<@ Title ("Answer phone call")
/* <<@ AfterLayout (uiDefSetSize (ExactSize 800) (ExactSize 600)) */ //FIXME
......
......@@ -26,7 +26,7 @@ selectContact = withShared Nothing
(viewContactsOnMap mapContacts sel <<@ Title "Map")
<<@ ArrangeWithTabs True
)
where
where
mapContacts = mapRead (\(x,y) -> x++y) (contactsOfOpenIncidentsGeo |+| contactsProvidingHelpGeo)
selectContactFromLists :: (Shared (Maybe (Either ContactNo MMSI))) -> Task (Either ContactNo MMSI)
......@@ -40,7 +40,7 @@ where
/*
,(editSharedSelectionWithShared (Title "AIS") False
(SelectInTree ungrouped) (mapRead (sortBy (\x y -> contactTitle x < contactTitle y) o map aisToContact) allAISContacts) (Right o contactIdentity)) sel
*/ ] <<@ (ArrangeSplit Horizontal True) @? tvHd
*/ ] <<@ (ArrangeSplit Horizontal True) @? tvHd
fromOpenOption [{ContactShortWithIncidents|contactNo}] = contactNo
......@@ -195,7 +195,7 @@ manageContactCommunicationMeans compact contactNo = forever (
>^* [OnAction ActionAdd (always (addMean contactNo <<@ InWindow @! ()))
,OnAction ActionEdit (hasValue (\{CommunicationMean|id} -> editMean id <<@ InWindow @! ()))
,OnAction ActionRemove (hasValue (\{CommunicationMean|id} -> removeMean id))
]
]
)
where
ActionAdd = Action (if compact "Add" "/Add")
......@@ -263,7 +263,7 @@ manageContactIncidents :: Workspace ContactNo -> Task ()
manageContactIncidents ws contactNo
= feedForward choose
( \sel ->
withSelection viewNoSelection viewIncidentDetails sel
withSelection viewNoSelection viewIncidentDetails sel
-&&-
doAddRemoveOpen (add <<@ InWindow) (\c -> (remove c) <<@ InWindow) (\c -> doOrClose (open c)) ws sel
) <<@ (ArrangeWithSideBar 1 RightSide 300 True) <<@ (Icon "incidents") <<@ (Title "Incidents")
......@@ -596,7 +596,7 @@ where
selection _ = NoValue
sharePerspective (_,perspective) = set (WallOverview perspective) wallContent @! ()
toMarkers sel contacts
= [contactGeoToMapMarker ais (isSelected contactNo sel) c \\ (ais,c=:{ContactGeo|contactNo,name=Just _,position=Just _}) <- contacts]
......@@ -609,7 +609,7 @@ where
| startsWith "c" markerId = Just (Left (toInt (subString 1 (textSize markerId) markerId)))
| startsWith "a" markerId = Just (Right (toInt (subString 1 (textSize markerId) markerId)))
= updateSelection ms
findContactNo title contacts = case [(isAis,contactNo) \\ (isAis,{ContactGeo|contactNo,name}) <- contacts | name == title] of
[(False,contactNo)] = Just (Left contactNo)
[(True,mmsi)] = Just (Right mmsi)
......
......@@ -94,11 +94,11 @@ where
contactSummary :: Contact -> ContactShort
contactSummary {Contact|contactNo,name,type,group}
= {ContactShort|contactNo = contactNo, name = name, type = type, group = group}
incidentDetails :: Incident -> IncidentDetails
incidentDetails {Incident|incidentNo,title,summary,type,phase}
= {IncidentDetails|incidentNo = incidentNo, title = title, summary = summary, type = type, phase = phase}
contactDetails :: Contact -> ContactDetails
contactDetails {Contact|contactNo,name,type,position,notes}
= {ContactDetails|contactNo = contactNo, name = name, type = type, position = position, notes = notes}
......
......@@ -27,7 +27,7 @@ manageIncidentInformation ws incidentNo
,(Embedded, \_ -> manageIncidentContacts ws incidentNo)
,(Embedded, \_ -> manageIncidentActions incidentNo)
,(Embedded, \_ -> manageIncidentWeather incidentNo)
,(Embedded, \_ -> manageIncidentLog incidentNo)
,(Embedded, \_ -> manageIncidentLog incidentNo)
] [] <<@ ArrangeWithTabs False)
@! ()
......@@ -101,7 +101,7 @@ manageIncidentActions incidentNo
@! ()
where
selectAndWorkOnPlannedActions
= (feedForward (chooseActionItem (Title "Overview") False True (sdsFocus incidentNo actionStatusesByIncident) /* <<@ AfterLayout (tweakUI fill) */)
= (feedForward (chooseActionItem (Title "Overview") False True (sdsFocus incidentNo actionStatusesByIncident) /* <<@ AfterLayout (tweakUI fill) */)
(\s -> whileUnchanged s
(\t -> case t of
Just taskId = workOnActionItem taskId
......@@ -120,7 +120,7 @@ manageIncidentWeather incidentNo
where
weather = sdsFocus incidentNo incidentWeather
log = logIncidentWeatherUpdated incidentNo
viewWebWeather widgets = viewInformation (Title "Web weather info") [] (RawText widgets)
viewWebWeather widgets = viewInformation (Title "Web weather info") [] (Html widgets)
manageIncidentLog :: IncidentNo -> Task ()
manageIncidentLog incidentNo
......@@ -152,7 +152,7 @@ where
( enterInformation () [] @ string
>>* [OnAction (Action "Add log message") (hasValue (\msg -> addLogMessage msg incidentNo))]
)
string :: String -> String
string x = x
......@@ -350,7 +350,7 @@ createIncident incident
logIncidentCreated incidentNo incident
@! incidentNo
where
create :: NewIncident -> Task IncidentNo
create :: NewIncident -> Task IncidentNo
create {NewIncident|type,title,summary}
= get databaseDef
>>- \db -> sqlExecute db ["allIncidents"] (execInsert "INSERT INTO Incident (type,title,summary) VALUES (?,?,?)"
......
......@@ -143,7 +143,7 @@ where
# (err,cur) = execute "INSERT INTO PhoneCall (communicationNo,externalNo) VALUES (?,?)"
(flatten [toSQL communicationNo,mbToSQL externalNo]) cur
| isJust err
# (err,cur) = execute "UPDATE PhoneCall SET externalNo = ? WHERE communicationNo = ?"
# (err,cur) = execute "UPDATE PhoneCall SET externalNo = ? WHERE communicationNo = ?"
(flatten [mbToSQL externalNo,toSQL communicationNo]) cur
| isJust err = (Error (toString (fromJust err)),cur)
= (Ok (), cur)
......@@ -193,7 +193,7 @@ where
detailsIncidents :: (Maybe RowFilterDef) -> ReadOnlyShared [IncidentDetails]
detailsIncidents mbWhere = mapRead (map prj) (baseIncidents mbWhere)
where
where
prj {Incident|incidentNo,title,summary,type,phase}
= {IncidentDetails|incidentNo=incidentNo,title=title,summary=summary,type=type,phase=phase}
......@@ -327,7 +327,7 @@ where
, communications = fromMaybe [] ('DM'.get incident.Incident.incidentNo cmlinks)
, log = log
}
writePrj (incident=:{Incident|incidentNo,contacts,communications}) (((_,cnlinks),cmlinks),_)
= Just ((incident,'DM'.put incidentNo contacts cnlinks),'DM'.put incidentNo communications cmlinks)
writePrj _ _ = Nothing
......@@ -758,7 +758,7 @@ where
# (err,mbRow,cur) = fetchOne cur
| isJust err = (Error (toString (fromJust err)),cur)
= (Ok (fmap fromSQL mbRow), cur)