Commit b2eda41f authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: User can include his own organisations

parent a7b91719
<!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_person_add_organisation.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>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>contributor/person_module/1</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>cedric.le.ninivin</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_page_slap_person_add_organisation.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_erp5_page_slap_person_add_organisation_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>modification_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1455284351.46</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Slap Person Add Organisation</string> </value>
</item>
<item>
<key> <string>url_string</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) {
"use strict";
var content_type = {
Spreadsheet: 'application/x-asc-spreadsheet',
Presentation: 'application/x-asc-presentation',
Text: 'application/x-asc-text'
};
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post")
.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) {
if (content_type.hasOwnProperty(doc.portal_type)) {
doc.content_type = content_type[doc.portal_type];
}
return gadget.jio_post(doc);
})
.push(function (key) {
return gadget.notifySubmitted({message: 'New Organisation created.', status: 'success'})
.push(function () {
// Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change",
"options": {"jio_key": key, "page": "slap_controller"}});
});
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.declareMethod("render", function () {
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_title": {
"description": "The name of a document in ERP5",
"title": "Title",
"default": "",
"css_class": "",
"required": 0,
"editable": 1,
"key": "title",
"hidden": 0,
"type": "StringField"
},
"my_role": {
"description": "Role Definition",
"title": "Role",
"default": "client",
"css_class": "",
"required": 0,
"editable": 1,
"key": "role",
"hidden": 1,
"type": "StringField"
},
"my_portal_type": {
"description": "The name of a document in ERP5",
"title": "Portal Type",
"default": "Organisation",
"css_class": "",
"required": 1,
"editable": 1,
"key": "portal_type",
"hidden": 1,
"type": "StringField"
},
"my_parent_relative_url": {
"description": "",
"title": "Parent Relative Url",
"default": "organisation_module",
"css_class": "",
"required": 1,
"editable": 1,
"key": "parent_relative_url",
"hidden": 1,
"type": "StringField"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"left",
[["my_title"], ["my_role"], ["my_portal_type"], ["my_parent_relative_url"]]
]]
}
});
})
.push(function (result) {
return RSVP.all([
gadget.getUrlFor({command: 'change', options: {page: "slap_person_view"}})
]);
})
.push(function (url_list) {
return gadget.updateHeader({
page_title: "New Organisation",
selection_url: url_list[0],
submit_action: true
});
});
});
}(window, rJS, RSVP));
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<list>
<string>Manager</string>
<string>Authenticated</string>
<string>Developer</string>
<string>Owner</string>
</list>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>contributor/person_module/1</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>cedric.le.ninivin</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_page_slap_person_add_organisation.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_erp5_page_slap_person_add_organisation_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>modification_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1455284351.49</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>SlapOS Person Add Organisation JS</string> </value>
</item>
<item>
<key> <string>url_string</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -89,17 +89,27 @@
.onStateChange(function () {
var gadget = this,
i, destination_list,
column_list = [
['reference', 'Reference'],
['portal_type', 'Type']
],
organisation_column_list = [
['title', 'Title'],
['reference', 'Reference'],
['default_address_region_title', 'Region'],
['Organisation_getNewsDict', 'Status']
],
data;
return new RSVP.Queue()
.push(function () {
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
var editable = gadget.state.editable;
destination_list = "%22NULL%22%2C";
for (i in gadget.state.doc.assignment_destination_list) {
destination_list += "%22" + gadget.state.doc.assignment_destination_list[i] + "%22%2C";
}
return form_gadget.render({
erp5_document: {
"_embedded": {"_view": {
......@@ -109,7 +119,7 @@
"default": gadget.state.doc.first_name,
"css_class": "",
"required": 1,
"editable": editable,
"editable": 1,
"key": "first_name",
"hidden": 0,
"type": "StringField"
......@@ -120,7 +130,7 @@
"default": gadget.state.doc.last_name,
"css_class": "",
"required": 1,
"editable": editable,
"editable": 1,
"key": "last_name",
"hidden": 0,
"type": "StringField"
......@@ -131,7 +141,7 @@
"default": gadget.state.doc.default_email_text,
"css_class": "",
"required": 1,
"editable": editable,
"editable": 1,
"key": "default_email_text",
"hidden": 0,
"type": "StringField"
......@@ -156,6 +166,25 @@
"sort": [["reference", "ascending"]],
"title": "Logins",
"type": "ListBox"
},
"organisation_listbox": {
"column_list": organisation_column_list,
"show_anchor": 0,
"default_params": {},
"editable": 1,
"editable_column_list": [],
"key": "slap_person_organisation_listbox",
"lines": 20,
"list_method": "portal_catalog",
"query": "urn:jio:allDocs?query=portal_type%3A%22" +
"Organisation" + "%22%20AND%20role_title%3A%22Client%22%20AND%20" +
"relative_url%3A(" + destination_list + ")",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
"sort": [["reference", "ascending"]],
"title": "Organisations",
"type": "ListBox"
}
}},
"_links": {
......@@ -171,7 +200,7 @@
[["my_first_name"], ["my_last_name"], ["my_default_email_text"]]
], [
"bottom",
[["listbox"]]
[["listbox"], ["organisation_listbox"]]
]]
}
});
......@@ -186,6 +215,7 @@
gadget.getUrlFor({command: "change", options: {jio_key: me, page: "slap_person_request_certificate"}}),
gadget.getUrlFor({command: "change", options: {jio_key: me, page: "slap_person_get_token"}}),
gadget.getUrlFor({command: "change", options: {jio_key: me, page: "slap_person_add_erp5_login"}}),
gadget.getUrlFor({command: "change", options: {jio_key: me, page: "slap_person_add_organisation"}}),
gadget.getUrlFor({command: "change", options: {page: "slapos"}})
]);
})
......@@ -196,8 +226,9 @@
request_certificate_url: url_list[2],
revoke_certificate_url: url_list[1],
token_url: url_list[3],
add_url: url_list[4],
selection_url: url_list[5]
add_login_url: url_list[4],
add_organisation_url: url_list[5],
selection_url: url_list[6]
};
if (!gadget.state.editable) {
header_dict.edit_content = url_list[0];
......
......@@ -241,7 +241,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>976.3552.39636.23859</string> </value>
<value> <string>976.40553.2729.56763</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -259,7 +259,7 @@
</tuple>
<state>
<tuple>
<float>1559517473.11</float>
<float>1561422636.38</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -108,7 +108,7 @@
<value> <string encoding="cdata"><![CDATA[
CACHE MANIFEST\n
# generated on Fri, 26 Avril 2019 00:00:00 GMT+0200\n
# generated on Fri, 24 Jun 2019 00:00:00 GMT+0200\n
CACHE:\n
favicon.ico\n
font-awesome/font-awesome-webfont.eot?v=4.6.3\n
......@@ -321,6 +321,8 @@ gadget_erp5_page_slap_parameter_form.js\n
gadget_erp5_page_slap_payment_result.html\n
gadget_erp5_page_slap_person_get_token.html\n
gadget_erp5_page_slap_person_get_token.js\n
gadget_erp5_page_slap_person_add_organisation.js\n
gadget_erp5_page_slap_person_add_organisation.html\n
gadget_erp5_page_slap_person_request_certificate.html\n
gadget_erp5_page_slap_person_request_certificate.js\n
gadget_erp5_page_slap_person_revoke_certificate.html\n
......@@ -565,7 +567,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>976.8845.38902.19200</string> </value>
<value> <string>976.40547.59496.46250</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -583,7 +585,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1559518993.22</float>
<float>1561423738.11</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -40,6 +40,8 @@
['download_url', 'Download', 'download'],
// Include SlapOS specific items
['ticket_url', 'Add Ticket', 'ticket'],
['add_login_url', 'Add Login', 'plus'],
['add_organisation_url', 'Add Organisation', 'plus'],
['token_url', 'Token', 'key'],
['request_certificate_url', 'Request Certificate', 'certificate'],
['revoke_certificate_url', 'Revoke Certificate', 'ban'],
......
......@@ -216,7 +216,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>ERP5TypeTestCase</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.62049.17150.785</string> </value>
<value> <string>976.9867.41515.40260</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1558489401.94</float>
<float>1561421021.85</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -79,6 +79,8 @@ web_page_module/rjs_gadget_erp5_page_slap_parameter_form_js
web_page_module/rjs_gadget_erp5_page_slap_payment_result_html
web_page_module/rjs_gadget_erp5_page_slap_person_add_erp5_login_html
web_page_module/rjs_gadget_erp5_page_slap_person_add_erp5_login_js
web_page_module/rjs_gadget_erp5_page_slap_person_add_organisation_html
web_page_module/rjs_gadget_erp5_page_slap_person_add_organisation_js
web_page_module/rjs_gadget_erp5_page_slap_person_get_token_html
web_page_module/rjs_gadget_erp5_page_slap_person_get_token_js
web_page_module/rjs_gadget_erp5_page_slap_person_request_certificate_html
......
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