Skip to content

Commit

Permalink
Merge 0467825 into 627b235
Browse files Browse the repository at this point in the history
  • Loading branch information
nngu6036 committed Jan 8, 2020
2 parents 627b235 + 0467825 commit f2e093d
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Changelog
[tmassman]
- fix translation of ``filter_value``
[petschki]

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

3.2.1 (2019-08-07)
------------------
Expand Down
19 changes: 19 additions & 0 deletions src/collective/collectionfilter/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,25 @@ 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'Search input placeholder'),
description=_(
'help_header',
u'Placeholder of the search input.'
),
required=False,
default=_(u'Search')
)


class IGroupByCriteria(Interface):
Expand Down
6 changes: 3 additions & 3 deletions src/collective/collectionfilter/portlets/collectionsearch.pt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<input type="hidden" tal:attributes="name python:item[0]; value python:item[1]"/>
</tal:urlquery>
<input name="SearchableText" type="text"
placeholder="Search"
placeholder="${view/settings/placeholder}"
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>
</tal:if>
</aside>
</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 @@ -21,18 +21,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
2 changes: 2 additions & 0 deletions src/collective/collectionfilter/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def setUpPloneSite(self, portal):
)
portal.invokeFactory(
'Document',
Type="Document",
id='testdoc',
title=u'Test Document 😉',
text=RichTextValue(u'Ein heißes Test Dokument'),
Expand All @@ -86,6 +87,7 @@ def setUpPloneSite(self, portal):
)
portal.invokeFactory(
'Document',
Type="Document",
id='testdoc2',
title=u'Page 😉',
text=RichTextValue(u'Ein heißes Test Dokument'),
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 @@ -80,6 +80,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 @@ -155,7 +157,12 @@ My collection has a collection filter 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 ${document} with ajax
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ Scenario: Displaying multiple collection filters on a single page
and my collection has a collection filter portlet group_by=Type
When I'm viewing the collection
Then I should have a portlet titled "Subject" with 4 filter options
and I should have a portlet titled "Type" with 3 filter options
and I should have a portlet titled "Type" with 3 filter options
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@ Scenario: Searching through a portlet with ajax disabled
# Given I'm viewing the collection
# When I search for ${EMPTY} and click search
# Then should be 2 collection results
# and should be 4 filter options
# and should be 4 filter options


Scenario: Customize search porlet text with ajax disabled
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 @@ -25,3 +25,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"

0 comments on commit f2e093d

Please sign in to comment.