Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Breaking Change:
- Add idx parameter to display_modifier call, so that we can use the index name to resolve the correct translated taxonomy titles in collective.taxonomy. This means that the display_modifier method in the groupby_modifier adapters needs to expect this parameter too!
[MrTango]

Features:

- allow user to customize search button text and search input placeholder
[nngu6036 + jeffersonbledsoe]


3.5.1 (2021-05-26)
----------------
Expand Down
16 changes: 16 additions & 0 deletions src/collective/collectionfilter/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,22 @@ class ICollectionFilterSchema(ICollectionFilterBaseSchema):
class ICollectionSearchSchema(ICollectionFilterBaseSchema):
"""Schema for the search filter."""

button_text = schema.TextLine(
title=_("text_search_button", default=u"Search button text"),
description=_("help_header", u"Text of the search button."),
required=False,
default=_(u"Search"),
)

placeholder = schema.TextLine(
title=_(
"placeholder_search_input", default=u"Placeholder"
),
description=_("help_header", u"Placeholder of the search input."),
required=False,
default=_(u"Search"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have no default so the default will be translated based on the language of the site.
Same as the button text

)


class ICollectionFilterResultListSort(ICollectionFilterBaseSchema):
"""Schema for the result list sorting."""
Expand Down
5 changes: 3 additions & 2 deletions src/collective/collectionfilter/portlets/collectionsearch.pt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
<header class="portletHeader" tal:condition="view/title" tal:content="view/title">Title</header>
<div class="searchContent">
<form method="get" name="searchForm" role="form" action="${view/action_url}">
<input type="hidden" name="collectionfilter" value="1"/>
<tal:urlquery repeat="item python:view.urlquery">
<input type="hidden" name="${python:item[0]}" value="${python:item[1]}"/>
</tal:urlquery>
<input name="SearchableText" type="text"
placeholder="Search"
placeholder="${view/settings/placeholder}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need the same changes for tiles

data-url="${view/ajax_url}"
value="${view/value}"
i18n:attributes="placeholder text_search"/>
<button type="submit" i18n:translate="button_search">Search</button>
<button type="submit" i18n:translate="button_search">${view/settings/button_text}</button>
</form>
</div>
</aside>
6 changes: 6 additions & 0 deletions src/collective/collectionfilter/portlets/collectionsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,24 @@ class Assignment(base.Assignment):
target_collection = None
view_name = None
content_selector = "#content-core"
button_text = _(u"Search")
placeholder = _(u"Search keyword")

def __init__(
self,
header=u"",
target_collection=None,
view_name=None,
content_selector="#content-core",
button_text=_(u"Search"),
placeholder=_(u"Search"),
):
self.header = header
self.target_collection = target_collection
self.view_name = view_name
self.content_selector = content_selector
self.button_text = button_text
self.placeholder = placeholder

@property
def title(self):
Expand Down
7 changes: 7 additions & 0 deletions src/collective/collectionfilter/tests/robot/keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ Add search portlet
Wait until element is visible css=input#form-widgets-header

Input text css=input#form-widgets-header Searchable Text
Input text css=input#form-widgets-button_text Click to search
Input text css=input#form-widgets-placeholder Enter some keyword
#Select related filter collection
Click element css=.plone-modal-footer input#form-buttons-add
Wait until page contains element xpath=//div[@class='portletAssignments']//a[text()='Searchable Text']
Expand Down Expand Up @@ -178,7 +180,12 @@ My collection has a collection sorting portlet
I'm viewing the collection
Go to ${PLONE_URL}/testcollection
Should be 3 collection results

I should see the search portlet placeholder displays the text "${placeholder_text}"
Wait Until Element Is Visible xpath=//input[@name='SearchableText' and @placeholder='${placeholder_text}']

I should see the search portlet search button displays the text "${button_text}"
Wait Until Element Is Visible xpath=//button[@type='submit' and text()='${button_text}']

# --- Core Functionality ------------------------------------------------------
I search for "${search}" with ajax
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ Scenario: Searching through a portlet with ajax disabled
# and should be 4 filter options


Scenario: Customize search porlet text with ajax disabled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to be rebased against the testing branch. There aren't tests specific to portlets anymore. The same test should work for tiles and portlets

Given I've got a site with a collection
and my collection has a collection search portlet
When I'm viewing the collection
Then I should see the search portlet search button displays the text "Click to search"
and I should see the search portlet placeholder displays the text "Enter some keyword"
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ Scenario: Searching through a portlet with ajax enabled
# When I search for ${EMPTY} with ajax
# Then should be 2 collection results
# and should be 4 filter options


Scenario: Customize search porlet text with ajax enabled
Given I've got a site with a collection
and my collection has a collection search portlet
When I'm viewing the collection
and I should see the search portlet placeholder displays the text "Enter some keyword"