Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
8f9a20c6
Commit
8f9a20c6
authored
Jan 12, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
INTERACTION experimentation with hardcoded form/field update
parent
3588e8f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
6 deletions
+77
-6
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_form_js.js
...thTemplateItem/web_page_module/rjs_gadget_erp5_form_js.js
+75
-4
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_form_js.xml
...hTemplateItem/web_page_module/rjs_gadget_erp5_form_js.xml
+2
-2
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_form_js.js
View file @
8f9a20c6
...
...
@@ -111,7 +111,7 @@
.
setState
({
// erp5 document is an instance of a document referenced by jio_key
erp5_document
:
undefined
,
erp5_document
_json
:
undefined
,
jio_key
:
undefined
,
// form definition holds positioning of fields
form_definition
:
undefined
,
...
...
@@ -156,7 +156,7 @@
}
return
this
.
changeState
({
erp5_document
:
options
.
erp5_document
,
erp5_document
_json
:
JSON
.
stringify
(
options
.
erp5_document
)
,
form_definition
:
options
.
form_definition
,
jio_key
:
options
.
jio_key
,
hash
:
hash
,
...
...
@@ -167,7 +167,7 @@
})
.
onStateChange
(
function
(
modification_dict
)
{
var
erp5_document
=
this
.
state
.
erp5_document
,
var
erp5_document
=
JSON
.
parse
(
this
.
state
.
erp5_document_json
)
,
form_definition
=
this
.
state
.
form_definition
,
rendered_document
=
erp5_document
.
_embedded
.
_view
,
group_list
=
form_definition
.
group_list
,
...
...
@@ -286,6 +286,77 @@
return
result
;
});
},
{
mutex
:
'
changestate
'
});
},
{
mutex
:
'
changestate
'
})
.
declareAcquiredMethod
(
"
notifyChange
"
,
"
notifyChange
"
)
.
declareJob
(
"
updateForm
"
,
function
()
{
var
context
=
this
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
delay
(
50
);
})
.
push
(
function
()
{
return
context
.
getContent
();
})
.
push
(
function
(
content
)
{
var
quantity
=
content
.
field_my_quantity
,
title
=
'
foo
'
+
quantity
+
'
title
'
,
erp5_document
=
JSON
.
parse
(
context
.
state
.
erp5_document_json
);
// console.log(context.state);
erp5_document
.
_embedded
.
_view
.
my_title
.
default
=
title
;
return
context
.
changeState
({
erp5_document_json
:
JSON
.
stringify
(
erp5_document
)
});
});
})
/*
.declareJob("updateHeader", function (param_list) {
var context = this;
return new RSVP.Queue()
.push(function () {
return RSVP.delay(200);
})
.push(function () {
return context.notifyChange.call(context, param_list);
});
})
*/
/* can do any declarative
add a gadget in the page. Gadget "not rendered", ie no label, no dom
gadget call erp5_form.addInteraction('field_my_quantity', 'notifyChange')
problem: impossible from JS to hardcode this field key (formulator can change)
should notifyChange provides the getContent value of the field?
should the form check the subgadget scope OR the getContent field key
scope is no guarantee to be as the field key
developper doesn't know anything also about formulator key generation algorithm (black box)
shoud the update field
how to dynamically add/remove on field
how to render only the needed field?
listbox: how not to reload the lines? how to reload the lines on demand?
*/
.
allowPublicAcquisition
(
"
notifyChange
"
,
function
(
param_list
,
scope
)
{
// Trigger update field if needed
var
context
=
this
;
if
(
scope
===
'
field_my_quantity
'
)
{
context
.
updateForm
();
}
// return context.updateHeader(param_list);
return
context
.
notifyChange
.
call
(
context
,
param_list
);
/*
return this.getContent()
.push(function (content) {
console.log(scope, content);
return context.notifyChange.call(context, param_list);
});
*/
});
}(
window
,
document
,
rJS
,
RSVP
));
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_form_js.xml
View file @
8f9a20c6
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
964.5
8561.19908.14080
</string>
</value>
<value>
<string>
964.5
0178.15987.24217
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
151
6274548.88
</float>
<float>
151
5763409.77
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
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