From: lzdych <svn...@pl...> - 2006-07-28 21:47:38
|
Author: lzdych Date: Fri Jul 28 08:49:55 2006 New Revision: 26491 Added: InventoryBuilder/trunk/skins/InventoryBuilder/ibtool_view.pt Modified: InventoryBuilder/trunk/HISTORY.txt InventoryBuilder/trunk/i18n/generated.pot InventoryBuilder/trunk/model/InventoryBuilder.zuml InventoryBuilder/trunk/skins/InventoryBuilder/ib_search_macros.pt InventoryBuilder/trunk/skins/InventoryBuilder_images/ib_builder_icon.gif InventoryBuilder/trunk/tools/InventoryBuilderTool.py InventoryBuilder/trunk/types/InventoryBuilder.py InventoryBuilder/trunk/version.txt Log: - fixed setting of results table listing (added new option to search settings in the inventory class) - added initial ibtool view template and updated ibtool icon - minor fixes related to generating search forms Modified: InventoryBuilder/trunk/HISTORY.txt ============================================================================== --- InventoryBuilder/trunk/HISTORY.txt (original) +++ InventoryBuilder/trunk/HISTORY.txt Fri Jul 28 08:49:55 2006 @@ -1,6 +1,12 @@ 1.0-beta1 (UNRELEASED) ====================== +- fixed setting of results table listing (added new option to search settings + in the inventory class) +- added initial ibtool view template and updated ibtool icon +- minor fixes related to generating search forms + [lzdych] + - fixed: removing inventory index from inventory tool management tab makes list of index types in the inventory tool desynchronized - added new maintenance function to synchronize index types list with registered Modified: InventoryBuilder/trunk/i18n/generated.pot ============================================================================== --- InventoryBuilder/trunk/i18n/generated.pot (original) +++ InventoryBuilder/trunk/i18n/generated.pot Fri Jul 28 08:49:55 2006 @@ -3,8 +3,8 @@ msgid "" msgstr "" "Project-Id-Version: InventoryBuilder\n" -"POT-Creation-Date: Thu Jul 27 16:44:33 2006\n" -"PO-Revision-Date: Thu Jul 27 16:44:33 2006\n" +"POT-Creation-Date: Thu Jul 27 22:18:17 2006\n" +"PO-Revision-Date: Thu Jul 27 22:18:17 2006\n" "Last-Translator: Radim Novotny, Lukas Zdych <rad...@co..., luk...@co...>\n" "Language-Team: Radim Novotny, Lukas Zdych <rad...@co..., luk...@co...>\n" "MIME-Version: 1.0\n" @@ -229,6 +229,11 @@ msgid "InventoryBuilder_help_masked_fields" msgstr "" +#. Default: "Select one or more attributes of item, which should be displayed in search results. It can take a long time to save settings if you change this value according to number of objects in the portal." +#: types/InventoryBuilder.py +msgid "InventoryBuilder_help_resultsTableColumns" +msgstr "" + #. Default: "Enter number of columns in which will be organized item attributes displaying on most item views." #: types/InventoryBuilder.py msgid "InventoryBuilder_help_schemataColumns" @@ -246,7 +251,7 @@ #. Default: "Here you can select widget for every searchable field which should represent fields in the search forms. Note that if you change searchable fields list you have to save settings to update this table." #: types/InventoryBuilder.py -msgid "InventoryBuilder_help_searchableFieldsWidgets" +msgid "InventoryBuilder_help_searchableWidgets" msgstr "" #. Default: "Select one or more item attributes, on which will be applyed html stripping. Only TextFields with TextAreaWidgets supports this feature." @@ -512,6 +517,11 @@ msgid "InventoryBuilder_label_masked_fields" msgstr "" +#. Default: "Results table columns" +#: types/InventoryBuilder.py +msgid "InventoryBuilder_label_resultsTableColumns" +msgstr "" + #. Default: "Schemata columns" #: types/InventoryBuilder.py msgid "InventoryBuilder_label_schemataColumns" @@ -527,9 +537,9 @@ msgid "InventoryBuilder_label_searchableFields" msgstr "" -#. Default: "Searchable fields widgets" +#. Default: "Searchable widgets" #: types/InventoryBuilder.py -msgid "InventoryBuilder_label_searchableFieldsWidgets" +msgid "InventoryBuilder_label_searchableWidgets" msgstr "" #. Default: "Stripped fields" Modified: InventoryBuilder/trunk/model/InventoryBuilder.zuml ============================================================================== Binary files. No diff available. Modified: InventoryBuilder/trunk/skins/InventoryBuilder/ib_search_macros.pt ============================================================================== --- InventoryBuilder/trunk/skins/InventoryBuilder/ib_search_macros.pt (original) +++ InventoryBuilder/trunk/skins/InventoryBuilder/ib_search_macros.pt Fri Jul 28 08:49:55 2006 @@ -97,22 +97,27 @@ </tal:fields> </tr> </tal:columns> + + <tr> + <td tal:attributes="colspan cols"> + <div class="formControls" + style="float: right; + margin: 0;"> + <input class="context" + tabindex="" + type="submit" + name="submit" + value="Search" + i18n:attributes="value label_search;" + tal:attributes="tabindex tabindex/next;" + /> + </div> + </td> + </tr> </table> <div class="visualClear"><!-- --></div> - - <div class="formControls" - style="float: right;"> - <input class="context" - tabindex="" - type="submit" - name="submit" - value="Search" - i18n:attributes="value label_search;" - tal:attributes="tabindex tabindex/next;" - /> - </div> - + </dd> </dl> @@ -126,7 +131,7 @@ results python:here.getFilteredItems(criteria, b_size = b_size, full_objects=False); batch batch|python:Batch(results, b_size, int(b_start), orphan=1); display_item_thumbs python: 1; - table_columns here/getListing_table_columns; + table_columns here/getResultsTableColumns; schema python: ibuilder.atse_getSchemaById('IBItem'); "> Added: InventoryBuilder/trunk/skins/InventoryBuilder/ibtool_view.pt ============================================================================== --- (empty file) +++ InventoryBuilder/trunk/skins/InventoryBuilder/ibtool_view.pt Fri Jul 28 08:49:55 2006 @@ -0,0 +1,89 @@ +<html xmlns="http://www.w3.org/1999/xhtml" + xml:lang="en" + lang="en" + xmlns:tal="http://xml.zope.org/namespaces/tal" + xmlns:metal="http://xml.zope.org/namespaces/metal" + xmlns:i18n="http://xml.zope.org/namespaces/i18n" + metal:use-macro="here/main_template/macros/master" + i18n:domain="plone"> + + <head><title></title></head> + + <metal:javascript_head fill-slot="javascript_head_slot"> + <tal:block define="macro here/archetypes_custom_js/macros/javascript_head | nothing" + condition="macro"> + <metal:block use-macro="macro" /> + </tal:block> + <tal:comment replace="nothing"> + Many of the following defines duplicated from the tal:defines in the + main slot. With base_edit, edit_macros could be reused as it was defined + for the entire document. base_view uses main_template and thus must + create additional defines for each slot it fills. + </tal:comment> + <tal:js define="fields python:here.Schema().viewableFields(here); + js python:here.getUniqueWidgetAttr(fields, 'helper_js')" + condition="js" + repeat="item js"> + <script type="text/javascript" + charset="iso-8859-1" + tal:condition="python:exists('portal/%s' % item)" + tal:attributes="src string:$portal_url/$item"> + </script> + </tal:js> + <tal:block define="portal_type python:here.getPortalTypeName().lower().replace(' ', '_'); + view_template python:'%s_view' % portal_type; + view_macros python:path('here/%s/macros|nothing' % view_template); + macro view_macros/js | nothing" + condition="macro"> + <metal:block use-macro="macro" /> + </tal:block> + </metal:javascript_head> + + <metal:css fill-slot="css_slot"> + <tal:comment replace="nothing"> + Many of the following defines duplicated from the tal:defines in the + main slot. With base_edit, edit_macros could be reused as it was defined + for the entire document. base_view uses main_template and thus must + create additional defines for each slot it fills. + </tal:comment> + <tal:css define="fields python:here.Schema().viewableFields(here); + css python:here.getUniqueWidgetAttr(fields, 'helper_css')" + condition="css" + repeat="item css"> + <style type="text/css" + media="all" + tal:condition="python:exists('portal/%s' % item)" + tal:content="string:@import url($portal_url/$item);"> + </style> + </tal:css> + <tal:block define="portal_type python:here.getPortalTypeName().lower().replace(' ', '_'); + view_template python:'%s_view' % portal_type; + view_macros python:path('here/%s/macros|nothing' % view_template); + macro view_macros/css | nothing" + condition="macro"> + <metal:block use-macro="macro" /> + </tal:block> + </metal:css> + + <body> + <metal:fill fill-slot="main"> + <metal:main_macro define-macro="main" + tal:define="portal_type python:here.getPortalTypeName().lower().replace(' ', '_'); + base_macros here/base/macros; + view_template python:'%s_view' % portal_type; + view_macros python:path('here/%s/macros|nothing' % view_template); + header_macro view_macros/header | header_macro | base_macros/header; + body_macro view_macros/body | body_macro | base_macros/body; + folderlisting_macro view_macros/folderlisting | folderlisting | base_macros/folderlisting; + footer_macro view_macros/footer | footer_macro | base_macros/footer; + errors python:request.get('errors', {})"> + + <metal:use_header use-macro="header_macro" /> + <metal:use_body use-macro="body_macro" /> + <metal:use_body use-macro="folderlisting_macro" /> + <metal:use_footer use-macro="footer_macro" /> + + </metal:main_macro> + </metal:fill> + </body> +</html> Modified: InventoryBuilder/trunk/skins/InventoryBuilder_images/ib_builder_icon.gif ============================================================================== Binary files. No diff available. Modified: InventoryBuilder/trunk/tools/InventoryBuilderTool.py ============================================================================== --- InventoryBuilder/trunk/tools/InventoryBuilderTool.py (original) +++ InventoryBuilder/trunk/tools/InventoryBuilderTool.py Fri Jul 28 08:49:55 2006 @@ -235,6 +235,15 @@ actions = ( + {'action': "string:${object_url}/ibtool_view", + 'category': "object", + 'id': 'view', + 'name': 'View', + 'permissions': (VIEW_PERMISSION,), + 'condition': 'python:1' + }, + + {'action': "string:${object_url}/ibtool_management", 'category': "object", 'id': 'management', Modified: InventoryBuilder/trunk/types/InventoryBuilder.py ============================================================================== --- InventoryBuilder/trunk/types/InventoryBuilder.py (original) +++ InventoryBuilder/trunk/types/InventoryBuilder.py Fri Jul 28 08:49:55 2006 @@ -541,13 +541,14 @@ ), DataGridField( - name='searchableFieldsWidgets', + name='searchableWidgets', + mutator="setSearchableWidgets", widget=DataGridWidget( - label="Searchable fields widgets", + label="Searchable widgets", description="Here you can select widget for every searchable field which should represent fields in the search forms. Note that if you change searchable fields list you have to save settings to update this table.", - columns={'field':FixedColumn('Field'), 'widget':SelectColumn('Widget', vocabulary='getWidgetsForSearch'), }, - label_msgid='InventoryBuilder_label_searchableFieldsWidgets', - description_msgid='InventoryBuilder_help_searchableFieldsWidgets', + columns={'fld':FixedColumn('Field'), 'wdt':SelectColumn('Widget', vocabulary='getWidgetsForSearch')}, + label_msgid='InventoryBuilder_label_searchableWidgets', + description_msgid='InventoryBuilder_help_searchableWidgets', i18n_domain='InventoryBuilder', ), allow_delete=0, @@ -555,7 +556,27 @@ allow_insert=0, allow_reorder=0, default_method="populateWidgetTypes", - columns=('field', 'widget') + columns=('fld', 'wdt') + ), + + LinesField( + name='resultsTableColumns', + widget=InAndOutWidget( + label="Results table columns", + description="Select one or more attributes of item, which should be displayed in search results. It can take a long time to save settings if you change this value according to number of objects in the portal.", + label_msgid='InventoryBuilder_label_resultsTableColumns', + description_msgid='InventoryBuilder_help_resultsTableColumns', + i18n_domain='InventoryBuilder', + ), + required=False, + vocabulary="getAvailableItemFields", + default=VOC_LISTING_COLUMNS, + enforceVocabulary=1, + storage=AnnotationStorage(migrate=True), + mutator="setResultsTableColumns", + languageIndependent=True, + schemata="special_searching", + mode="rw" ), IntegerField( @@ -1225,10 +1246,10 @@ fields.extend(self.atse_getSchemata('IBItem', schemata).fields()) # prepare widget types dict - widget_types = self.getSearchableFieldsWidgets() + widget_types = self.getSearchableWidgets() w_types = {} for widget_type in widget_types: - w_types[widget_type['field']] = widget_type['widget'] + w_types[widget_type['fld']] = widget_type['wdt'] for field in fields: accessor = '' @@ -1607,58 +1628,53 @@ brains = ctool.schema() rebuild = False - + if ids and len(ids) > 0: for field in ids: - if field and field != '': - appended = False + if field and field != '' and (field not in VOC_SYSTEM_FIELDS) and (field not in VOC_SEARCH_CRITERIA): # check index existence and create it if not exists if field not in indexes: ctool.addIndex(field, DEFAULT_INDEX_TYPE) rebuild = True - appended = True # check brains existence and create it if not exists if field not in brains: ctool.manage_addColumn(field) # register custom index in the builder tool - if appended and (field not in VOC_SYSTEM_FIELDS) and (field not in VOC_SEARCH_CRITERIA): - itool = getToolByName(self, 'portal_inventorybuildertool') - idxs = itool.getInventoryIndexes() - if field not in idxs: - idxs += (field,) - itool.setInventoryIndexes(idxs) - - # add to indexes list - index_list = itool.getInventoryIndexTypes() - result = [] - exists = False - for idx in index_list: - if idx['name'] == field: - exists = True - result.append({'name':idx['name'], 'type':idx['type']}) - - if not exists: - result.append({'name':field, 'type':DEFAULT_INDEX_TYPE}) - itool.setInventoryIndexTypes(result) - - # add to field widgets list - widgets = self.getSearchableFieldsWidgets() - result = [] - exists = False - for widget in widgets: - if widget['field'] == field: - exists = True - - # if field is not selected as searchable remove it - # from widgets list - if widget['field'] in ids: - result.append({'field':widget['field'], 'widget':widget['widget']}) - - if not exists: - result.append({'field':field, 'widget':DEFAULT_WIDGET_TYPE}) - self.setSearchableFieldsWidgets(tuple(result)) + itool = getToolByName(self, 'portal_inventorybuildertool') + idxs = itool.getInventoryIndexes() + if field not in idxs: + idxs += (field,) + itool.setInventoryIndexes(idxs) + + # add to indexes list + index_list = itool.getInventoryIndexTypes() + result = [] + exists = False + for idx in index_list: + if idx['name'] == field: + exists = True + result.append({'name':idx['name'], 'type':idx['type']}) + + if not exists: + result.append({'name':field, 'type':DEFAULT_INDEX_TYPE}) + itool.setInventoryIndexTypes(result) + + # add to field widgets list + widgets = self.getSearchableWidgets() + result = [] + exists = False + for widget in widgets: + if widget['fld'] == field: + exists = True + + if widget['fld'] in ids: + result.append({'fld':widget['fld'], 'wdt':widget['wdt']}) + + if not exists: + result.append({'fld':field, 'wdt':DEFAULT_WIDGET_TYPE}) + self.setSearchableWidgets(tuple(result)) if rebuild: # FIXME: it would be faster to run ctool.reindexIndex() but it doesn't @@ -1666,7 +1682,7 @@ ctool.clearFindAndRebuild() self.getField('searchableFields').set(self, value, **kwargs) - + security.declarePublic('setListingTableColumns') def setListingTableColumns(self, value, **kwargs): """ @@ -1682,7 +1698,7 @@ if ids and len(ids) > 0: for field in ids: - if field and (field not in ['title', 'description']): + if field and (field not in VOC_SYSTEM_FIELDS) and (field not in VOC_SEARCH_CRITERIA): appended = False # check index existence and create it if not exists if field not in indexes: @@ -1695,7 +1711,7 @@ ctool.manage_addColumn(field) # register custom index in the builder tool - if appended and (field not in VOC_SYSTEM_FIELDS) and (field not in VOC_SEARCH_CRITERIA): + if appended: itool = getToolByName(self, 'portal_inventorybuildertool') idxs = itool.getInventoryIndexes() if field not in idxs: @@ -1720,7 +1736,7 @@ # update catalog metadata ctool.clearFindAndRebuild() - self.getField('searchableFields').set(self, value, **kwargs) + self.getField('listing_table_columns').set(self, value, **kwargs) security.declarePublic('updateItemSchemataFields') def updateItemSchemataFields(self): @@ -1799,16 +1815,71 @@ """ Set inital list of widget types. """ - result = [{'field':'title', 'widget':'StringWidget',}, - {'field':'description', 'widget':'StringWidget',}, - {'field':'Creator', 'widget':'StringWidget',}, - {'field':'hasImage', 'widget':'BooleanWidget',}, - {'field':'listCategoryIds', 'widget':'SelectionWidget',}, - {'field':'review_state', 'widget':'SelectionWidget',}, + result = [{'fld':'Title', 'wdt':'StringWidget',}, + {'fld':'Description', 'wdt':'StringWidget',}, + {'fld':'Creator', 'wdt':'StringWidget',}, + {'fld':'hasImage', 'wdt':'BooleanWidget',}, + {'fld':'listCategoryIds', 'wdt':'SelectionWidget',}, + {'fld':'review_state', 'wdt':'SelectionWidget',}, ] return result + security.declarePublic('setResultsTableColumns') + def setResultsTableColumns(self, value, **kwargs): + """ + The mutator method checks if there are defined indexes and metadata in the portal catalog + for all selected fields, if not it creates it. + """ + ctool = getToolByName(self, 'portal_catalog') + ids = value + indexes = ctool.indexes() + brains = ctool.schema() + + rebuild = False + + if ids and len(ids) > 0: + for field in ids: + if field and (field not in VOC_SYSTEM_FIELDS) and (field not in VOC_SEARCH_CRITERIA): + appended = False + # check index existence and create it if not exists + if field not in indexes: + ctool.addIndex(field, DEFAULT_INDEX_TYPE) + rebuild = True + appended = True + + # check brains existence and create it if not exists + if field not in brains: + ctool.manage_addColumn(field) + + # register custom index in the builder tool + if appended: + itool = getToolByName(self, 'portal_inventorybuildertool') + idxs = itool.getInventoryIndexes() + if field not in idxs: + idxs += (field,) + itool.setInventoryIndexes(idxs) + + # add to indexes list + index_list = itool.getInventoryIndexTypes() + result = [] + exists = False + for idx in index_list: + if idx['name'] == field: + exists = True + result.append({'name':idx['name'], 'type':idx['type']}) + + if not exists: + result.append({'name':field, 'type':DEFAULT_INDEX_TYPE}) + itool.setInventoryIndexTypes(result) + + if rebuild: + # FIXME: it would be faster to run ctool.reindexIndex() but it doesn't + # update catalog metadata + ctool.clearFindAndRebuild() + + self.getField('resultsTableColumns').set(self, value, **kwargs) + # Methods from Interface IInventoryBuilderBaseObject security.declareProtected(VIEW_PERMISSION, 'getParentInventoryBuilder') Modified: InventoryBuilder/trunk/version.txt ============================================================================== --- InventoryBuilder/trunk/version.txt (original) +++ InventoryBuilder/trunk/version.txt Fri Jul 28 08:49:55 2006 @@ -1 +1 @@ -1.0-beta1 (UNRELEASED) build 79 +1.0-beta1 (UNRELEASED) build 86 |