Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
iTasks-SDK
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
84
Issues
84
List
Boards
Labels
Service Desk
Milestones
Merge Requests
10
Merge Requests
10
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
clean-and-itasks
iTasks-SDK
Commits
01195bb7
Commit
01195bb7
authored
Nov 12, 2018
by
Bas Lijnse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Worked out composition for refined editor proposal
parent
c19e0a92
Pipeline
#16285
passed with stage
in 3 minutes and 51 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
29 deletions
+78
-29
Libraries/iTasks/UI/RefinedEditor.dcl
Libraries/iTasks/UI/RefinedEditor.dcl
+78
-29
No files found.
Libraries/iTasks/UI/RefinedEditor.dcl
View file @
01195bb7
definition
module
iTasks
.
UI
.
RefinedEditor
//TODO: Use (p r w) instead of v for external interface
//Tasks to handle side-effects just write commands to the share?
//Collaboration with a distributed message set and versions needs to be built into
//interact. The state and message queue will be shared between tasks instead of the editor value
CollabModel
s
:==
(
Versioned
s
,
[
Versioned
EditorUpdate
])
...
...
@@ -7,7 +10,6 @@ Versioned a :== (!Int,!a)
SDS
Int
(
Either
(
Version
s
)
[
Version
s
])
//Tasks to handle side-effects
//Definition of an editor
//Each editor defines a client and a server component with their own state.
...
...
@@ -15,32 +17,38 @@ SDS Int (Either (Version s) [Version s])
::
[(
String
,
c
->
(
c
,
Maybe
msg
))]
->
EditorClient
c
msg
::
Editor
v
s
c
=
E
.
msg
:
{
client
::
EditorClient
c
msg
,
server
::
EditorServer
v
s
c
msg
//v = Value the editor represents (print/parse to lower level)
//s = Raw server state, for example an unparsed string
//c = Client configuration, the initial setup of a client component
//m = Message type, used for communicating between client and server
::
Editor
v
s
c
m
=
{
client
::
EditorClient
c
m
,
server
::
EditorServer
v
s
c
m
}
::
EditorClient
c
m
sg
=
{
init
::
c
!
JSObject
*
JSWorld
->
*(!
Maybe
m
sg
,
!*
JSWorld
)
::
EditorClient
c
m
=
{
init
::
c
!
JSObject
*
JSWorld
->
*(!
Maybe
m
,
!*
JSWorld
)
,
destroy
::
!
JSObject
*
JSWorld
->
*
JSWorld
,
onEvent
::
!
String
!
JSObject
!
JSObject
!*
JSWorld
->
(!
Maybe
msg
,
!*
JSWorld
)
,
onMessage
::
msg
!
JSObject
!*
JSWorld
->
*(!
Maybe
msg
,
!*
JSWorld
)
,
setState
::
c
!
JSObject
!*
JSWorld
->
*(!
Maybe
msg
,
*
JSWorld
)
,
getState
::
!
JSObject
!*
JSWorld
->
*(!
c
,
*
JSWorld
)
//Something happened in the javascript/DOM world
,
onEvent
::
!
String
!
JSObject
!
JSObject
!*
JSWorld
->
(!
Maybe
m
,
!*
JSWorld
)
//A message from the server arrived
,
onMessage
::
m
!
JSObject
!*
JSWorld
->
*(!
Maybe
m
,
!*
JSWorld
)
}
::
EditorServer
v
s
c
m
sg
=
{
init
::
s
->
c
//Derive the initial client state from the server state
::
EditorServer
v
s
c
m
=
{
configure
::
s
->
c
//Derive the initial client configuration
,
on
Set
::
s
s
->
(
s
,
Maybe
msg
)
,
onMessage
::
m
sg
s
->
(
s
,
Maybe
msg
)
,
on
Refresh
::
s
s
->
(
s
,
Maybe
m
)
,
onMessage
::
m
s
->
(
s
,
Maybe
m
)
,
toValue
::
s
->
EditorValue
v
,
fromValue
::
(
EditorValue
v
)
->
s
,
value
::
((
EditorValue
v
)
->
s
,
s
->
EditorValue
v
)
//How to get to/from the validated domain
}
//Exposing editors valid/invalid/empty judgement
::
EditorValue
a
=
ValidValue
a
|
InvalidValue
|
EmptyValue
class
EditorMessage
m
where
encodeEditorMessage
::
m
->
EditStateUpdate
...
...
@@ -51,14 +59,12 @@ where
encodeEditorState
::
s
->
EditState
decodeEditorState
::
EditState
->
s
//Exposing editors valid/invalid/empty judgement
::
EditorValue
a
=
ValidValue
a
|
InvalidValue
|
EmptyValue
//Generic untyped edit state
::
EditState
=
{
attributes
::
Map
AttributeName
AttributeValue
,
children
::
[
EditState
]
}
::
AttributeName
:==
String
::
AttributeValue
:==
JSONNode
...
...
@@ -73,7 +79,6 @@ where
::
ClientState
:==
EditState
::
ServerState
:==
EditState
//Editor composition
//- client side without communication
//- service
...
...
@@ -84,14 +89,14 @@ where
// - Dynamic label that shows the number of items
// - Buttons with each item for moving i
listEditor
::
(
Editor
a
s
c
)
->
Editor
[
a
]
[
s
]
[
c
]
listEditor
::
(
Editor
a
s
c
m
)
->
Editor
[
a
]
[
s
]
[
c
]
(
Int
,
m
)
label
::
String
->
Editor
String
()
LabelDef
button
::
String
->
Editor
Bool
Bool
ButtonDef
textView
::
Editor
String
TextViewDef
TextViewDef
textField
::
Editor
String
TextFieldDef
TextFieldDef
button
::
(
Bool
->
ButtonDef
)
->
Editor
Bool
Bool
ButtonDef
Bool
textView
::
Editor
String
TextViewDef
TextViewDef
String
textField
::
Editor
String
TextFieldDef
TextFieldDef
String
integerField
::
Editor
Int
TextFieldDef
TextFieldDef
integerField
::
Editor
Int
TextFieldDef
TextFieldDef
String
::
ButtonDef
=
{
clicked
::
Bool
...
...
@@ -109,6 +114,50 @@ integerField :: Editor Int TextFieldDef TextFieldDef
{
text
::
String
}
//editor voor getal
//editor voor boolean (checkbox)
//combinatie voor (maybe getal)
//Editor for numbers
//Editor for boolean (checkbox)
//Combination: for maybe number
//Compose by juxtaposition, no need to specify interdependency
glue
::
(
Editor
v1
s1
c1
m1
)
(
Editor
v2
s2
c2
m2
)
->
(
Editor
(
EditorValue
v1
,
EditorValue
v2
)
(
s1
,
s2
)
(
c1
,
c2
)
(
Maybe
m1
,
Maybe
m2
))
//Define the dependencies by defining feedback on messages
link
::
((
c1
,
c2
)
->
(
c1
,
c2
))
//Rewrite the initial client configuration
((
Maybe
m1
,
Maybe
m2
)
->
((
Maybe
m1
,
Maybe
m2
),(
Maybe
m1
,
Maybe
m2
)))
//Rewrite from server to client with feedback to server
((
Maybe
m1
,
Maybe
m2
)
->
((
Maybe
m1
,
Maybe
m2
),(
Maybe
m1
,
Maybe
m2
)))
//Rewrite from client to server with feedback to client
(
Editor
v
s
(
c1
,
c2
)
(
Maybe
m1
,
Maybe
m2
))
->
(
Editor
v
s
(
c1
,
c2
)
(
Maybe
m1
,
Maybe
m2
))
//Get rid of the tuples and combine the parts into a unified state, configuration and
fuse
::
((
c1
,
c2
)
->
c
,
c
->
(
c1
,
c2
))
//Unify client configuration
((
s1
,
s2
)
->
s
,
s
->
(
s1
,
s2
))
//Unify server state
(
m
->
(
Maybe
m1
,
Maybe
m2
),
(
Maybe
m1
,
Maybe
m2
)
->
Maybe
m
)
//Unify messages
(
EditorValue
v
->
(
EditorValue
v1
,
EditorValue
v2
),
(
EditorValue
v1
,
EditorValue
v2
)
->
EditorValue
v
)
//Unity checked interface
(
Editor
(
EditorValue
v1
,
EditorValue
v2
)
(
s1
,
s2
)
(
c1
,
c2
)
(
Maybe
m1
,
Maybe
m2
))
->
(
Editor
v
s
c
m
)
//Example : Texfield with reset button
resettableField
=
fuseFst
buttonconfig
(
link
id
serverlink
clientlink
(
glue
textField
(
button
(
const
buttonconfig
))))
where
clientlink
(_,
Just
True
)
=
((
Just
""
,
Nothing
),
(
Just
""
,
Just
False
))
//When button is clicked, reset both local and remote
clientlink
(
mt
,
mb
)
=
((
mt
,
mb
),(
Nothing
,
Nothing
)
serverlink
m
=
(
m
,(
Nothing
,
Nothing
))
//No feedback serverside
buttonconfig
=
{
ButtonDef
|
clicked
=
False
,
label
=
Just
"Reset"
,
icon
=
Nothing
}
//Common pattern: expose first component
fuseFst
sndCfg
editor
=
fuse
clientconfig
serverstate
messages
interface
where
clientconfig
=
(
fst
,
\
s
->
(
s
,
sndCfg
))
//Reset button is statically configured
serverstate
=
(
fst
,
\
s
->
(
s
,
False
))
//Only server state of the textfield is stored
messages
=
(\
m
->
(
Just
m
,
Nothing
),
fst
)
//Drop messages for second part of the tuple
interface
=
(
x
->
(
x
,
EmptyValue
),
fst
)
//Only consider first part as editor
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment