Skip to content

Filter state two-way binding, custom equals - #1

Open
speti43 wants to merge 15 commits into
Qabel:datagrid-state-inputfrom
speti43:datagrid-state-input
Open

Filter state two-way binding, custom equals#1
speti43 wants to merge 15 commits into
Qabel:datagrid-state-inputfrom
speti43:datagrid-state-input

Conversation

@speti43

@speti43 speti43 commented Nov 29, 2018

Copy link
Copy Markdown

Here is a working version of the filter two-way binding, it's not ready to merge yet, because there are serious memory leaks (and some coding guideline issues), I justed wanted to ask you to take a look that the approach is fine, and if you have a suggestion to eliminate the memory leak, then please share the idea :).

@speti43

speti43 commented Nov 29, 2018

Copy link
Copy Markdown
Author

So if I get it right, I should create a new interface which is called SerializableFilter and extends ClrDatagridFilterInterface, and I should create a new implementation as well which will implement this new interface, and i think it can extend the string filter implementation class. In this case we wont affect custom filters like color filter. What about the equals logic, is it fine to you to check the property names?

@speti43

speti43 commented Nov 29, 2018

Copy link
Copy Markdown
Author

Yes, but with one difference: Just patch the builtin sting filter implementation to extend the ClrDatagridFilterInterface because just about everything useful there is private anyway.

You mean to patch the builtin sting filter implementation to implement the new SerializableFilter interface.

@speti43

speti43 commented Nov 30, 2018

Copy link
Copy Markdown
Author

@audax The refactor is committed, One thing is different, I don't set the filterstate directly, I just set it by the value setter, and via the constructor.

@speti43

speti43 commented Dec 4, 2018

Copy link
Copy Markdown
Author

Memory leak is fixed, now it works fine for built in string filter.

@speti43

speti43 commented Dec 5, 2018

Copy link
Copy Markdown
Author

@audax are there any e2e tests (protractor) in the project, is it runned by the pipeline? Or it is enough to make a dedicated page under the datagrid section to demonstrate the usage, with the built in filters, and the custom ones?

@speti43

speti43 commented Dec 5, 2018

Copy link
Copy Markdown
Author

All right, I'll prepare demo site, with different filters, and presorted columns, prepaged grid. Is that enough to accept the pull request?

@speti43

speti43 commented Dec 6, 2018

Copy link
Copy Markdown
Author

I'm just wondering, how could we restore the state of a custom filter, because it is a content child of the grid, so somehow we have to deliver the state info to the content child, which should implement the SerializableFilter interface, and restore the values in the component. How should we do this, or we should let the user to handle it locally?

@speti43

speti43 commented Dec 7, 2018

Copy link
Copy Markdown
Author

It seems, it works now, but we have to identify the filters somehow, we identifies string filters by type and property name, but for custom filters like color filter we also have to use type and id as well, because there can be two different colorfilters on the same grid, so I think we should update FilterStateInterface to include some kind of id beside the type field.

export interface FilterStateInterface {
    id: string;
    type: string;
}

@speti43

speti43 commented Dec 7, 2018

Copy link
Copy Markdown
Author

Now the preset for custom filters works, but I still don't know, how to pass an identifier for the custom filters, because we have to differentiate if multiple instance exists of the same type of the custom filter. Given this filter:

<clr-dg-filter [clrDgFilter]="colorFilter">
            <clr-datagrid-color-filter-demo #colorFilter class="color-filter">
            </clr-datagrid-color-filter-demo>
</clr-dg-filter>

When this filter is registered in the grid, we cannot access input properties, because they are null, because the filter component is not in that lifecycle to access these fields, so we need something which is available in the constructor, can we get #colorFilter identifier?
constructor of color-filter:

constructor() {
        this._state =
            {
                id: null, //Need the id here which is provided by the user in the template
                type: 'ColorFilter',
                allColors: this.allColors,
                selectedColors: {}
            };
    }

Any idea is welcome.

@speti43

speti43 commented Dec 13, 2018

Copy link
Copy Markdown
Author

@Wallabeng helped me with the solution, which was obvious, but I didn't think about that. He sets the custom filter ids in the binding-state component's onInit, not in the HTML. It works perfectly, but that means the user have to pay attention to set it.

Date interval filter, Number interval filter, List filter

Signed-off-by: Daniel Szegvari <extern.daniel.szegvari@porscheinformatik.at>
@dszegvari

Copy link
Copy Markdown

Hi @audax , I took over @speti43 's task. I pushed some changes about the custom filters. Please review it when you have the time.
After that, I will continue with the pagination refactor.

@dszegvari

Copy link
Copy Markdown

Also, I decided to not use the a writable state api of the datagrid, but instead to bind all writes to properties myself and write a custom filter component that is not integrated with the datagrid at all.

I may not understand this, could you please show me an example how you use the custom filters?

Minor refactors, Write new tests, Fix failing tests

Signed-off-by: Daniel Szegvari <extern.daniel.szegvari@porscheinformatik.at>
@dszegvari

Copy link
Copy Markdown

Hi @audax . Sorry for the delay. I had a couple of minor refactors, and wrote some tests. Please review it, if you have time.

Minor refactors

Signed-off-by: Daniel Szegvari <extern.daniel.szegvari@porscheinformatik.at>
@amellnik

Copy link
Copy Markdown

I'm interested in getting this across the finish line -- let me know if there's anything I can help with. Should it be rebased on top of vmware-archive#2846?

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 this pull request may close these issues.

3 participants