From 011f7f46b16f0f833183f48f45305a5d8079cb02 Mon Sep 17 00:00:00 2001
From: Adrian Schulz
Date: Thu, 5 Oct 2017 13:10:57 +0000
Subject: [PATCH] Frontend cleanups (dragging-item highlighting, hiding of
sorting-field, d&d cursor) & no limit for search-results
---
buildout.cfg | 5 ++++
requirements.txt | 2 +-
src/collective/sortedlisting/behavior.py | 9 +++++++-
.../sortedlisting/browser/querybuilder.py | 3 +--
.../sortedlisting/browser/results.pt | 2 +-
.../static/sortablequerystring/pattern.less | 18 +++++++++++++++
.../sortedlisting/tests/test_tile.py | 10 ++++++++
.../sortedlisting/tests/test_widget.py | 23 +++++++++++++++++++
src/collective/sortedlisting/tile.py | 6 ++++-
9 files changed, 72 insertions(+), 6 deletions(-)
diff --git a/buildout.cfg b/buildout.cfg
index 5d073e9..5d68a52 100644
--- a/buildout.cfg
+++ b/buildout.cfg
@@ -55,6 +55,10 @@ eggs = ${instance:eggs}
defaults = ['-s', 'collective.sortedlisting', '--auto-color', '--auto-progress']
+[sources]
+plone.app.z3cform = git https://github.com/plone/plone.app.z3cform.git branch=master
+
+
[zopepy]
recipe = zc.recipe.egg
eggs =
@@ -113,6 +117,7 @@ python-coveralls = 2.7.0
requests-toolbelt = 0.7.1
testfixtures = 4.13.4
zope.component = 3.12.1
+zc.buildout = 2.9.5
watchdog = 0.8.3
sh = 1.12.14
diff --git a/requirements.txt b/requirements.txt
index 244887f..ef52986 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,2 @@
setuptools==33.1.1
-zc.buildout==2.8.0
+zc.buildout==2.9.5
diff --git a/src/collective/sortedlisting/behavior.py b/src/collective/sortedlisting/behavior.py
index bea8094..076c489 100644
--- a/src/collective/sortedlisting/behavior.py
+++ b/src/collective/sortedlisting/behavior.py
@@ -7,6 +7,7 @@
from plone.batching import Batch
from plone.dexterity.interfaces import IDexterityContent
from plone.supermodel import model
+from plone.z3cform.textlines import TextLinesFieldWidget
from zope import schema
from zope.component import adapter
from zope.interface import implementer_only
@@ -30,7 +31,9 @@ class ISortableCollectionBehavior(model.Schema):
missing_value=''
)
# override QueryString widget with our sortable version
- form.widget('query', SortableQueryStringFieldWidget)
+ form.widget('query',
+ SortableQueryStringFieldWidget,
+ wrapper_css_class='sortableCollection-query')
sort_on = schema.TextLine(
title=_(u'label_sort_on', default=u'Sort on'),
@@ -80,6 +83,10 @@ class ISortableCollectionBehavior(model.Schema):
value_type=schema.TextLine(),
required=False,
)
+ # We have to set the widget to update the widget-settings
+ form.widget('sorting',
+ TextLinesFieldWidget,
+ wrapper_css_class='sortableCollection-sorting')
@implementer_only(ISortableCollectionBehavior)
diff --git a/src/collective/sortedlisting/browser/querybuilder.py b/src/collective/sortedlisting/browser/querybuilder.py
index b78019c..5247b36 100644
--- a/src/collective/sortedlisting/browser/querybuilder.py
+++ b/src/collective/sortedlisting/browser/querybuilder.py
@@ -14,8 +14,7 @@ def html_results(self, query):
used in the live update results"""
options = dict(original_context=self.context)
results = self(query, sort_on=self.request.get('sort_on', None),
- sort_order=self.request.get('sort_order', None),
- limit=10)
+ sort_order=self.request.get('sort_order', None),)
return getMultiAdapter(
(results, self.request),
name='sortable_query_results'
diff --git a/src/collective/sortedlisting/browser/results.pt b/src/collective/sortedlisting/browser/results.pt
index 463a0fe..9933477 100644
--- a/src/collective/sortedlisting/browser/results.pt
+++ b/src/collective/sortedlisting/browser/results.pt
@@ -24,7 +24,7 @@
-
+
-
',
+ self.view.html_results(self.query)
+ )
+
def test_querybuilder_batch(self):
""" Test querybuilder with batch
"""
@@ -60,3 +66,20 @@ def test_querybuilder_batch(self):
results = qb(sc.query, batch=True)
self.assertIsInstance(results, Batch)
self.assertEqual(len(results), 0)
+
+ def test_querybulider_default_batch(self):
+ """ Test if it the results will be batched if it's not implicity given.
+ """
+
+ setRoles(self.portal, TEST_USER_ID, ['Manager', ])
+
+ # default batch size is 10 for querystring
+ for counter in range(11):
+ obj = api.content.create(self.portal, 'Document',
+ title='A doc - {0}'.format(counter))
+ obj.reindexObject()
+
+ self.assertIn(
+ '',
+ self.view.html_results(self.query)
+ )
diff --git a/src/collective/sortedlisting/tile.py b/src/collective/sortedlisting/tile.py
index 6267c3f..d03e8e1 100644
--- a/src/collective/sortedlisting/tile.py
+++ b/src/collective/sortedlisting/tile.py
@@ -13,8 +13,12 @@
class ISortableContentListingTile(contentlisting.IContentListingTile):
- form.widget('query', SortableQueryStringFieldWidget)
+ form.widget('query',
+ SortableQueryStringFieldWidget,
+ wrapper_css_class='sortableCollection-query')
+ form.widget('sorting',
+ wrapper_css_class='sortableCollection-sorting')
sorting = schema.List(
title=_(u'Sorting'),
description=_(u'Widget specific sorting of the search results'),