Commit 2c603b2c authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Add gadget to generate a invitation link to an Organisation

parent 7e382c9b
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Add Text Document</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_slap_organisation_get_invitation_link.js"></script>
</head>
<body>
<form class="save_form ui-body-c" novalidate>
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button>
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="form_view"
data-gadget-sandbox="public">
</div>
</form>
</body>
</html>
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.allowPublicAcquisition('notifySubmit', function () {
return this.triggerSubmit();
})
.onEvent('submit', function () {
var gadget = this;
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
return form_gadget.getContent();
})
.push(function (doc) {
return gadget.getSetting("hateoas_url")
.push(function (url) {
return gadget.jio_getAttachment(doc.relative_url,
url + doc.relative_url + "/Base_getInvitationLink");
})
.push(function (result) {
return gadget.notifySubmitted({message: "New Invitation link generated.", status: 'success'})
.push(function () {
// Workaround, find a way to open document without break gadget.
result.jio_key = doc.relative_url;
return gadget.render(result);
});
});
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.declareMethod("render", function (options) {
var gadget = this;
return RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getDeclaredGadget('form_view')
]);
})
.push(function (result) {
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"my_relative_url": {
"description": "",
"title": "Parent Relative Url",
"default": options.jio_key,
"css_class": "",
"required": 1,
"editable": 1,
"key": "relative_url",
"hidden": 1,
"type": "StringField"
},
"my_invitation_link": {
"description": "",
"title": "Your Invitation Link",
"default": options.invitation_link,
"css_class": "",
"required": 1,
"editable": 0,
"key": "invitation_link",
"hidden": (options.invitation_link === undefined) ? 1: 0,
"type": "StringField"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"center",
[["my_invitation_link"], ["my_relative_url"]]
]]
}
});
})
.push(function () {
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'})
]);
})
.push(function (url_list) {
var header_dict = {
page_title: "Generate New Invitation Link",
submit_action: true,
selection_url: url_list[0]
};
return gadget.updateHeader(header_dict);
});
});
}(window, rJS, RSVP));
\ No newline at end of file
...@@ -259,6 +259,8 @@ gadget_erp5_page_slap_add_network.html\n ...@@ -259,6 +259,8 @@ gadget_erp5_page_slap_add_network.html\n
gadget_erp5_page_slap_add_network.js\n gadget_erp5_page_slap_add_network.js\n
gadget_erp5_page_slap_add_organisation.html\n gadget_erp5_page_slap_add_organisation.html\n
gadget_erp5_page_slap_add_organisation.js\n gadget_erp5_page_slap_add_organisation.js\n
gadget_erp5_page_slap_organisation_get_invitation_link.js\n
gadget_erp5_page_slap_organisation_get_invitation_link.html\n
gadget_erp5_page_slap_add_project.html\n gadget_erp5_page_slap_add_project.html\n
gadget_erp5_page_slap_add_project.js\n gadget_erp5_page_slap_add_project.js\n
gadget_erp5_page_slap_add_related_event.html\n gadget_erp5_page_slap_add_related_event.html\n
...@@ -569,7 +571,7 @@ NETWORK:\n ...@@ -569,7 +571,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>976.40663.4126.24849</string> </value> <value> <string>976.40666.4477.59699</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -587,7 +589,7 @@ NETWORK:\n ...@@ -587,7 +589,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1561428124.08</float> <float>1562033682.52</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -17,6 +17,8 @@ web_page_module/rjs_gadget_erp5_page_slap_add_network_html ...@@ -17,6 +17,8 @@ web_page_module/rjs_gadget_erp5_page_slap_add_network_html
web_page_module/rjs_gadget_erp5_page_slap_add_network_js web_page_module/rjs_gadget_erp5_page_slap_add_network_js
web_page_module/rjs_gadget_erp5_page_slap_add_organisation_html web_page_module/rjs_gadget_erp5_page_slap_add_organisation_html
web_page_module/rjs_gadget_erp5_page_slap_add_organisation_js web_page_module/rjs_gadget_erp5_page_slap_add_organisation_js
web_page_module/rjs_gadget_erp5_page_slap_organisation_get_invitation_link_html
web_page_module/rjs_gadget_erp5_page_slap_organisation_get_invitation_link_js
web_page_module/rjs_gadget_erp5_page_slap_add_project_html web_page_module/rjs_gadget_erp5_page_slap_add_project_html
web_page_module/rjs_gadget_erp5_page_slap_add_project_js web_page_module/rjs_gadget_erp5_page_slap_add_project_js
web_page_module/rjs_gadget_erp5_page_slap_add_related_event_html web_page_module/rjs_gadget_erp5_page_slap_add_related_event_html
......
...@@ -71,6 +71,8 @@ web_page_module/rjs_gadget_erp5_page_slap_load_schema_html ...@@ -71,6 +71,8 @@ web_page_module/rjs_gadget_erp5_page_slap_load_schema_html
web_page_module/rjs_gadget_erp5_page_slap_load_schema_js web_page_module/rjs_gadget_erp5_page_slap_load_schema_js
web_page_module/rjs_gadget_erp5_page_slap_network_list_html web_page_module/rjs_gadget_erp5_page_slap_network_list_html
web_page_module/rjs_gadget_erp5_page_slap_network_list_js web_page_module/rjs_gadget_erp5_page_slap_network_list_js
web_page_module/rjs_gadget_erp5_page_slap_organisation_get_invitation_link_html
web_page_module/rjs_gadget_erp5_page_slap_organisation_get_invitation_link_js
web_page_module/rjs_gadget_erp5_page_slap_organisation_view_html web_page_module/rjs_gadget_erp5_page_slap_organisation_view_html
web_page_module/rjs_gadget_erp5_page_slap_organisation_view_js web_page_module/rjs_gadget_erp5_page_slap_organisation_view_js
web_page_module/rjs_gadget_erp5_page_slap_parameter_form_css web_page_module/rjs_gadget_erp5_page_slap_parameter_form_css
......
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