Commit 1a032115 authored by Roque's avatar Roque

erp5_officejs: gadgets cleanup

parent 3f82e201
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Add Post Document</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_ojs_add_post.js"></script>
</head>
<body>
</body>
</html>
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Blob) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
var gadget = this, doc_id;
return RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getSetting('portal_type'),
gadget.getSetting('parent_relative_url')
]);
})
.push(function (result) {
var doc = {
title: "Untitled Document",
portal_type: result[0],
parent_relative_url: result[1]
}, key, doc_key;
for (key in options) {
if (options.hasOwnProperty(key)) {
if (key.startsWith("my_")) {
doc_key = key.replace("my_", "");
doc[doc_key] = options[key];
}
}
}
return gadget.jio_post(doc);
})
.push(function (id) {
return gadget.redirect({
command: 'display',
options: {
jio_key: id,
editable: true
}
});
});
});
}(window, rJS, RSVP, Blob));
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Posts List</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_ojs_post_list.js"></script>
</head>
<body>
<div data-gadget-url="gadget_erp5_pt_form_list.html" data-gadget-scope="form_list"></div>
</body>
</html>
/*global window, document, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, document, rJS, RSVP) {
"use strict";
//TODO rename this gadget as "front or main" gadget
//check if this can be done by the controller and use that gadget instead
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("isDesktopMedia", "isDesktopMedia")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("getSetting", "getSetting")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
var gadget = this,
default_view = "jio_view",
common_utils_gadget_url = "gadget_officejs_common_utils.html",
child_gadget_url = 'gadget_erp5_pt_form_list.html',
portal_type,
//In a future, the post list will be within a thread. For now:
fake_thread_uid = "thread-" + ("0000" + ((Math.random() * Math.pow(36, 4)) | 0).toString(36)).slice(-4);
return RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getSetting('parent_portal_type'),
gadget.declareGadget("gadget_officejs_common_utils.html")
]);
})
.push(function (result) {
portal_type = result[0];
return result[1].getFormDefinition(result[0], default_view, {source_reference: fake_thread_uid});
})
.push(function (form_definition) {
return gadget.changeState({
jio_key: options.jio_key,
portal_type: portal_type,
//TODO child_gadget_url should be decided in utils.getFormDefinition based on form type
child_gadget_url: child_gadget_url,
form_definition: form_definition,
form_type: 'list',
editable: false,
view: default_view,
front_page: true
});
});
})
.onStateChange(function () {
var fragment = document.createElement('div'),
gadget = this,
options;
while (this.element.firstChild) {
this.element.removeChild(this.element.firstChild);
}
this.element.appendChild(fragment);
return gadget.declareGadget("gadget_officejs_form_view.html", {element: fragment,
scope: 'form_view'})
.push(function (form_view_gadget) {
return form_view_gadget.render(gadget.state);
});
})
.declareMethod("triggerSubmit", function () {
var argument_list = arguments;
return this.getDeclaredGadget('form_view')
.push(function (view_gadget) {
return view_gadget.getDeclaredGadget('fg');
})
.push(function (gadget) {
return gadget.triggerSubmit.apply(gadget, argument_list);
});
});
}(window, document, rJS, RSVP));
\ No newline at end of file
......@@ -83,7 +83,7 @@
});
})
.declareMethod("getAllActions", function (portal_type, action_category) {
.declareMethod("getAllActions", function (portal_type, action_category, options) {
var gadget = this,
action_info_dict = {views: {}, actions: {}},
query = 'portal_type: "Action Information" AND parent_relative_url: "portal_types/' + portal_type + '"';
......@@ -108,6 +108,7 @@
}
action_settings_list.push({
page: page,
jio_key: options.jio_key,
title: action_doc.title,
action: action_doc.reference,
reference: action_doc.reference,
......@@ -128,7 +129,7 @@
}
//if portal_type has both view and jio_view, remove classic 'view'
//TODO use action type instead of reference
//is the 'classic view' action needed at all here? -maybe don't add it in appcache manifest
//is the 'classic view' action needed at all here? -maybe it shouldn't be added in appcache manifest
if (action_info_dict.views.hasOwnProperty("view") && action_info_dict.views.hasOwnProperty("jio_view")) {
delete action_info_dict.views.view;
}
......@@ -148,7 +149,7 @@
return options.portal_type;
})
.push(function (portal_type) {
return gadget.getAllActions(portal_type, view_categories[0]);
return gadget.getAllActions(portal_type, view_categories[0], options);
})
.push(function (action_info_dict) {
return RSVP.all([
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.39736.64982.14762</string> </value>
<value> <string>975.40561.441.8482</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1557489660.39</float>
<float>1557499265.0</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.40675.7475.8960</string> </value>
<value> <string>975.40721.35496.30668</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1557496526.16</float>
<float>1557500271.45</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment