Skip to content

Commit

Permalink
compound facet templates
Browse files Browse the repository at this point in the history
  • Loading branch information
nics committed Mar 2, 2017
1 parent 8ddc217 commit a624cba
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 32 deletions.
20 changes: 10 additions & 10 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ views:
facet: popular_science
- template: facets/extern
facet: extern
min: 1
- template: facets/open_access
facet: open_access
- template: facets/isi
facet: isi
- template: facets/pmid
facet: pmid
min: 1
- template: facets/isi_pmid
facet: [isi, pmid]
min: 1
backend:
publication:
facets:
- - template: facets/status
facet: status
- - template: facets/department
facet: department
roles:
- super_admin
role: super_admin
- template: facets/type
facet: type
- template: facets/author
Expand All @@ -41,10 +41,10 @@ views:
facet: extern
- template: facets/open_access
facet: open_access
- template: facets/isi
facet: isi
- template: facets/pmid
facet: pmid
min: 1
- template: facets/isi_pmid
facet: [isi, pmid]
min: 1
# TODO move to backend/publication/edit/
publication_edit:
js:
Expand Down
11 changes: 9 additions & 2 deletions views/facets.tt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@
[% FOR facet_group IN h.config.features.views.item(backend ? 'backend' : 'frontend').publication.facets %]
[% facets_in_group = [] %]
[% FOR f IN facet_group %]
[% NEXT IF (facets.item(f.facet).terms.size || 0) < 2 %]
[% NEXT IF f.roles && (!session.role || !f.roles.grep(session.role).size) %]
[% min_terms = f.min.defined ? f.min : 2 %]
[% num_terms = 0 %]
[% FOR key IN f.facet.list %]
[% n = facets.item(key).terms.size || 0 %]
[% NEXT IF n == 1 && facets.item(key).terms.0.count == total %]
[% num_terms = num_terms + n %]
[% END %]
[% NEXT IF num_terms < min_terms %]
[% NEXT IF f.role && (!session.role || !f.role.list.grep(session.role).size) %]
[% facets_in_group.push(f) %]
[% END %]
[% NEXT UNLESS facets_in_group.size > 0 %]
Expand Down
File renamed without changes.
20 changes: 0 additions & 20 deletions views/facets/pmid.tt

This file was deleted.

0 comments on commit a624cba

Please sign in to comment.