Commit 7bb9deec authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Simplify and use a form instead.

  Acquire listbox configuration from erp5 using proper API rather
  them hardcode the values over the .js
parent b38bf507
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>string:${object_url}/Base_viewDummyAsHateoas</string> </value> <value> <string>string:${object_url}/ProjectModule_viewProjectListAsHateoas</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -58,75 +58,23 @@ ...@@ -58,75 +58,23 @@
}) })
.declareMethod("render", function () { .declareMethod("render", function () {
var gadget = this, var gadget = this,
lines_limit,
projects_translation, projects_translation,
translation_list = [ translation_list = [
"Title",
"Reference",
"Status",
"Projects" "Projects"
]; ];
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return RSVP.all([
gadget.getSetting("listbox_lines_limit", 20),
window.getSettingMe(gadget)
]);
})
.push(function (settings) {
lines_limit = settings[0];
return RSVP.all([ return RSVP.all([
gadget.getDeclaredGadget('form_list'), gadget.getDeclaredGadget('form_list'),
gadget.jio_get(settings[1]), gadget.jio_getAttachment('project_module', 'view'),
gadget.getTranslationList(translation_list) gadget.getTranslationList(translation_list)
]); ])
}) })
.push(function (result) { .push(function (result) {
var destination_project_list, i, projects_translation = result[2][0];
column_list = [
['title', result[2][0]],
['reference', result[2][1]],
['Project_getNewsDict', result[2][2]]
];
projects_translation = result[2][3];
destination_project_list = "%22NULL%22%2C";
for (i in result[1].assignment_destination_project_list) {
if (result[1].assignment_destination_project_list.hasOwnProperty(i)) {
destination_project_list += "%22" + result[1].assignment_destination_project_list[i] + "%22%2C";
}
}
return result[0].render({ return result[0].render({
erp5_document: { erp5_document: result[1],
"_embedded": {"_view": {
"listbox": {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 0,
"editable_column_list": [],
"key": "slap_project_listbox",
"lines": lines_limit,
"list_method": "portal_catalog",
// XXX TODO Filter by default_strict_allocation_scope_uid="!=%s" % context.getPortalObject().portal_categories.allocation_scope.close.forever.getUid(),
"query": "urn:jio:allDocs?query=portal_type%3A%22" +
"Project" + "%22%20AND%20validation_state%3Avalidated%20AND%20" +
"relative_url%3A(" + destination_project_list + ")",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
"sort": [["title", "ascending"]],
"title": projects_translation,
"type": "ListBox"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: { form_definition: {
group_list: [[ group_list: [[
"bottom", "bottom",
......
...@@ -84,12 +84,7 @@ ...@@ -84,12 +84,7 @@
return gadget.jio_get(me); return gadget.jio_get(me);
}) })
.push(function (me) { .push(function (me) {
var i, destination_list = '"NULL",', destination_project_list = '"NULL",'; var i, destination_list = '"NULL",';
for (i in me.assignment_destination_project_list) {
if (me.assignment_destination_project_list.hasOwnProperty(i)) {
destination_project_list += '"' + me.assignment_destination_project_list[i] + '",';
}
}
for (i in me.assignment_destination_list) { for (i in me.assignment_destination_list) {
if (me.assignment_destination_list.hasOwnProperty(i)) { if (me.assignment_destination_list.hasOwnProperty(i)) {
destination_list += '"' + me.assignment_destination_list[i] + '",'; destination_list += '"' + me.assignment_destination_list[i] + '",';
...@@ -104,7 +99,7 @@ ...@@ -104,7 +99,7 @@
select_list: ['reference', 'title'] select_list: ['reference', 'title']
}), }),
gadget.jio_allDocs({ gadget.jio_allDocs({
query: 'portal_type:"Project" AND validation_state:"validated" AND relative_url:(' + destination_project_list + ')', query: 'portal_type:"Project" AND validation_state:"validated"',
sort_on: [['reference', 'ascending']], sort_on: [['reference', 'ascending']],
select_list: ['reference', 'title'] select_list: ['reference', 'title']
}), }),
......
...@@ -279,7 +279,7 @@ ...@@ -279,7 +279,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.11742.24961.22050</string> </value> <value> <string>994.62925.42961.44083</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1602255287.46</float> <float>1638836612.1</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -82,12 +82,7 @@ ...@@ -82,12 +82,7 @@
return gadget.jio_get(me); return gadget.jio_get(me);
}) })
.push(function (me) { .push(function (me) {
var i, destination_list = '"NULL",', destination_project_list = '"NULL",'; var i, destination_list = '"NULL",';
for (i in me.assignment_destination_project_list) {
if (me.assignment_destination_project_list.hasOwnProperty(i)) {
destination_project_list += '"' + me.assignment_destination_project_list[i] + '",';
}
}
for (i in me.assignment_destination_list) { for (i in me.assignment_destination_list) {
if (me.assignment_destination_list.hasOwnProperty(i)) { if (me.assignment_destination_list.hasOwnProperty(i)) {
destination_list += '"' + me.assignment_destination_list[i] + '",'; destination_list += '"' + me.assignment_destination_list[i] + '",';
...@@ -97,7 +92,7 @@ ...@@ -97,7 +92,7 @@
gadget.getDeclaredGadget('form_view'), gadget.getDeclaredGadget('form_view'),
gadget.jio_get(options.jio_key), gadget.jio_get(options.jio_key),
gadget.jio_allDocs({ gadget.jio_allDocs({
query: 'portal_type:"Project" AND validation_state:"validated" AND relative_url:(' + destination_project_list + ')', query: 'portal_type:"Project" AND validation_state:"validated"',
sort_on: [['reference', 'ascending']], sort_on: [['reference', 'ascending']],
select_list: ['reference', 'title'] select_list: ['reference', 'title']
}), }),
......
...@@ -277,7 +277,7 @@ ...@@ -277,7 +277,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.11739.65160.27938</string> </value> <value> <string>993.49407.7079.26129</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -295,7 +295,7 @@ ...@@ -295,7 +295,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1602255203.72</float> <float>1638836685.2</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -79,12 +79,7 @@ ...@@ -79,12 +79,7 @@
return gadget.jio_get(me); return gadget.jio_get(me);
}) })
.push(function (me) { .push(function (me) {
var i, destination_list = '"NULL",', destination_project_list = '"NULL",'; var i, destination_list = '"NULL",';
for (i in me.assignment_destination_project_list) {
if (me.assignment_destination_project_list.hasOwnProperty(i)) {
destination_project_list += '"' + me.assignment_destination_project_list[i] + '",';
}
}
for (i in me.assignment_destination_list) { for (i in me.assignment_destination_list) {
if (me.assignment_destination_list.hasOwnProperty(i)) { if (me.assignment_destination_list.hasOwnProperty(i)) {
destination_list += '"' + me.assignment_destination_list[i] + '",'; destination_list += '"' + me.assignment_destination_list[i] + '",';
...@@ -99,7 +94,7 @@ ...@@ -99,7 +94,7 @@
select_list: ['reference', 'title'] select_list: ['reference', 'title']
}), }),
gadget.jio_allDocs({ gadget.jio_allDocs({
query: 'portal_type:"Project" AND validation_state:"validated" AND relative_url:(' + destination_project_list + ')', query: 'portal_type:"Project" AND validation_state:"validated"',
sort_on: [['reference', 'ascending']], sort_on: [['reference', 'ascending']],
select_list: ['reference', 'title'] select_list: ['reference', 'title']
}), }),
......
...@@ -277,7 +277,7 @@ ...@@ -277,7 +277,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.11732.53320.3003</string> </value> <value> <string>993.49407.7079.26129</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -295,7 +295,7 @@ ...@@ -295,7 +295,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1602490257.93</float> <float>1638836764.88</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
# Use a script for overcome security
return [i.getDestinationProject() for i in context.objectValues(portal_type="Assignment")
if i.getDestinationProject() and i.getValidationState() == "open"]
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Person_getAssignmentDestinationProjectList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -92,7 +92,6 @@ ...@@ -92,7 +92,6 @@
<string>my_reference</string> <string>my_reference</string>
<string>my_last_name</string> <string>my_last_name</string>
<string>my_assignment_destination_list</string> <string>my_assignment_destination_list</string>
<string>my_assignment_destination_project_list</string>
<string>my_default_address_city</string> <string>my_default_address_city</string>
<string>my_default_address_region</string> <string>my_default_address_region</string>
<string>my_default_address_street_address</string> <string>my_default_address_street_address</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_doSelect</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>listbox</string>
</list>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ProjectModule_viewProjectListAsHateoas</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>ProjectModule_viewProjectListAsHateoas</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_list</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Projects</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>all_columns</string>
<string>columns</string>
<string>default_params</string>
<string>portal_types</string>
<string>selection_name</string>
<string>sort</string>
<string>style_columns</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>all_columns</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>columns</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>selection_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>sort</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>style_columns</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>all_columns</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>columns</string> </key>
<value>
<list>
<tuple>
<string>title</string>
<string>Title</string>
</tuple>
<tuple>
<string>reference</string>
<string>Reference</string>
</tuple>
<tuple>
<string>Project_getNewsDict</string>
<string>Status</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>default_params</string> </key>
<value>
<list>
<tuple>
<string>validation_state</string>
<string>validated</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_list_mode_listbox</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value>
<list>
<tuple>
<string>Instance Tree</string>
<string>Instance Tree</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>portal_types</string> </key>
<value>
<list>
<tuple>
<string>Project</string>
<string>Project</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>selection_name</string> </key>
<value> <string>project_module_hateoas_selection</string> </value>
</item>
<item>
<key> <string>sort</string> </key>
<value>
<list>
<tuple>
<string>title</string>
<string>ascending</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>style_columns</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Projects</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -15,7 +15,7 @@ def redirect(message, message_type): ...@@ -15,7 +15,7 @@ def redirect(message, message_type):
"&portal_status_message=%s" % context.Base_translateString(message)) "&portal_status_message=%s" % context.Base_translateString(message))
try: try:
context.acceptInvitation(invitation_token) context.acceptInvitation(invitation_token=invitation_token)
except ValueError as e: except ValueError as e:
return redirect(context.Base_translateString(e), "error") return redirect(context.Base_translateString(e), "error")
......
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