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

(Proposal) UI Grid Filters #492

Closed
jniles opened this issue Jun 13, 2016 · 1 comment
Closed

(Proposal) UI Grid Filters #492

jniles opened this issue Jun 13, 2016 · 1 comment

Comments

@jniles
Copy link
Collaborator

jniles commented Jun 13, 2016

The current filtering of UI Grids is bulky and difficult to work with. Some problems with it:

  1. Cannot selectively add or remove filters. The modal applies all filters at once, and removes them all when filtering again.
  2. Filters should ideally be stored as JSON objects to be sent as query params to the server. They are currently stored in an array that is difficult to work with on the client.

Proposal
I propose that we model filters as a JSON object with column:value pairs. Like this:

// filters to be applied to the grid.
let filters = {
  name: "Christopher",
  limit: "10",
  sex: "M"
};

I also propose that we implement add/remove functionality that can remove or add a single filter at a time. The UI would look like this:
ui grid filters no filters
Fig 1: No filters applied.

ui grid filters filters applied
Fig 2: Filtering with a single filter + limit.

ui grid filters multiple filters
Fig 3: Filtering with multiple, additive filters.

When the user clicks the "X" icon on a filter, it is removed, and the data is refreshed from the database.

@jniles
Copy link
Collaborator Author

jniles commented Jun 14, 2016

After some discussion, I'm updating my recommendation for the data model. I propose:

var filters = [
  { field : 'first_name', displayName: 'FORM.LABELS.FIRST_NAME', value: undefined },
  // more filters
];

Advantages:

  1. Looks like ui-grid.
  2. Allows translation to be defined with columns as displayName.
  3. Is extendable to hold other properties (greater than, less than, etc) in the future.

jniles referenced this issue in jniles/bhima Jun 17, 2016
This commit improves the filters ui again by introducing the following
upgrades:
 1. The server uses `moment` to parse dates in the date filters.  The
 code on the server for rendering the filters is very similar to the
 clientside codebase, which is unavoidable.  There might be an
 optimisation down the road to reduce this replication, but I think this
 is acceptable for now.

 2. The filters are now passed into the filter form and preset there.
 That way, when you go to filter a second time, all the data is
 preserved.

 3. A weird bug with caching filters was fixed.  The detailed flag no
 longer shows up as a potential filter, and refreshing the page after
 printing no longer breaks the browser.

 4. The date rendering has been improved in the handlebar's date helper
 function.  If an invalid date occurs, it will simply render the empty
 string.

 5. The `$uibModal` handler now implements the behavior described in
 #506.

Closes #492.  Closes #336.
@jniles jniles mentioned this issue Jun 17, 2016
4 tasks
jniles referenced this issue in jniles/bhima Jun 21, 2016
This commit improves the filters ui again by introducing the following
upgrades:
 1. The server uses `moment` to parse dates in the date filters.  The
 code on the server for rendering the filters is very similar to the
 clientside codebase, which is unavoidable.  There might be an
 optimisation down the road to reduce this replication, but I think this
 is acceptable for now.

 2. The filters are now passed into the filter form and preset there.
 That way, when you go to filter a second time, all the data is
 preserved.

 3. A weird bug with caching filters was fixed.  The detailed flag no
 longer shows up as a potential filter, and refreshing the page after
 printing no longer breaks the browser.

 4. The date rendering has been improved in the handlebar's date helper
 function.  If an invalid date occurs, it will simply render the empty
 string.

 5. The `$uibModal` handler now implements the behavior described in
 #506.

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

No branches or pull requests

1 participant