Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
clean-and-itasks
iTasks-SDK
Commits
025577d2
Commit
025577d2
authored
Jun 09, 2016
by
Bas Lijnse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made builtin editors pass the unit tests
parent
fbe031ba
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
39 deletions
+27
-39
Server/iTasks/UI/Editor.icl
Server/iTasks/UI/Editor.icl
+4
-4
Server/iTasks/UI/Editor/Builtin.icl
Server/iTasks/UI/Editor/Builtin.icl
+2
-1
Tests/Tests/Unit/CoreEditors.icl
Tests/Tests/Unit/CoreEditors.icl
+21
-34
No files found.
Server/iTasks/UI/Editor.icl
View file @
025577d2
...
...
@@ -66,15 +66,15 @@ stdAttributes typename optional mask
#
(
touched
,
valid
,
state
)
=
case
mask
of
(
FieldMask
{
FieldMask
|
touched
,
valid
,
state
})
=
(
touched
,
valid
,
state
)
mask
=
(
isTouched
mask
,
True
,
JSONNull
)
|
not
touched
||
(
state
=:
JSONNull
&&
optional
)
|
state
=:
JSONNull
&&
not
touched
=
'
DM
'.
fromList
[(
HINT_TYPE_ATTRIBUTE
,
JSONString
HINT_TYPE_INFO
)
,(
HINT_ATTRIBUTE
,
JSONString
(
"Please enter a "
+++
typename
+++
if
optional
""
" (this value is required)"
))]
|
state
=:
JSONNull
=
'
DM
'.
fromList
[(
HINT_TYPE_ATTRIBUTE
,
JSONString
HINT_TYPE_INVALID
)
,(
HINT_ATTRIBUTE
,
JSONString
(
"You need to enter a "
+++
typename
+++
" (this value is required)"
))]
|
valid
=
'
DM
'.
fromList
[(
HINT_TYPE_ATTRIBUTE
,
JSONString
HINT_TYPE_VALID
)
,(
HINT_ATTRIBUTE
,
JSONString
(
"You have correctly entered a "
+++
typename
))]
|
state
=:
JSONNull
=
'
DM
'.
fromList
[(
HINT_TYPE_ATTRIBUTE
,
JSONString
HINT_TYPE_INVALID
)
,(
HINT_ATTRIBUTE
,
JSONString
(
"You need to enter a "
+++
typename
+++
" (this value is required)"
))]
|
otherwise
=
'
DM
'.
fromList
[(
HINT_TYPE_ATTRIBUTE
,
JSONString
HINT_TYPE_INVALID
)
,(
HINT_ATTRIBUTE
,
JSONString
(
"This value not in the required format of a "
+++
typename
))]
...
...
Server/iTasks/UI/Editor/Builtin.icl
View file @
025577d2
...
...
@@ -45,8 +45,9 @@ icon = simpleComponent toJSON UIIcon
simpleComponent
toValue
type
=
{
Editor
|
genUI
=
genUI
,
onEdit
=
onEdit
,
onRefresh
=
onRefresh
}
where
genUI
dp
val
vst
=:{
VSt
|
taskId
,
mode
,
optional
}
#
mask
=
newFieldMask
#
val
=
if
(
mode
=:
Enter
)
JSONNull
(
toValue
val
)
#
valid
=
if
(
mode
=:
Enter
)
optional
True
//When entering data a value is initially only valid if it is optional
#
mask
=
FieldMask
{
touched
=
False
,
valid
=
valid
,
state
=
val
}
#
attr
=
'
DM
'.
unions
[
optionalAttr
optional
,
taskIdAttr
taskId
,
editorIdAttr
(
editorId
dp
),
valueAttr
val
]
=
(
Ok
(
uia
type
attr
,
mask
),
vst
)
...
...
Tests/Tests/Unit/CoreEditors.icl
View file @
025577d2
...
...
@@ -31,13 +31,12 @@ testGenericEditorGenUI :: TestSuite
testGenericEditorGenUI
=
testsuite
"Generic UI generation"
"Tests for the core generic UI generation"
[
testIntEnter
,
testIntUpdate
,
testIntBlanked
,
testRealTouched
,
testConsFieldsTouched
,
testRealUpdate
,
testConsFieldsUpdate
,
testMultipleConsesTouched
,
testConsesWithFieldTouched
,
testRecordTouched
,
testMaybeInt
U
nt
ouched
,
testMaybeInt
E
nt
er
]
testGenUI
::
String
(
UI
,
EditMask
)
a
EditMode
->
Test
|
iTask
a
...
...
@@ -49,14 +48,15 @@ where
#
world
=
fromStubIWorld
(
fromStubVSt
vst
)
=
(
res
,
world
)
testIntEnter
=
testGenUI
"
U
nt
ouched
Int"
testIntEnter
=
testGenUI
"
E
nt
er
Int"
(
uia
UIIntegerField
('
DM
'.
fromList
[(
"optional"
,
JSONBool
False
),(
"hint-type"
,
JSONString
"info"
)
,(
"hint"
,
JSONString
"Please enter a whole number (this value is required)"
)
,(
"taskId"
,
JSONString
"STUB"
)
,(
"editorId"
,
JSONString
"v"
)
,(
"value"
,
JSONNull
)
]),
FieldMask
{
touched
=
False
,
valid
=
False
,
state
=
JSONNull
})
42
Enter
0
Enter
testIntUpdate
=
testGenUI
"Update Int"
(
uia
UIIntegerField
...
...
@@ -65,33 +65,20 @@ testIntUpdate = testGenUI "Update Int"
,(
"taskId"
,
JSONString
"STUB"
)
,(
"editorId"
,
JSONString
"v"
)
,(
"value"
,
JSONInt
42
)
]),
FieldMask
{
touched
=
False
,
valid
=
True
,
state
=
JSON
Null
})
]),
FieldMask
{
touched
=
False
,
valid
=
True
,
state
=
JSON
Int
42
})
42
Update
testIntBlanked
=
skip
"Blanked Int"
/* testGenUI "Blanked Int"
(uia UIEditInt
('DM'.fromList[("optional",JSONBool False),("hint-type",JSONString "invalid")
,("hint",JSONString "Please enter a whole number (this value is required)")
,("taskId",JSONString "STUB")
,("editorId",JSONString "v")
]))
42 Blanked
*/
testRealTouched
=
skip
"Touched Real"
/* testGenUI "Touched Real"
(uia UIEditDecimal
testRealUpdate
=
testGenUI
"Update Real"
(
uia
UIDecimalField
('
DM
'.
fromList
[(
"optional"
,
JSONBool
False
),(
"hint-type"
,
JSONString
"valid"
)
,("hint",JSONString "You have correctly entered a decimalnumber")
,(
"hint"
,
JSONString
"You have correctly entered a decimal
number"
)
,(
"taskId"
,
JSONString
"STUB"
)
,(
"editorId"
,
JSONString
"v"
)
,(
"value"
,
JSONReal
3.14
)
]))
3.14 Touched
*/
]),
FieldMask
{
touched
=
False
,
valid
=
True
,
state
=
JSONReal
3.14
})
3.14
Update
testConsFields
Touched
=
testGenUI
"Touched cons fields"
testConsFields
Update
=
testGenUI
"Touched cons fields"
(
uiac
UICons
('
DM
'.
fromList
[(
"optional"
,
JSONBool
False
)])
[
fieldExp
"v0"
1
,
fieldExp
"v1"
2
,
fieldExp
"v2"
3
,
fieldExp
"v3"
4
,
fieldExp
"v4"
5
,
fieldExp
"v5"
6
],
CompoundMask
[])
(
TestConsFields
1
2
3
4
5
6
)
Update
...
...
@@ -150,17 +137,17 @@ where
('DM'.fromList[("optional",JSONBool False),("label",JSONString "c"),("taskId",JSONString "STUB"),("editorId",JSONString "v2")]))
*/
testMaybeIntUntouched
=
skip
"Untouched optional Int"
/* (testGenUI "Untouched optional Int"
(uia UIEditInt ('DM'.fromList[("hint-type",JSONString "info")
,("hint",JSONString "Please enter a whole number")
,("taskId",JSONString "STUB")
,("editorId",JSONString "v")]))
test Untouched
testMaybeIntEnter
=
testGenUI
"Enter optional Int"
(
uia
UIIntegerField
('
DM
'.
fromList
[(
"optional"
,
JSONBool
True
)
,(
"hint-type"
,
JSONString
"info"
)
,(
"hint"
,
JSONString
"Please enter a whole number"
)
,(
"taskId"
,
JSONString
"STUB"
)
,(
"editorId"
,
JSONString
"v"
)
,(
"value"
,
JSONNull
)]),
FieldMask
{
touched
=
False
,
valid
=
True
,
state
=
JSONNull
})
test
Enter
where
test
::
Maybe
Int
test
=
Nothing
*/
testGenericEditorEdits
::
TestSuite
testGenericEditorEdits
=
testsuite
"Generic edits"
"Tests for processing edits by editors"
...
...
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