Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run-time configuration for displaying facets (when we have a user and solr data available) for displaying facets #717

Closed
cbeer opened this issue Jan 29, 2014 · 1 comment · Fixed by #718
Milestone

Comments

@cbeer
Copy link
Member

cbeer commented Jan 29, 2014

Blacklight already supports static configuration for showing facet fields:

config.add_facet_field 'field', show: false
config.add_facet_field 'field', show: true

But it would be handy to have similar configuration for evaluating this at run-time when the solr data (and request context) are available. Maybe something like:

  • helper method (with no arguments), e.g.:
config.add_facet_field 'field', :show => :should_render_this_field?
...
# helper
def should_render_this_field?
  current_user.admin?
end
  • helper method with the solr data, e.g.:
config.add_facet_field 'field', :show => :should_render_field?
...
# helper
def should_render_field? display_field
  display_field.items.length > 1
end
  • inline Proc/lambda, e.g.:
config.add_facet_field 'field', :show => lambda { |ctx, facet_config,
display_field| true }
cbeer added a commit that referenced this issue Jan 29, 2014
Add configuration options to `add_facet_field 'field', :show => ` to
allow "run-time" configuration when the solr data and request context
are available, with a couple different options:

 - helper method (with no arguments), e.g.:

```
config.add_facet_field 'field', :show => :should_render_this_field?
...
\# helper
def should_render_this_field?
  current_user.admin?
end
```

 - helper method with the solr data, e.g.:

```
config.add_facet_field 'field', :show => :should_render_field?
...
\# helper
def should_render_field? display_field
  display_field.items.length > 1
end
```

 - inline Proc/lambda, e.g.:

```
config.add_facet_field 'field', :show => lambda { |ctx, facet_config,
display_field| true }
```

Fixes #717
@cbeer cbeer closed this as completed in a1459ce Jan 29, 2014
cbeer added a commit that referenced this issue Jan 30, 2014
Add configuration options to `add_facet_field 'field', :show => ` to
allow "run-time" configuration when the solr data and request context
are available, with a couple different options:

 - helper method (with no arguments), e.g.:

```
config.add_facet_field 'field', :show => :should_render_this_field?
...
\# helper
def should_render_this_field?
  current_user.admin?
end
```

 - helper method with the solr data, e.g.:

```
config.add_facet_field 'field', :show => :should_render_field?
...
\# helper
def should_render_field? display_field
  display_field.items.length > 1
end
```

 - inline Proc/lambda, e.g.:

```
config.add_facet_field 'field', :show => lambda { |ctx, facet_config,
display_field| true }
```

Fixes #717
@jrochkind
Copy link
Member

neat, nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants