Commit f324043a authored by Guillaume Hervier's avatar Guillaume Hervier Committed by Thomas Gambier

Add/Fix URL columns on some views

I added and fixed some URL columns on some views:
- `slapos_cloud/ComputerUsage_view`
- `slapos_cloud/HostingSubscription_view`

The goal is to make the process to look for the needed informations faster by reducing clicks between views on listbox objects, by making some changes such as clicking on an object name on a column should redirect to the object view page instead of the row's object view page.

Additionally, these changes are made to be compatible with the RenderJS UI.

As this is not the default behaviour in ERP5, it may sound counter-intuitive, but this special behaviour is made to improve efficiency/productivity over intuitivity.

Personally, I wondered about having some "compromise" which is having the "Plane" icon on these columns beside the content to clearly indicate that this icon will redirect to the object's view (as the current "Plane icon" behaviour in ERP5)

/reviewed-on nexedi/slapos.core!89
parents b8d5e234 cb1e6dd7
partition = context if brain is None:
brain = context
software_instance_list = partition.getAggregateRelatedValueList(portal_type=["Software Instance"]) software_instance = brain.getAggregateRelatedValue(portal_type=["Software Instance"])
for si in software_instance_list: if software_instance is None:
obj = si.getObject() return None
hosting_url = obj.getSpecialise()
if hosting_url: hosting_subscription = software_instance.getSpecialiseValue()
return "%s?editable_mode:int=1" % hosting_url
if url_dict: # If RenderJS UI
jio_key = hosting_subscription.getRelativeUrl()
return {
'command': 'push_history',
'view_kw': {
'view': 'view',
'jio_key': jio_key,
},
'options': {
'jio_key': jio_key
},
}
else:
return hosting_subscription.absolute_url()
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>**kw</string> </value> <value> <string>url_dict=False, brain=None, selection=None, selection_name=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
partition = context if brain is None:
brain = context
software_instance_list = partition.getAggregateRelatedValueList(portal_type=["Software Instance"]) software_instance = brain.getAggregateRelatedValue(portal_type=["Software Instance"])
for si in software_instance_list: if software_instance is None:
obj = si.getObject() return None
return "%s?editable_mode:int=1" % obj.getRelativeUrl()
if url_dict: # If RenderJS UI
jio_key = software_instance.getRelativeUrl()
return {
'command': 'push_history',
'view_kw': {
'view': 'view',
'jio_key': jio_key,
'editable': 'true',
},
'options': {
'jio_key': jio_key
},
}
else:
return software_instance.absolute_url()
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>**kw</string> </value> <value> <string>url_dict=False, brain=None, selection=None, selection_name=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
partition = context
si = partition.getAggregateRelatedValue(portal_type=["Software Instance", "Slave Instance"])
if si:
person = si.getSpecialiseValue().getDestinationSectionValue()
return '<a href="%s?editable_mode:int=1">%s</a>' % (person.getRelativeUrl(), person.getTitle())
instance = context.getAggregateRelatedValue(portal_type=["Software Instance"])
if instance is None:
return None
owner = instance.getSpecialiseValue().getDestinationSectionValue()
return owner.getTitle()
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ComputerPartition_getOwnerAsHtml</string> </value> <value> <string>ComputerPartition_getOwnerName</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
if brain is None:
brain = context
instance = brain.getAggregateRelatedValue(portal_type=["Software Instance"])
if instance is None:
return None
owner = instance.getSpecialiseValue().getDestinationSectionValue()
if url_dict: # If RenderJS UI
jio_key = owner.getRelativeUrl()
return {
'command': 'push_history',
'view_kw': {
'view': 'view',
'jio_key': jio_key,
},
'options': {
'jio_key': jio_key
},
}
else:
return owner.absolute_url()
...@@ -50,11 +50,11 @@ ...@@ -50,11 +50,11 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>**kw</string> </value> <value> <string>url_dict=False, brain=None, selection=None, selection_name=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ComputerPartition_getUsageReportUrl</string> </value> <value> <string>ComputerPartition_getOwnerUrl</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -95,7 +95,6 @@ ...@@ -95,7 +95,6 @@
<string>listbox_usage</string> <string>listbox_usage</string>
<string>my_busy_computer_partition_list_creation_date</string> <string>my_busy_computer_partition_list_creation_date</string>
<string>my_busy_computer_partition_list_status</string> <string>my_busy_computer_partition_list_status</string>
<string>my_busy_computer_partition_list_owner_title</string>
<string>listbox_installation_status</string> <string>listbox_installation_status</string>
<string>my_busy_computer_partition_list_hosting_subscription_title</string> <string>my_busy_computer_partition_list_hosting_subscription_title</string>
<string>my_busy_computer_partition_list_instance_title</string> <string>my_busy_computer_partition_list_instance_title</string>
......
...@@ -414,7 +414,7 @@ ...@@ -414,7 +414,7 @@
<string>Image</string> <string>Image</string>
</tuple> </tuple>
<tuple> <tuple>
<string>owner_title</string> <string>ComputerPartition_getOwnerName</string>
<string>Owner</string> <string>Owner</string>
</tuple> </tuple>
<tuple> <tuple>
...@@ -641,10 +641,6 @@ ...@@ -641,10 +641,6 @@
<key> <string>url_columns</string> </key> <key> <string>url_columns</string> </key>
<value> <value>
<list> <list>
<tuple>
<string>reference</string>
<string>ComputerPartition_getUsageReportUrl</string>
</tuple>
<tuple> <tuple>
<string>instance_title</string> <string>instance_title</string>
<string>ComputerPartition_getInstanceUrlString</string> <string>ComputerPartition_getInstanceUrlString</string>
...@@ -661,6 +657,10 @@ ...@@ -661,6 +657,10 @@
<string>image</string> <string>image</string>
<string>ComputerPartition_getInstanceUrlString</string> <string>ComputerPartition_getInstanceUrlString</string>
</tuple> </tuple>
<tuple>
<string>ComputerPartition_getOwnerName</string>
<string>ComputerPartition_getOwnerUrl</string>
</tuple>
<tuple> <tuple>
<string>ComputerPartition_getLastestContactedDate</string> <string>ComputerPartition_getLastestContactedDate</string>
<string>ComputerPartition_getInstanceUrlString</string> <string>ComputerPartition_getInstanceUrlString</string>
......
<?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>
<string>default</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_busy_computer_partition_list_owner_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>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</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>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_editor_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>
<item>
<key> <string>title</string> </key>
<value> <string>Instance Owner</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>cell/ComputerPartition_getOwnerAsHtml</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -95,9 +95,7 @@ ...@@ -95,9 +95,7 @@
<value> <value>
<list> <list>
<string>listbox_aggregate_parent_title</string> <string>listbox_aggregate_parent_title</string>
<string>listbox_aggregate_default_ipv6</string>
<string>listbox_is_slave</string> <string>listbox_is_slave</string>
<string>listbox_aggregate_parent_reference</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -108,6 +106,7 @@ ...@@ -108,6 +106,7 @@
<string>my_title</string> <string>my_title</string>
<string>my_reference</string> <string>my_reference</string>
<string>my_source_reference</string> <string>my_source_reference</string>
<string>listbox_aggregate_parent_reference</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
<string>search_columns</string> <string>search_columns</string>
<string>selection_name</string> <string>selection_name</string>
<string>title</string> <string>title</string>
<string>url_columns</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -139,11 +140,11 @@ ...@@ -139,11 +140,11 @@
<string>Computer Ref.</string> <string>Computer Ref.</string>
</tuple> </tuple>
<tuple> <tuple>
<string>getAggregateTitle</string> <string>aggregate_title</string>
<string>Computer Partition</string> <string>Computer Partition</string>
</tuple> </tuple>
<tuple> <tuple>
<string>aggregate_default_ipv6</string> <string>SoftwareInstance_getComputerPartitionIPv6</string>
<string>IPv6</string> <string>IPv6</string>
</tuple> </tuple>
<tuple> <tuple>
...@@ -228,6 +229,25 @@ ...@@ -228,6 +229,25 @@
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Software Instances</string> </value> <value> <string>Software Instances</string> </value>
</item> </item>
<item>
<key> <string>url_columns</string> </key>
<value>
<list>
<tuple>
<string>aggregate_title</string>
<string>SoftwareInstance_getPartitionUrl</string>
</tuple>
<tuple>
<string>aggregate_parent_title</string>
<string>SoftwareInstance_getComputerUrl</string>
</tuple>
<tuple>
<string>aggregate_parent_reference</string>
<string>SoftwareInstance_getComputerUrl</string>
</tuple>
</list>
</value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
......
if brain is None:
brain = context
partition = brain.getAggregateValue()
if partition is None:
return None
computer = partition.getParent()
if url_dict: # If RenderJS UI
jio_key = computer.getRelativeUrl()
return {
'command': 'push_history',
'view_kw': {
'view': 'view',
'jio_key': jio_key,
},
'options': {
'jio_key': jio_key
},
}
else:
return computer.absolute_url()
<?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>url_dict=False, brain=None, selection=None, selection_name=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstance_getComputerUrl</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# Script to generate URL for computer partiton of Software Instances
# both for XHTML UI as well as renderJS UI
if brain is None:
brain = context
# 'brain' in this case is the Software Instance, hence trying to get
# the partition as it it related to the Software Instance with 'aggregate'
# category, hence, this will get us the relative URL of the aggregate
partition = brain.getAggregateValue()
if partition is None:
return None
if url_dict: # if RenderJS UI
jio_key = partition.getRelativeUrl()
return {
'command': 'push_history',
'view_kw': {
'view': 'view',
'jio_key': jio_key,
},
'options': {
'jio_key': jio_key
},
}
else:
return partition.absolute_url()
<?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>url_dict=False, brain=None, selection=None, selection_name=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstance_getPartitionUrl</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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