Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
erp5
Commits
3abd9c03
Commit
3abd9c03
authored
Oct 28, 2016
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_web_renderjs_ui] Reimplement gadget field
Use new renderJS job to simplify the code
parent
caee5344
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
82 deletions
+60
-82
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_gadgetfield_html.html
...tem/web_page_module/rjs_gadget_erp5_gadgetfield_html.html
+0
-1
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_gadgetfield_html.xml
...Item/web_page_module/rjs_gadget_erp5_gadgetfield_html.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_gadgetfield_js.js
...ateItem/web_page_module/rjs_gadget_erp5_gadgetfield_js.js
+56
-77
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_gadgetfield_js.xml
...teItem/web_page_module/rjs_gadget_erp5_gadgetfield_js.xml
+2
-2
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_gadgetfield_html.html
View file @
3abd9c03
...
...
@@ -14,6 +14,5 @@
</head>
<body>
<div></div>
</body>
</html>
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_gadgetfield_html.xml
View file @
3abd9c03
...
...
@@ -234,7 +234,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
46.44927.40202.16725
</string>
</value>
<value>
<string>
9
54.45675.44850.53452
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>
14
53306099
.89
</float>
<float>
14
77661832
.89
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_gadgetfield_js.js
View file @
3abd9c03
/*global window, rJS,
RSVP
*/
/*global window, rJS,
document
*/
/*jslint nomen: true, indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
,
RSVP
)
{
(
function
(
window
,
rJS
,
document
)
{
"
use strict
"
;
function
enqueueRender
(
gadget
,
options
)
{
var
loop_deferred
=
gadget
.
props
.
loop_defer
,
new_loop_deferred
=
RSVP
.
defer
();
gadget
.
props
.
loop_defer
=
new_loop_deferred
;
gadget
.
props
.
render_queue
.
push
(
function
()
{
return
gadget
.
props
.
service_deferred
.
promise
;
})
.
push
(
function
(
field_gadget
)
{
return
field_gadget
.
render
(
options
);
})
.
push
(
function
()
{
return
new_loop_deferred
.
promise
;
});
loop_deferred
.
resolve
();
}
rJS
(
window
)
.
ready
(
function
(
g
)
{
var
loop_defer
=
RSVP
.
defer
();
g
.
props
=
{
service_deferred
:
RSVP
.
defer
(),
first_render_deferred
:
RSVP
.
defer
(),
render_queue
:
new
RSVP
.
Queue
(),
loop_defer
:
loop_defer
};
g
.
props
.
render_queue
.
push
(
function
()
{
return
loop_defer
.
promise
;
});
})
// Assign the element to a variable
.
ready
(
function
(
g
)
{
return
g
.
getElement
()
.
push
(
function
(
element
)
{
g
.
props
.
element
=
element
;
});
})
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
render
"
,
function
(
options
)
{
var
gadget
=
this
;
enqueueRender
(
gadget
,
{
.
declareMethod
(
"
render
"
,
function
(
options
)
{
return
this
.
changeState
({
key
:
options
.
field_json
.
key
,
value
:
options
.
field_json
.
default
,
editable
:
options
.
field_json
.
editable
editable
:
options
.
field_json
.
editable
,
url
:
options
.
field_json
.
url
,
sandbox
:
options
.
field_json
.
sandbox
||
undefined
});
gadget
.
props
.
first_render_deferred
.
resolve
(
options
.
field_json
);
})
.
declareMethod
(
"
getContent
"
,
function
()
{
return
this
.
props
.
field_gadget
.
getContent
();
.
onStateChange
(
function
(
modification_dict
)
{
// Check if a sub gadget has to be regenerated
if
((
modification_dict
.
hasOwnProperty
(
'
url
'
))
||
(
modification_dict
.
hasOwnProperty
(
'
sandbox
'
))
||
(
modification_dict
.
hasOwnProperty
(
'
key
'
)))
{
return
this
.
deferDeclareGadget
();
}
return
this
.
deferRenderGadget
();
})
.
declareService
(
function
()
{
// Add the field in the DOM after the first render method has been called
var
gadget
=
this
,
gadget_element
=
gadget
.
props
.
element
.
querySelector
(
'
div
'
),
field_json
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
props
.
first_render_deferred
.
promise
;
})
.
push
(
function
(
result
)
{
field_json
=
result
;
return
gadget
.
declareGadget
(
field_json
.
url
,
{
scope
:
field_json
.
key
,
sandbox
:
field_json
.
sandbox
||
undefined
,
element
:
gadget_element
});
})
.
push
(
function
(
field_gadget
)
{
var
iframe
;
.
declareJob
(
'
deferDeclareGadget
'
,
function
()
{
var
div
=
document
.
createElement
(
'
div
'
),
element
=
this
.
element
,
gadget
=
this
;
/*
if (field_json.css_class) {
gadget_element.setAttribute("class", field_json.css_class);
}
// Trigger render methods
gadget
.
props
.
field_gadget
=
field_gadget
;
gadget
.
props
.
service_deferred
.
resolve
(
field_gadget
);
*/
// Clear first to DOM, append after to reduce flickering/manip
while
(
element
.
firstChild
)
{
element
.
removeChild
(
element
.
firstChild
);
}
element
.
appendChild
(
div
);
return
gadget
.
declareGadget
(
gadget
.
state
.
url
,
{
scope
:
gadget
.
state
.
key
,
sandbox
:
gadget
.
state
.
sandbox
,
element
:
div
})
.
push
(
function
()
{
return
gadget
.
deferRenderGadget
();
});
})
.
declareJob
(
'
deferRenderGadget
'
,
function
()
{
var
gadget
=
this
;
return
gadget
.
getDeclaredGadget
(
gadget
.
state
.
key
)
.
push
(
function
(
result
)
{
return
result
.
render
({
key
:
gadget
.
state
.
key
,
value
:
gadget
.
state
.
value
,
editable
:
gadget
.
state
.
editable
});
});
})
.
declareService
(
function
()
{
// Defer render execution and check errors
return
this
.
props
.
render_queue
;
.
declareMethod
(
"
getContent
"
,
function
()
{
var
gadget
=
this
;
if
(
!
gadget
.
state
.
editable
)
{
return
{};
}
return
gadget
.
getDeclaredGadget
(
gadget
.
state
.
key
)
.
push
(
function
(
result
)
{
return
result
.
getContent
();
});
}(
window
,
rJS
,
RSVP
));
});
}(
window
,
rJS
,
document
));
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_gadgetfield_js.xml
View file @
3abd9c03
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
954.5
8962.6524.44134
</string>
</value>
<value>
<string>
954.5
9037.54566.52462
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
147766
0162.48
</float>
<float>
147766
4543.13
</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