Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
ede0b638
Commit
ede0b638
authored
Mar 21, 2016
by
Rafael Ostertag
Browse files
Support for refreshing/reconfiguring form elements added.
parent
e4ec6811
Changes
4
Hide whitespace changes
Inline
Side-by-side
javascript/src/Form.js
View file @
ede0b638
...
...
@@ -74,6 +74,10 @@ if (!QfqNS) {
.
fail
(
this
.
submitFailureHandler
.
bind
(
this
));
};
n
.
Form
.
prototype
.
serialize
=
function
()
{
return
this
.
$form
.
serialize
();
};
/**
*
* @param data
...
...
javascript/src/QfqForm.js
View file @
ede0b638
...
...
@@ -11,10 +11,11 @@ if (!QfqNS) {
(
function
(
n
)
{
'
use strict
'
;
n
.
QfqForm
=
function
(
formId
,
submitTo
,
deleteUrl
)
{
n
.
QfqForm
=
function
(
formId
,
submitTo
,
deleteUrl
,
dataRefreshUrl
)
{
this
.
formId
=
formId
;
this
.
submitTo
=
submitTo
;
this
.
deleteUrl
=
deleteUrl
;
this
.
dataRefreshUrl
=
dataRefreshUrl
;
this
.
form
=
new
n
.
Form
(
this
.
formId
);
this
.
bsTabs
=
null
;
this
.
lastButtonPress
=
null
;
...
...
@@ -31,6 +32,8 @@ if (!QfqNS) {
this
.
getCloseButton
().
click
(
this
.
handleCloseClick
.
bind
(
this
));
this
.
getNewButton
().
click
(
this
.
handleNewClick
.
bind
(
this
));
this
.
getDeleteButton
().
click
(
this
.
handleDeleteClick
.
bind
(
this
));
this
.
setupRefreshHandler
();
};
n
.
QfqForm
.
prototype
.
setBsTabs
=
function
(
bsTabs
)
{
...
...
@@ -58,6 +61,23 @@ if (!QfqNS) {
}
};
n
.
QfqForm
.
prototype
.
setupRefreshHandler
=
function
()
{
$
(
'
input[data-load]
'
).
on
(
'
change
'
,
this
.
refreshHandler
.
bind
(
this
));
};
n
.
QfqForm
.
prototype
.
refreshHandler
=
function
()
{
var
that
=
this
;
$
.
post
(
this
.
dataRefreshUrl
,
this
.
form
.
serialize
(),
"
json
"
)
.
fail
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
var
alert
=
new
QfqNS
.
Alert
(
"
Error:<br>
"
+
errorThrown
,
"
error
"
);
alert
.
show
();
})
.
done
(
function
(
data
)
{
this
.
applyElementConfiguration
(
data
);
}.
bind
(
that
));
};
/**
* @private
*/
...
...
mockup/api/form_refresh.json
0 → 100644
View file @
ede0b638
{
"text"
:
{
"value"
:
"value. Now its enabled"
,
"disabled"
:
false
,
"readonly"
:
true
},
"select"
:
{
"value"
:
[
{
"value"
:
100
,
"text"
:
"a"
,
"selected"
:
true
},
{
"value"
:
200
,
"text"
:
"b"
,
"selected"
:
false
}
]
},
"radio"
:
{
"value"
:
"a"
,
"disabled"
:
false
},
"checkbox"
:
{
"value"
:
true
,
"readonly"
:
true
},
"trigger"
:
{
"value"
:
false
}
}
\ No newline at end of file
mockup/elementconfiguration.html
View file @
ede0b638
...
...
@@ -133,6 +133,25 @@
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"col-md-2"
>
<b
class=
"control-label"
>
Data reload trigger
</b>
</div>
<div
class=
"col-md-6"
>
<div
class=
"checkbox"
>
<label>
<input
type=
"checkbox"
id=
"checkbox2"
name=
"trigger"
data-load=
""
>
</label>
<p
class=
"help-block"
>
Changing the value of this checkbox triggers reload
</p>
</div>
</div>
</div>
</form>
</div>
...
...
@@ -143,7 +162,7 @@
<script
src=
"../js/qfq.debug.js"
></script>
<script
type=
"text/javascript"
>
$
(
function
()
{
var
form
=
new
QfqNS
.
QfqForm
(
"
myForm
"
,
'
none
'
,
'
none
'
);
var
form
=
new
QfqNS
.
QfqForm
(
"
myForm
"
,
'
none
'
,
'
none
'
,
'
api/form_refresh.json
'
);
QfqNS
.
Log
.
level
=
0
;
$
(
"
#applyconfig
"
).
click
(
function
()
{
...
...
Write
Preview
Supports
Markdown
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