Commit 12a22d07 authored by Ayush Tiwari's avatar Ayush Tiwari

erp5_catalog: Add select_variable property for StandardProperty object in ERP5.

Whenever we create a standard property in a property sheet, we generate some properties
for the standard property(like id, translatable, read_permission, etc) which one can
usually see and change from going to manage_propertiesForm.

But in case when we set the property type to selection or multiple selection, right
now we get errors while trying to access property form ('select_variable not defined').
This was because we didn't have the select_variable property for the standard property,
which are required to show the items available in the property. Also, in the dtml file
for the properties form did have some bugs while displaying properties for select variable.

This commit solves both the problem by adding property 'select_variable' for StandardProperty
object, generating accessors for it and fixing the bug in dtml file for properties form.

Even though we could have survived without the use of select_variable property in
StandardProperty object, we can expect better consistency as in some places inside
erp5, we are still using select_variable property.
Also, it can prove helpful in casese where we shift something from zope to erp5, for
example ZSQLCatalog, which do ahve select_property in their propertyMap and might
need it inside erp5.
parent a0d21451
......@@ -55,6 +55,7 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject):
- write_permission: string (default: Permissions.ModifyPortalContent)
- translatable: boolean (default: False)
- translation_domain: string
- select_variable: string
"""
meta_type = 'ERP5 Standard Property'
portal_type = 'Standard Property'
......@@ -133,6 +134,10 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject):
'translation_domain',
'string')
getSelectVariable = Base.Getter('getSelectVariable',
'select_variable',
'string')
@classmethod
def _asPropertyMap(cls, property_dict):
"""
......@@ -152,6 +157,7 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject):
property_dict['default'] = property_dict.pop('property_default')
property_dict['id'] = property_dict.pop('reference')
property_dict['select_variable'] = property_dict.pop('select_variable')
# In case, this property is a list, then display it as a list
if property_dict['type'] in list_types or property_dict['multivalued']:
......@@ -609,7 +615,8 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject):
'read_permission': self.getReadPermission(),
'write_permission': self.getWritePermission(),
'translatable': self.getTranslatable(),
'translation_domain': self.getTranslationDomain()}
'translation_domain': self.getTranslationDomain(),
'select_variable': self.getSelectVariable()}
security.declareProtected(Permissions.ModifyPortalContent,
'applyOnAccessorHolder')
......
......@@ -95,17 +95,17 @@ property values, edit the values and click "Save Changes".
<dtml-elif "type=='selection'">
<dtml-if "hasProperty(select_variable)">
<dtml-if "hasProperty('select_variable')">
<div class="form-element">
<select name="&dtml-id;:<dtml-var "REQUEST['management_page_charset_tag']">text">
<dtml-in "getProperty(select_variable)">
<dtml-in "getProperty('select_variable')">
<option
<dtml-if "_['sequence-item']==getProperty(id)">SELECTED</dtml-if>
>&dtml-sequence-item;</option>
</dtml-in>
</select>
</div>
<dtml-elif "_.has_key(select_variable)">
<dtml-elif "_.has_key('select_variable')">
<div class="form-element">
<select name="&dtml-id;:<dtml-var "REQUEST['management_page_charset_tag']">text">
<dtml-in "_[select_variable]">
......@@ -123,11 +123,11 @@ property values, edit the values and click &quot;Save Changes&quot;.
<dtml-elif "type=='multiple selection'">
<dtml-if "hasProperty(select_variable)">
<dtml-if "hasProperty('select_variable')">
<div class="form-element">
<select name="&dtml-id;:<dtml-var "REQUEST['management_page_charset_tag']">list:string" multiple
size="<dtml-var "_.min(7, _.len(getProperty(select_variable)))">">
<dtml-in "getProperty(select_variable)">
size="<dtml-var "_.min(7, _.len(getProperty('select_variable')))">">
<dtml-in "getProperty('select_variable')">
<option<dtml-if
"getProperty(id) and (_['sequence-item'] in getProperty(id))"
> SELECTED</dtml-if
......@@ -135,7 +135,7 @@ property values, edit the values and click &quot;Save Changes&quot;.
</dtml-in>
</select>
</div>
<dtml-elif "_.has_key(select_variable)">
<dtml-elif "_.has_key('select_variable')">
<div class="form-element">
<select name="&dtml-id;:<dtml-var "REQUEST['management_page_charset_tag']">list:string" multiple
size="<dtml-var "_.min(7, _.len(_[select_variable]))">">
......
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