primefaces-extensions / primefaces-extensions.github.com

Organization repo, only for homepage, wiki and issue tracker
https://primefaces-extensions.github.io/
70 stars 22 forks source link

New component: FuzzySearch #767

Closed aripddev closed 4 years ago

aripddev commented 4 years ago

Hi @melloware , I try to implement fuzzysort (https://github.com/farzher/fuzzysort) as PF component. It is a very fast javascript based search component for json data. Other alternatives are Lunr (http://lunrjs.com) and Fuse.js (https://fusejs.io). Do you think that this feature is appropriate for PF extensions?

melloware commented 4 years ago

PF Extensions is meant as a proving grounds for useful components so this seems like a good candidate.

aripddev commented 4 years ago

Since I am not good at creating advanced component, I will need your help. :)

melloware commented 4 years ago

Well the advice i can give is look at a component "like" it in PF or PFE and try to model it after that.

aripddev commented 4 years ago

I added the component to PFE showcase in local and try to test it using it. Component pages are working well however component itself is not working due to RES_NOT_FOUND (fuzzysort.js and primefaces.fuzzysort.js)? Do you accept commits for PFE showcase?

melloware commented 4 years ago

@aripddev Look at how Calculator works. the files in resoures are 0-1- 2- 3-calculator.js.

Then in the pom.xml I have this...

<include>calculator/**</include>

Then in my Component I just reference 1 file called calculator.js

@ResourceDependency(library = "primefaces-extensions", name = "calculator/calculator.js")

We combine all JS files in order that is why we use 0- and 1- to order then and they will get put into 1 file.

melloware commented 4 years ago

And yes we accept PR's for Showcase as we will need examples of your new component!

melloware commented 4 years ago

Some notes on your showcase example. It doesn't show them being styled as these styles...

resultStyleClass="resultStyleClass1234" resultStyle="resultStyle1234"

don't exist? It should highlight what was "fuzzy" about this result.

The fuzzysort example i think should also be provided as an "Advanced Example"

https://rawgit.com/farzher/fuzzysort/master/test.html

melloware commented 4 years ago

Also my IDE is reporting that buttonStyle is never used in the code. Can you confirm?

String buttonStyle = HTML.BUTTON_TEXT_ONLY_BUTTON_FLAT_CLASS;
        if (size == 1) {
            buttonStyle = buttonStyle + " ui-corner-all";
        }
        else if (idx == 0) {
            buttonStyle = buttonStyle + " ui-corner-left";
        }
        else if (idx == (size - 1)) {
            buttonStyle = buttonStyle + " ui-corner-right";
        }

        buttonStyle = selected ? buttonStyle + " ui-state-active" : buttonStyle;
        buttonStyle = disabled ? buttonStyle + " ui-state-disabled" : buttonStyle;
aripddev commented 4 years ago

I did not implement highlighting, and yes buttonStyle is not used.

melloware commented 4 years ago

OK i removed button styles...

melloware commented 4 years ago

OK I added highlighting as a new attribute. Updated Showcase example. Also added a new example of searching Timezones which are just Strings with no converters.

Also got the Input box styled to match PF theme.