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
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Leo Le Bouter
erp5
Commits
4dfd0c6e
Commit
4dfd0c6e
authored
Jan 21, 2016
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_web_renderjs_ui] Ensure that iframe GadgetField are correctly loaded with their data
parent
533a81c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
58 deletions
+83
-58
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
+4
-3
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
+79
-55
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_gadgetfield_html.xml
View file @
4dfd0c6e
...
...
@@ -121,6 +121,7 @@
\n
</head>
\n
<body>
\n
<div></div>
\n
</body>
\n
</html>
\n
...
...
@@ -246,7 +247,7 @@
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
xiaowu
</string>
</value>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
...
...
@@ -260,7 +261,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
94
0.17402.52950.42820
</string>
</value>
<value>
<string>
94
6.44927.40202.16725
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -278,7 +279,7 @@
</tuple>
<state>
<tuple>
<float>
14
21153002.1
9
</float>
<float>
14
53306099.8
9
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_gadgetfield_js.xml
View file @
4dfd0c6e
...
...
@@ -99,45 +99,43 @@
</item>
<item>
<key>
<string>
text_content
</string>
</key>
<value>
<string>
/*global window, rJS, RSVP
, document
*/\n
<value>
<string>
/*global window, rJS, RSVP*/\n
/*jslint nomen: true, indent: 2, maxerr: 3 */\n
(function (window,
document,
rJS, RSVP) {\n
(function (window, rJS, RSVP) {\n
"use strict";\n
function createGadget(gadget) {\n
var gadget_element = document.createElement("div"),\n
suboptions = {},\n
field_json = gadget.props.field_json;\n
suboptions.value = field_json.default;\n
suboptions.key = field_json.key;\n
suboptions.editable = field_json.editable;\n
gadget.props.element.appendChild(gadget_element);\n
return new RSVP.Queue()\n
\n
function enqueueRender(gadget, options) {\n
var loop_deferred = gadget.props.loop_defer,\n
new_loop_deferred = RSVP.defer();\n
\n
gadget.props.loop_defer = new_loop_deferred;\n
\n
gadget.props.render_queue\n
.push(function () {\n
return gadget.declareGadget(field_json.url, {\n
scope: field_json.key,\n
sandbox: field_json.sandbox,\n
element: gadget_element\n
});\n
return gadget.props.service_deferred.promise;\n
})\n
.push(function (field_gadget) {\n
var iframe;\n
gadget.props.field_gadget = field_gadget;\n
if (field_json.css_class) {\n
gadget_element.setAttribute("class", field_json.css_class);\n
}\n
if (field_json.sandbox === "iframe") {\n
iframe = gadget_element.querySelector("iframe");\n
iframe.style.width = "100%";\n
iframe.style.height = "100%";\n
}\n
if (field_gadget.render !== undefined) {\n
return field_gadget.render(suboptions);\n
}\n
return field_gadget.render(options);\n
})\n
.push(function () {\n
return new_loop_deferred.promise;\n
});\n
loop_deferred.resolve();\n
}\n
\n
rJS(window)\n
.ready(function (g) {\n
g.props = {};\n
var loop_defer = RSVP.defer();\n
g.props = {\n
service_deferred: RSVP.defer(),\n
first_render_deferred: RSVP.defer(),\n
render_queue: new RSVP.Queue(),\n
loop_defer: loop_defer\n
};\n
g.props.render_queue\n
.push(function () {\n
return loop_defer.promise;\n
});\n
})\n
// Assign the element to a variable\n
.ready(function (g) {\n
...
...
@@ -151,32 +149,58 @@
/////////////////////////////////////////////////////////////////\n
.declareMethod("render", function (options) {\n
var gadget = this;\n
gadget.props.field_json = options.field_json;\n
if (gadget.props.field_gadget !== undefined) {\n
if (gadget.props.field_gadget.render !== undefined) {\n
return gadget.props.field_gadget.render({"key" : options.field_json.key,\n
"value" : options.field_json.default,\n
"editable" : options.field_json.editable});\n
}\n
} else if (gadget.props.field_json.sandbox !== "iframe") {\n
if (gadget.props.field_json.sandbox === "") {\n
gadget.props.field_json.sandbox = "public";\n
}\n
return createGadget(gadget);\n
}\n
\n
enqueueRender(gadget, {\n
key: options.field_json.key,\n
value: options.field_json.default,\n
editable: options.field_json.editable\n
});\n
gadget.props.first_render_deferred.resolve(options.field_json);\n
})\n
\n
.declareMethod("getContent", function () {\n
return this.props.field_gadget.getContent();\n
})\n
\n
.declareService(function () {\n
var gadget = this;\n
if (gadget.props.field_gadget === undefined) {\n
return createGadget(gadget);\n
}\n
// Add the field in the DOM after the first render method has been called\n
var gadget = this,\n
gadget_element = gadget.props.element.querySelector(\'div\'),\n
field_json;\n
return new RSVP.Queue()\n
.push(function () {\n
return gadget.props.first_render_deferred.promise;\n
})\n
.push(function (result) {\n
field_json = result;\n
return gadget.declareGadget(field_json.url, {\n
scope: field_json.key,\n
sandbox: field_json.sandbox,\n
element: gadget_element\n
});\n
})\n
.push(function (field_gadget) {\n
var iframe;\n
if (field_json.css_class) {\n
gadget_element.setAttribute("class", field_json.css_class);\n
}\n
if (field_json.sandbox === "iframe") {\n
iframe = gadget_element.querySelector("iframe");\n
iframe.style.width = "100%";\n
iframe.style.height = "100%";\n
}\n
// Trigger render methods\n
gadget.props.field_gadget = field_gadget;\n
gadget.props.service_deferred.resolve(field_gadget);\n
});\n
})\n
.declareMethod("getContent", function () {\n
if (this.props.field_gadget.getContent) {\n
return this.props.field_gadget.getContent();\n
}\n
\n
\n
.declareService(function () {\n
// Defer render execution and check errors\n
return this.props.render_queue;\n
});\n
}(window,
document,
rJS, RSVP));\n
}(window, rJS, RSVP));\n
</string>
</value>
</item>
<item>
...
...
@@ -298,7 +322,7 @@
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
xiaowu
</string>
</value>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
...
...
@@ -312,7 +336,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
94
0.57981.32712.11997
</string>
</value>
<value>
<string>
94
8.39131.50045.63214
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -330,7 +354,7 @@
</tuple>
<state>
<tuple>
<float>
14
23588896.63
</float>
<float>
14
53310168.81
</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