Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A administrate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 32
    • Merge requests 32
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • thoughtbot, inc.
  • administrate
  • Merge requests
  • !913

More flexible searching

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/upper-hand/master into main Jun 19, 2017
  • Overview 97
  • Commits 24
  • Pipelines 1
  • Changes 16

Created by: jason-uh

This PR adds a pluggable search feature to Administrate. Instead of a simple boolean, searchable can now also take a class that implements #query/2, #search_term, and #with_context/1. There is a DefaultSearch implementation that other searches can extend.

Usage

Searches can be labeled with their attribute or, without an attribute, they will be grouped in the "special" :all label that will be run against any searchable attribute. Labeled searches will always be preferred to the :all label. In addition, labels can be specified more than once to enable searching for multiple values within the attribute. Finally, "op: and" can be used to turn the default "OR" operator to an "AND" operator when creating the outer query conditions (multiple occurrences of a labeled search will always use an "OR" search unless overridden by the search definition).

Examples:

On the Line Items page of the example application this search will find all line items which are either for The Game of Life product, have a unit price greater than or equal to $63.00, or whose order comes to a total price greater than or equal to $190.00.

`product: Game of Life, unit_price: 63, total_price: 190`

This search is similar to the above but uses "AND" for the outer query, and thus requires all of the search terms to be true.

`op: and, product: Game of Life, unit_price: 63, total_price: 190`
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/upper-hand/master