Skip to content

Commit

Permalink
Merge dfe9e61 into 29e5a52
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgross committed Apr 12, 2018
2 parents 29e5a52 + dfe9e61 commit 69bc7a8
Show file tree
Hide file tree
Showing 18 changed files with 539 additions and 177 deletions.
11 changes: 0 additions & 11 deletions .travis.yml
@@ -1,7 +1,5 @@
language: python
sudo: false
addons:
chrome: stable
cache:
directories:
- eggs
Expand All @@ -10,19 +8,10 @@ python:
- 2.7.13
matrix:
fast_finish: true
before_install:
- CDVERSION=`curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE`
- wget http://chromedriver.storage.googleapis.com/$CDVERSION/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip
- chmod u+x chromedriver
- mv chromedriver ~/bin/
install:
- pip install -r requirements.txt
- buildout -N buildout:download-cache=downloads code-analysis:return-status-codes=True annotate
- buildout -N buildout:download-cache=downloads code-analysis:return-status-codes=True
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
script:
- bin/code-analysis
- bin/coverage run bin/test --all
Expand Down
7 changes: 6 additions & 1 deletion CHANGES.rst
Expand Up @@ -5,7 +5,12 @@ Changelog
1.0a5 (unreleased)
------------------

- Nothing changed yet.
- Preview-field is now bigger (drag & drop usability).
- Same results-limit will be used in the view and the querybuilder.
- The sorting for every collection will be stored in it's own sorting field.
- "Sort on"-field has now an impact on the query & the results.
- Fix tests
[adrianschulz]


1.0a4 (2017-11-09)
Expand Down
1 change: 1 addition & 0 deletions buildout.cfg
Expand Up @@ -123,3 +123,4 @@ sh = 1.12.14
# mosaic testing dependency
plone.formwidget.multifile = 2.0
plone.jsonserializer = 0.9.3
plone.app.widgets = 2.2
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -14,7 +14,7 @@

setup(
name='collective.sortedlisting',
version='1.0a5.dev0',
version='1.0a5.fork2',
description="Sorted listings in Plone",
long_description=long_description,
# Get more from https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down
2 changes: 1 addition & 1 deletion src/collective/sortedlisting/browser/configure.zcml
Expand Up @@ -21,7 +21,7 @@

<browser:page
name="sortable_query_results"
class="plone.app.querystring.querybuilder.ContentListingView"
class=".querybuilder.SortableContentListingView"
permission="zope2.View"
for="*"
template="results.pt"
Expand Down
13 changes: 12 additions & 1 deletion src/collective/sortedlisting/browser/querybuilder.py
@@ -1,10 +1,14 @@
# -*- coding: utf-8 -*-
from plone.app.contentlisting.interfaces import IContentListing
from plone.app.querystring.querybuilder import QueryBuilder as BaseQueryBilder
from plone.app.querystring.querybuilder import ContentListingView
from plone.batching import Batch
from zope.component import getMultiAdapter


DISPLAY_LIMIT = 50


class QueryBuilder(BaseQueryBilder):
""" This view is used by the javascripts,
fetching configuration or results"""
Expand All @@ -15,7 +19,7 @@ def html_results(self, query):
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=50)
limit=DISPLAY_LIMIT)
return getMultiAdapter(
(results, self.request),
name='sortable_query_results'
Expand All @@ -41,3 +45,10 @@ def _makequery(self, query=None, batch=False, b_start=0, b_size=30,
if batch:
results = Batch(results, b_size, start=b_start)
return results


class SortableContentListingView(ContentListingView):

def __call__(self, **kw):
obj = super(SortableContentListingView, self)
return obj.__call__(limit=DISPLAY_LIMIT, **kw)
24 changes: 21 additions & 3 deletions src/collective/sortedlisting/browser/results.pt
Expand Up @@ -4,7 +4,8 @@
there are no html and body tags
</tal:comment>
<div tal:define="results context;
limited_results python:context[:25];
limit nocall:options/limit;
limited_results python:context[:limit];
original_context nocall:options/original_context|nocall:context;
toLocalizedTime nocall:original_context/@@plone/toLocalizedTime;
pas_member original_context/@@pas_member;
Expand Down Expand Up @@ -95,11 +96,28 @@
</ul>
<script type="text/javascript">
var updateSorting = function(el, shift){
/* Get active modal window */
var modal = $('div.plone-modal-wrapper:visible').first();
/*
Not in use to reduce the risk of an error in the next release.
if(modal.length == 0) {
modal = $('div.plone-modal-wrapper.mosaic-overlay');
}
if(modal.length == 0){
modal = $('div#content-core');
}
*/
var sortOnSelect = modal.find(".querystring-sort-wrapper").find("select")
var uid = $(el).attr('data-uid');
var uidList = $("#search-results li").map(function() {
var uidList = modal.find("div#search-results li").map(function() {
return $(this).data("uid");
}).get();
$( "textarea[name$='sorting']" ).val( uidList.join("\r\n"))
modal.find("textarea[name$='sorting']").first().val( uidList.join("\r\n"))

/* If a sorting-option is selected and drag & drop is executed
the sort_on value will be set to No sorting automatically. */
sortOnSelect.first().val('');
sortOnSelect.first().trigger('change'); // Notify any JS components that the value changed
};

</script>
Expand Down

0 comments on commit 69bc7a8

Please sign in to comment.