Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Generated from:
# https://github.com/plone/meta/tree/main/config/default
# https://github.com/plone/meta/tree/main/src/plone/meta/default
# See the inline comments on how to expand/tweak this configuration file
#
# EditorConfig Configuration file, for more details see:
Expand Down
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Generated from:
# https://github.com/plone/meta/tree/main/config/default
# https://github.com/plone/meta/tree/main/src/plone/meta/default
# See the inline comments on how to expand/tweak this configuration file
[flake8]
doctests = 1
Expand Down
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Generated from:
# https://github.com/plone/meta/tree/main/src/plone/meta/default
# See the inline comments on how to expand/tweak this configuration file
version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
14 changes: 3 additions & 11 deletions .github/workflows/meta.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Generated from:
# https://github.com/plone/meta/tree/main/config/default
# https://github.com/plone/meta/tree/main/src/plone/meta/default
# See the inline comments on how to expand/tweak this configuration file
name: Meta
on:
Expand All @@ -25,16 +25,15 @@ on:

jobs:
qa:
uses: plone/meta/.github/workflows/qa.yml@main
uses: plone/meta/.github/workflows/qa.yml@2.x
release_ready:
uses: plone/meta/.github/workflows/release_ready.yml@main
uses: plone/meta/.github/workflows/release_ready.yml@2.x

##
# To modify the list of default jobs being created add in .meta.toml:
# [github]
# jobs = [
# "qa",
# "test",
# "coverage",
# "dependencies",
# "release_ready",
Expand All @@ -49,13 +48,6 @@ jobs:
# os_dependencies = "git libxml2 libxslt"
##

##
# To test against a specific matrix of python versions
# when running tests jobs, add in .meta.toml:
# [github]
# py_versions = "['3.12', '3.11']"
##


##
# Specify additional jobs in .meta.toml:
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/test-matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Generated from:
# https://github.com/plone/meta/tree/main/src/plone/meta/default
# See the inline comments on how to expand/tweak this configuration file
name: Tests

on:
push:

jobs:
build:
permissions:
contents: read
pull-requests: write
strategy:
# We want to see all failures:
fail-fast: false
matrix:
os:
- ["ubuntu", "ubuntu-latest"]
config:
# [Python version, visual name, tox env]
- ["3.13", "6.2 on py3.13", "py313-plone62"]
- ["3.10", "6.2 on py3.10", "py310-plone62"]
- ["3.13", "6.1 on py3.13", "py313-plone61"]
- ["3.10", "6.1 on py3.10", "py310-plone61"]
- ["3.9", "6.0 on py3.9", "py39-plone60"]
- ["3.13", "6.0 on py3.13", "py313-plone60"]

runs-on: ${{ matrix.os[1] }}
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
name: ${{ matrix.config[1] }}
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.config[0] }}
allow-prereleases: true
- name: Pip cache
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.config[0] }}-${{ hashFiles('setup.*', 'tox.ini') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.config[0] }}-
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Initialize tox
# the bash one-liner below does not work on Windows
if: contains(matrix.os, 'ubuntu')
run: |
if [ `tox list --no-desc -f init|wc -l` = 1 ]; then tox -e init;else true; fi
- name: Test
run: tox -e ${{ matrix.config[2] }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Generated from:
# https://github.com/plone/meta/tree/main/config/default
# https://github.com/plone/meta/tree/main/src/plone/meta/default
# See the inline comments on how to expand/tweak this configuration file
# python related
*.egg-info
Expand All @@ -20,6 +20,8 @@ __pycache__/
.tox
.vscode/
node_modules/
forest.dot
forest.json

# venv / buildout related
bin/
Expand Down Expand Up @@ -47,6 +49,7 @@ local.cfg
.installed.txt

forest.*
test_*
robot_*
dependencies.svg

Expand Down
6 changes: 3 additions & 3 deletions .meta.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Generated from:
# https://github.com/plone/meta/tree/main/config/default
# https://github.com/plone/meta/tree/main/src/plone/meta/default
# See the inline comments on how to expand/tweak this configuration file
[meta]
template = "default"
commit-id = "7a017355"
commit-id = "2.1.0"

[pyproject]
codespell_ignores = "Dokument"
codespell_skip = "*.min.js,*.min.js.map,yarn.lock,*.po,*.robot"
codespell_skip = "*.min.js,*.min.js.map,yarn.lock,*.po,*.robot,*.json"
dependencies_ignores = """
[
'collective.geolocationbehavior', 'plone.formwidget.geolocation',
Expand Down
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# Generated from:
# https://github.com/plone/meta/tree/main/config/default
# https://github.com/plone/meta/tree/main/src/plone/meta/default
# See the inline comments on how to expand/tweak this configuration file
ci:
autofix_prs: false
autoupdate_schedule: monthly

repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
rev: v3.20.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/pycqa/isort
rev: 5.13.2
rev: 6.0.1
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 24.8.0
rev: 25.1.0
hooks:
- id: black
- repo: https://github.com/collective/zpretty
rev: 3.1.0
rev: 3.1.1
hooks:
- id: zpretty

Expand All @@ -32,7 +32,7 @@ repos:
# """
##
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
rev: 7.3.0
hooks:
- id: flake8

Expand All @@ -44,7 +44,7 @@ repos:
# """
##
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
rev: v2.4.1
hooks:
- id: codespell
additional_dependencies:
Expand All @@ -58,15 +58,15 @@ repos:
# """
##
- repo: https://github.com/mgedmin/check-manifest
rev: "0.49"
rev: "0.50"
hooks:
- id: check-manifest
- repo: https://github.com/regebro/pyroma
rev: "4.2"
rev: "5.0"
hooks:
- id: pyroma
- repo: https://github.com/mgedmin/check-python-versions
rev: "0.22.0"
rev: "0.22.1"
hooks:
- id: check-python-versions
args: ['--only', 'setup.py,pyproject.toml']
Expand Down
1 change: 1 addition & 0 deletions news/223.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add missing translations for de and de-ch @1letter
1 change: 1 addition & 0 deletions news/228.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add a pat-select2 portlet as filter option @1letter
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@
"publishConfig": {
"access": "public"
},
"homepage": "https://github.com/collective/collective.collectionfilter"
"homepage": "https://github.com/collective/collective.collectionfilter",
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generated from:
# https://github.com/plone/meta/tree/main/config/default
# https://github.com/plone/meta/tree/main/src/plone/meta/default
# See the inline comments on how to expand/tweak this configuration file
[build-system]
requires = ["setuptools>=68.2,<77"]
requires = ["setuptools>=68.2,<80", "wheel"]

[tool.towncrier]
directory = "news/"
Expand Down Expand Up @@ -37,7 +37,7 @@ showcontent = true

[[tool.towncrier.type]]
directory = "tests"
name = "Tests"
name = "Tests:"
showcontent = true

##
Expand Down Expand Up @@ -71,8 +71,8 @@ target-version = ["py38"]
##

[tool.codespell]
ignore-words-list = "discreet,assertin,Dokument"
skip = "*.po,*.min.js,*.min.js.map,yarn.lock,*.po,*.robot"
ignore-words-list = "discreet,assertin,thet,Dokument"
skip = "*.po,*.min.js,*.min.js.map,yarn.lock,*.po,*.robot,*.json"
##
# Add extra configuration options in .meta.toml:
# [pyproject]
Expand Down Expand Up @@ -119,6 +119,7 @@ Zope = [
'Products.CMFCore', 'Products.CMFDynamicViewFTI',
]
python-dateutil = ['dateutil']
pytest-plone = ['pytest', 'zope.pytestlayer', 'plone.testing', 'plone.app.testing']
ignore-packages = [
'collective.geolocationbehavior', 'plone.formwidget.geolocation',
'plone.app.blocks', 'plone.tiles', 'plone.app.tiles', 'plone.app.portlets',
Expand Down
30 changes: 28 additions & 2 deletions resources/js/collectionfilter.pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,43 @@ export default Base.extend({
}.bind(this)
);

// OPTION 2 - filter rendered as checkboxes
// OPTION 2 - filter rendered as checkboxes or as pat-select2
$(".filterContent input", this.$el).on(
"change",
function (e) {
var collectionURL = $(e.target).data("url");

var collectionURL = null;

if(e.currentTarget.classList.contains('pat-select2') == true){

// the pat-select2 field
const select2 = e.currentTarget
const options = JSON.parse(select2.dataset.results)
let current_option = null
if(e.added){
// option is added
current_option = e.added
} else{
// option is removed
current_option = e.removed
}

const item = options.find((item) => item.title == current_option.text)

collectionURL = item.url

} else{
//other checkboxes
collectionURL = $(e.target).data("url");
}

$(this.trigger).trigger("collectionfilter:reload", {
collectionUUID: this.options.collectionUUID,
targetFilterURL: collectionURL,
});

this.reloadCollection(collectionURL);

}.bind(this)
);

Expand Down Expand Up @@ -175,6 +200,7 @@ export default Base.extend({
}.bind(this)
);
}

},

reload: function (filterURL) {
Expand Down
34 changes: 34 additions & 0 deletions src/collective/collectionfilter/baseviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,46 @@ class BaseFilterView(BaseView):
def input_type(self):
if self.settings.input_type == "links":
return "link"

if self.settings.input_type == "select2":
if self.settings.filter_type == "single":
return "select2_single"
else:
return "select2"

if self.settings.filter_type == "single":
if self.settings.input_type == "checkboxes_radiobuttons":
return "radio"
return "dropdown"
return "checkbox"

@property
def select2_options(self):
results = self.results()
options = []
selected_values = []
select2_options = {
"results": [],
"tags": [],
"selected_values": [],
}

if not results:
return select2_options

for item in results:
options.append(item["title"])
if item.get("selected"):
selected_values.append(item["title"])

select2_options = {
"results": json.dumps(results),
"tags": ",".join(options),
"selected_values": ",".join(selected_values),
}

return select2_options

# results is called twice inside the template in view/available and view/results. But its expensive so we cache it
# but just the the lifetime of the view
@instance.memoize
Expand Down
Loading
Loading