tim-reynolds / magento-qconfig

A Magento module that adds Quick Search functionality to the Admin Configuration area

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Show number of matches

amenk opened this issue · comments

It would be nice to see how many matches were found, especially if there were no matches (maybe the input field could become red or something like this)

Agreed. Tried working on this, but there is a trade off.

This uses XPath to search the config and the display config (system.xml files). It would be great if the config had a fixed depth, but unfortunately it doesn't. So, to handle that, I am using what amount to sub-queries in the XPath query, so I can get the top-level tag that has some matching child.

$sections->xpath('*[.//label[contains(translate(text(), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"), "'.$qsearch.'") and ../'.$levelClause.'="1"]]')

That XPath gets the top tag that has any child with a label that matches. The problem is, if a tag has 5 or 10 children that match, it only shows up in the results once. The alternative would be to get all the children, and then walk them up to the top counting. I could do this, but I'm fairly certain it would be slow. The xpath call uses native code so I don't see the overhead as much.

But, of course, I want this as a feature.

Okay, but showing that there was no match at all would be possible? Actually this was my main feature request. I am not so interested in the actual numbers, but a message saying that nothing was found avoids that the user needs to search the whole page for found-markers.

Oh yeah, ok, that makes sense.

I was thinking of showing the number of matches on the left nav, so you would see that "@example.com" matched 5 things on Emails. But no matches showing at the top, that makes a lot of sense. I'll get on that right away.

I have this feature working, however I wanted your input on it.

As for the text, do you think "No Results" or "No Matches" works better?

Also, it probably makes sense to shade everything still, right? Makes sense to me, but I could be (and often am) wrong.

"No Matches" is better. And the background of the input field to change to red as in PHP storm.

Tried a few background:red things, but had strange results with the borders reverting to the inset appearance in Chrome. Didn't want to sort that at the moment, so just going with the slide-out information. Let me know what you think.

Tested it and liked it. Thanks!