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
630c7fb3
Commit
630c7fb3
authored
Aug 27, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demo: fix demo to work with latest version gadget
parent
a1c09cf7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
40 deletions
+78
-40
demo/gadget_demo_json_schema_form.js
demo/gadget_demo_json_schema_form.js
+78
-40
No files found.
demo/gadget_demo_json_schema_form.js
View file @
630c7fb3
...
...
@@ -47,6 +47,35 @@
});
}
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
(
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
)
.
ready
(
function
(
g
)
{
g
.
props
=
{};
...
...
@@ -85,11 +114,19 @@
]);
});
})
.
allowPublicAcquisition
(
"
notifyValid
"
,
function
()
{
return
;
.
allowPublicAcquisition
(
"
notifyValid
"
,
function
(
arr
,
scope
)
{
if
(
scope
===
"
form_view
"
)
{
this
.
changeState
({
valid
:
true
});
}
})
.
allowPublicAcquisition
(
"
notifyInvalid
"
,
function
()
{
return
;
.
allowPublicAcquisition
(
"
notifyInvalid
"
,
function
(
arr
,
scope
)
{
if
(
scope
===
"
form_view
"
)
{
this
.
changeState
({
valid
:
false
});
}
})
.
allowPublicAcquisition
(
"
notifyChange
"
,
function
(
arr
,
scope
)
{
var
gadget
=
this
;
...
...
@@ -99,12 +136,11 @@
return
g
.
getContent
();
})
.
push
(
function
(
ret
)
{
if
(
ret
!==
gadget
.
props
.
schemas
[
0
])
{
if
(
ret
!==
gadget
.
props
.
schemas
[
0
]
&&
ret
!==
gadget
.
state
.
schema_url
)
{
return
gadget
.
changeState
({
schema_url
:
ret
,
json_document
:
JSON
.
parse
(
document
.
getElementById
(
"
json_document_content
"
).
textContent
)
json_document
:
gadget
.
state
.
json_document
});
}
});
...
...
@@ -134,46 +170,48 @@
json_document
:
json_document
}));
return
RSVP
.
all
(
tasks
);
})
.
push
(
function
()
{
return
render_document_selection_form
(
gadget
);
});
}
if
(
scope
===
"
form_view
"
)
{
return
this
.
getDeclaredGadget
(
"
form_view
"
)
.
push
(
function
(
g
)
{
return
g
.
getContent
();
return
gadget
.
changeState
({
changed
:
true
})
.
push
(
function
(
ret
)
{
if
(
ret
===
undefined
)
{
ret
=
{};
}
document
.
getElementById
(
"
json_document_content
"
).
textContent
=
JSON
.
stringify
(
ret
,
null
,
"
"
);
.
push
(
function
()
{
return
updateTextContent
(
gadget
);
});
}
return
;
})
.
onStateChange
(
function
()
{
var
g
=
this
;
return
g
.
getDeclaredGadget
(
"
form_view
"
)
.
onStateChange
(
function
(
modification
)
{
var
g
=
this
,
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
)
{
return
form_view
.
render
({
value
:
g
.
state
.
json_document
,
schema
:
g
.
state
.
schema
,
schema_url
:
g
.
state
.
schema_url
});
})
.
push
(
function
(
)
{
return
form_view
.
getContent
(
);
.
push
(
undefined
,
function
(
error
)
{
console
.
log
(
error
);
})
.
push
(
function
(
ret
)
{
if
(
ret
===
undefined
)
{
ret
=
{};
}
g
.
state
.
json_document
=
ret
;
document
.
getElementById
(
"
json_document_content
"
).
textContent
=
JSON
.
stringify
(
ret
,
null
,
"
"
);
.
push
(
function
()
{
return
updateTextContent
(
g
);
});
}
if
(
modification
.
hasOwnProperty
(
'
valid
'
))
{
queue
.
push
(
function
()
{
return
updateTextContent
(
g
);
});
}
return
queue
;
});
}(
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