Commit c1aeddbb authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Add fields to user edit his address.

  Replace String Field by a selection with the list of Countries available on ERP5,
  so it is consitent with general ERP5 Implementation
parent 8c8851c1
...@@ -111,13 +111,21 @@ ...@@ -111,13 +111,21 @@
"Logins", "Logins",
"Organisations", "Organisations",
"Your Account", "Your Account",
"Data updated." "Data updated.",
"Address",
"Postal Code",
"Telephone",
"City",
"Country"
]; ];
return new RSVP.Queue() return gadget.getSetting("hateoas_url")
.push(function () { .push(function (url) {
return RSVP.all([ return RSVP.all([
gadget.getDeclaredGadget('form_view'), gadget.getDeclaredGadget('form_view'),
gadget.getTranslationList(translation_list) gadget.getTranslationList(translation_list),
gadget.jio_getAttachment("portal_categories/region",
url + "/portal_categories/region/Category_getCategoryChildTranslatedCompactTitleItemListAsJSON")
]); ]);
}) })
.push(function (result) { .push(function (result) {
...@@ -125,6 +133,7 @@ ...@@ -125,6 +133,7 @@
gadget.message_translation = result[1][11]; gadget.message_translation = result[1][11];
var form_gadget = result[0], var form_gadget = result[0],
i, i,
region_list = result[2],
destination_list, destination_list,
column_list = [ column_list = [
['reference', result[1][0]], ['reference', result[1][0]],
...@@ -217,6 +226,62 @@ ...@@ -217,6 +226,62 @@
"sort": [["reference", "ascending"]], "sort": [["reference", "ascending"]],
"title": result[1][9], "title": result[1][9],
"type": "ListBox" "type": "ListBox"
},
"my_default_telephone_coordinate_text": {
"description": "",
"title": result[1][14],
"default": gadget.state.doc.default_telephone_coordinate_text,
"css_class": "",
"required": 0,
"editable": 1,
"key": "default_telephone_coordinate_text",
"hidden": 0,
"type": "StringField"
},
"my_default_address_street_address": {
"description": "",
"title": result[1][12],
"default": gadget.state.doc.default_address_street_address,
"css_class": "",
"required": 1,
"editable": 1,
"key": "default_address_street_address",
"hidden": 0,
"type": "TextAreaField"
},
"my_default_address_zip_code": {
"description": "",
"title": result[1][13],
"default": gadget.state.doc.default_address_zip_code,
"css_class": "",
"required": 1,
"editable": 1,
"key": "default_address_zip_code",
"hidden": 0,
"type": "StringField"
},
"my_default_address_city": {
"description": "",
"title": result[1][15],
"default": gadget.state.doc.default_address_city,
"css_class": "",
"required": 1,
"editable": 1,
"key": "default_address_city",
"hidden": 0,
"type": "StringField"
},
"my_default_address_region": {
"description": "",
"title": result[1][16],
"default": gadget.state.doc.default_address_region,
"css_class": "",
"items": region_list,
"required": 0,
"editable": 1,
"key": "default_address_region",
"hidden": 0,
"type": "ListField"
} }
}}, }},
"_links": { "_links": {
...@@ -229,7 +294,10 @@ ...@@ -229,7 +294,10 @@
form_definition: { form_definition: {
group_list: [[ group_list: [[
"left", "left",
[["my_first_name"], ["my_last_name"], ["my_default_email_text"]] [["my_first_name"], ["my_last_name"], ["my_default_email_text"], ['my_default_telephone_coordinate_text']]
], [
"right",
[["my_default_address_street_address"], ["my_default_address_zip_code"], ["my_default_address_city"], ["my_default_address_region"]]
], [ ], [
"bottom", "bottom",
[["listbox"], ["organisation_listbox"]] [["listbox"], ["organisation_listbox"]]
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>982.32663.26530.37700</string> </value> <value> <string>983.33586.34084.36078</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1584299335.69</float> <float>1588096504.89</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
import json
if context.getPortalType() not in ("Category", "Base Category"):
return json.dumps([])
return json.dumps(context.getCategoryChildTranslatedCompactTitleItemList(
sort_id='translated_short_title',
checked_permission='View',
filter_node=1))
<?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></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Category_getCategoryChildTranslatedCompactTitleItemListAsJSON</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -93,6 +93,12 @@ ...@@ -93,6 +93,12 @@
<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_assignment_destination_project_list</string>
<string>my_default_address_city</string>
<string>my_default_address_region</string>
<string>my_default_address_street_address</string>
<string>my_default_address_zip_code</string>
<string>my_career_subordination_title</string>
<string>my_default_telephone_coordinate_text</string>
</list> </list>
</value> </value>
</item> </item>
......
<?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/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_career_subordination_title</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>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>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_subordination_title</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Career_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</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/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_default_address_city</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>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>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_city</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Address_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</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/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_default_address_region</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>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>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</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/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_default_address_street_address</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>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>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_street_address</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Address_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</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/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_default_address_zip_code</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>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>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_zip_code</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Address_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</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>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_default_telephone_coordinate_text</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>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>
<item>
<key> <string>title</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_telephone_coordinate_text</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewBaseFieldLibrary</string> </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>Default Telephone</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>string:</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -86,7 +86,15 @@ ...@@ -86,7 +86,15 @@
</div><br/> </div><br/>
<div class="ui-field-contain"> <div class="ui-field-contain">
<label i18n:domain="ui" i18n:translate="" >Country</label> <label i18n:domain="ui" i18n:translate="" >Country</label>
<div><input type="text" name="default_address_country" value="" required=""></div> <div>
<select name="default_address_region" required="">
<tal:block tal:repeat="item python: context.portal_categories.region.getCategoryChildTranslatedCompactTitleItemList(sort_id='translated_short_title', checked_permission='View', filter_node=1)">
<option tal:attributes="value python: item[1]">
<tal:block tal:replace="python: item[0]"> Title </tal:block>
</option>
</tal:block>
</select>
</div>
</div><br/> </div><br/>
</div> </div>
<div class="bottom"> <div class="bottom">
......
...@@ -44,6 +44,36 @@ ...@@ -44,6 +44,36 @@
<td></td> <td></td>
</tr> </tr>
<tr>
<td>assertElementPresent</td>
<td>//label[text()="Telephone"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//label[text()="Address"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//label[text()="Postal Code"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//label[text()="City"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//label[text()="Country"]</td>
<td></td>
</tr>
<tr> <tr>
<td colspan="3"><b> Rename user to DEMO A </b></td> <td colspan="3"><b> Rename user to DEMO A </b></td>
</tr> </tr>
...@@ -66,12 +96,86 @@ ...@@ -66,12 +96,86 @@
<td>demoA@nexedi.com</td> <td>demoA@nexedi.com</td>
</tr> </tr>
<!-- Perform an intermediate save to ensure we can edit partial values -->
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/save" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/save" />
<tr>
<td>type</td>
<td>//textarea[@id="default_address_street_address"]</td>
<td>My New Address</td>
</tr>
<tr>
<td>type</td>
<td>//input[@id="default_address_city"]</td>
<td>My New City</td>
</tr>
<tr>
<td>type</td>
<td>//input[@id="default_address_zip_code"]</td>
<td>99999</td>
</tr>
<tr>
<td>type</td>
<td>//input[@id="default_telephone_coordinate_text"]</td>
<td>+55 0192182812</td>
</tr>
<tr>
<td>select</td>
<td>//select[@id="default_address_region"]</td>
<td>Brazil</td>
</tr>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/save" />
<!-- access somewhere else -->
<tal:block define="menu_item python: 'Sites'; header menu_item">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/access_menu_item" />
</tal:block>
<tal:block define="person_name python: 'DEMO A DEMO B'"> <tal:block define="person_name python: 'DEMO A DEMO B'">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/access_menu_item_account" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/access_menu_item_account" />
</tal:block> </tal:block>
<tr>
<td>waitForElementPresent</td>
<td>//input[@id="default_address_city" and @value="My New City"]</td>
<td></td>
</tr>
<tr>
<td>verifyValue</td>
<td>//textarea[@id="default_address_street_address"]</td>
<td>My New Address</td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//input[@id="default_address_city" and @value="My New City"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//input[@id="default_address_zip_code" and @value="99999"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//input[@id="default_telephone_coordinate_text" and @value="+55 0192182812"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//select[@id="default_address_region"]/option[text()="Brazil" and @selected="selected"]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" />
</tbody></table> </tbody></table>
......
...@@ -131,8 +131,8 @@ ...@@ -131,8 +131,8 @@
<td>Paris</td> <td>Paris</td>
</tr> </tr>
<tr> <tr>
<td>type</td> <td>select</td>
<td>//input[@name='default_address_country']</td> <td>//select[@name='default_address_region']</td>
<td>France</td> <td>France</td>
</tr> </tr>
<tr> <tr>
......
...@@ -131,8 +131,8 @@ ...@@ -131,8 +131,8 @@
<td>Paris</td> <td>Paris</td>
</tr> </tr>
<tr> <tr>
<td>type</td> <td>select</td>
<td>//input[@name='default_address_country']</td> <td>//select[@name='default_address_region']</td>
<td>France</td> <td>France</td>
</tr> </tr>
<tr> <tr>
......
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