Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rjs_json_form
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
rjs_json_form
Commits
a5a10bb8
Commit
a5a10bb8
authored
Aug 15, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: test viewer display validation and changed status
parent
0d4890f6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
33 deletions
+80
-33
test/jsonform_test_view.js
test/jsonform_test_view.js
+80
-33
No files found.
test/jsonform_test_view.js
View file @
a5a10bb8
...
@@ -38,6 +38,38 @@
...
@@ -38,6 +38,38 @@
});
});
}
}
function
updateTextContent
(
g
)
{
return
g
.
getDeclaredGadget
(
"
form_view
"
)
.
push
(
function
(
form_view
)
{
return
form_view
.
getContent
();
})
.
push
(
function
(
ret
)
{
var
valid
=
g
.
state
.
valid
,
changed
=
g
.
state
.
changed
;
if
(
ret
===
undefined
)
{
ret
=
{};
}
if
(
typeof
valid
===
"
boolean
"
)
{
if
(
valid
)
{
valid
=
"
form filed valid
"
;
}
else
{
valid
=
"
form filed invalid
"
;
}
}
else
{
valid
=
"
valid status unknown
"
;
}
if
(
changed
)
{
changed
=
'
changed
\n
'
;
}
else
{
changed
=
''
;
}
document
.
getElementById
(
"
json_document_content
"
).
textContent
=
valid
+
'
\n
'
+
changed
+
JSON
.
stringify
(
ret
,
null
,
2
);
});
}
rJS
(
window
)
rJS
(
window
)
.
ready
(
function
(
g
)
{
.
ready
(
function
(
g
)
{
var
url_list
=
[];
var
url_list
=
[];
...
@@ -97,11 +129,19 @@
...
@@ -97,11 +129,19 @@
]);
]);
});
});
})
})
.
allowPublicAcquisition
(
"
notifyValid
"
,
function
()
{
.
allowPublicAcquisition
(
"
notifyValid
"
,
function
(
arr
,
scope
)
{
return
;
if
(
scope
===
"
form_view
"
)
{
this
.
changeState
({
valid
:
true
});
}
})
})
.
allowPublicAcquisition
(
"
notifyInvalid
"
,
function
()
{
.
allowPublicAcquisition
(
"
notifyInvalid
"
,
function
(
arr
,
scope
)
{
return
;
if
(
scope
===
"
form_view
"
)
{
this
.
changeState
({
valid
:
false
});
}
})
})
.
allowPublicAcquisition
(
"
notifyChange
"
,
function
(
arr
,
scope
)
{
.
allowPublicAcquisition
(
"
notifyChange
"
,
function
(
arr
,
scope
)
{
var
gadget
=
this
;
var
gadget
=
this
;
...
@@ -125,12 +165,14 @@
...
@@ -125,12 +165,14 @@
return
g
.
getContent
();
return
g
.
getContent
();
})
})
.
push
(
function
(
ret
)
{
.
push
(
function
(
ret
)
{
gadget
.
props
.
valid
=
null
;
if
(
ret
!==
gadget
.
props
.
documents
[
0
])
{
if
(
ret
!==
gadget
.
props
.
documents
[
0
])
{
var
test
=
gadget
.
props
.
schema
+
'
:
'
+
ret
;
var
test
=
gadget
.
props
.
schema
+
'
:
'
+
ret
;
test
=
gadget
.
props
.
test_data
[
test
];
test
=
gadget
.
props
.
test_data
[
test
];
console
.
log
(
test
.
schema
);
console
.
log
(
test
.
schema
);
console
.
log
(
test
.
data
);
console
.
log
(
test
.
data
);
return
gadget
.
changeState
({
return
gadget
.
changeState
({
changed
:
false
,
schema
:
test
.
schema
,
schema
:
test
.
schema
,
json_document
:
test
.
data
json_document
:
test
.
data
});
});
...
@@ -138,40 +180,45 @@
...
@@ -138,40 +180,45 @@
});
});
}
}
if
(
scope
===
"
form_view
"
)
{
if
(
scope
===
"
form_view
"
)
{
return
this
.
getDeclaredGadget
(
"
form_view
"
)
return
gadget
.
changeState
({
.
push
(
function
(
g
)
{
changed
:
true
return
g
.
getContent
();
})
})
.
push
(
function
(
ret
)
{
.
push
(
function
()
{
if
(
ret
===
undefined
)
{
return
updateTextContent
(
gadget
);
ret
=
{};
}
document
.
getElementById
(
"
json_document_content
"
).
textContent
=
JSON
.
stringify
(
ret
,
null
,
"
"
);
});
});
}
}
})
})
.
onStateChange
(
function
()
{
.
onStateChange
(
function
(
modification
)
{
var
g
=
this
;
var
g
=
this
,
return
g
.
getDeclaredGadget
(
"
form_view
"
)
queue
=
RSVP
.
Queue
();
if
(
modification
.
hasOwnProperty
(
'
json_document
'
)
||
modification
.
hasOwnProperty
(
'
schema
'
)
||
modification
.
hasOwnProperty
(
'
schema_url
'
))
{
queue
.
push
(
function
()
{
return
g
.
getDeclaredGadget
(
"
form_view
"
);
})
.
push
(
function
(
form_view
)
{
.
push
(
function
(
form_view
)
{
return
form_view
.
render
({
return
form_view
.
render
({
value
:
g
.
state
.
json_document
,
value
:
g
.
state
.
json_document
,
schema
:
g
.
state
.
schema
,
schema
:
g
.
state
.
schema
,
schema_url
:
g
.
state
.
schema_url
schema_url
:
g
.
state
.
schema_url
});
})
})
.
push
(
function
(
)
{
.
push
(
undefined
,
function
(
error
)
{
return
form_view
.
getContent
(
);
console
.
log
(
error
);
})
})
.
push
(
function
(
ret
)
{
.
push
(
function
()
{
if
(
ret
===
undefined
)
{
return
updateTextContent
(
g
);
ret
=
{};
}
g
.
state
.
json_document
=
ret
;
document
.
getElementById
(
"
json_document_content
"
).
textContent
=
JSON
.
stringify
(
ret
,
null
,
2
);
});
});
}
if
(
modification
.
hasOwnProperty
(
'
valid
'
))
{
queue
.
push
(
function
()
{
return
updateTextContent
(
g
);
});
});
}
return
queue
;
});
});
}(
window
,
rJS
,
jIO
));
}(
window
,
rJS
,
jIO
));
\ No newline at end of file
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