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

NEW: Allow search field customisation #9341

Conversation

unclecheese
Copy link

@unclecheese unclecheese commented Nov 26, 2019

By default, GridFieldFilterHeader chooses the first field in the searchable fields array for the search bar. This allows you to customise what that field is.

Notes

Parent issue

Copy link
Contributor

@maxime-rainville maxime-rainville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make it easier and clearer for developers to know how to use and customise the new search interface. This is a good step in that direction.

I'm thinking we should provide a way for them to do it directly on their DataObjects, but this PR is a good intermediary step.

src/Forms/GridField/GridFieldFilterHeader.php Outdated Show resolved Hide resolved
@unclecheese
Copy link
Author

I'm not totally sold on adding it to the DataObject API. I think we've already got such a bloated DataObject "config", and we have a long history of just chucking concerns on to that pile that could be handled elsewhere.

@maxime-rainville
Copy link
Contributor

maxime-rainville commented Nov 27, 2019

That's probably a wider discussion for an RFC. This PR by itself doesn't preclude our duplicate these efforts. I'm fine with merging this PR once unit tests have been added and maybe some doc.

@unclecheese unclecheese force-pushed the pulls/4/come-on-baby-make-it-search-so-good branch from b4cdd16 to d6fde8f Compare January 13, 2020 01:14
@unclecheese
Copy link
Author

Good feedback, @maxime-rainville .. have added the primary_search_field config, plus tests and docs.

@Cheddam
Copy link
Member

Cheddam commented Jan 13, 2020

Likely doesn't impact this PR going through as-is, but #9356 talks about setting multiple fields to be searchable in the main field. Thinking we could change these new APIs in the future to optionally accept an array to achieve that issue's goals?

@lekoala
Copy link
Contributor

lekoala commented Jan 13, 2020

@Cheddam thanks for tracking this. Multiple field is indeed necessary in my opinion, as it is very unconvenient for the user to go through the dropdown in order to search on other fields. I think the common expectation of all my customers is that "typing something in the search bar matches on all relevant fields", not only on a single field.

@Cheddam
Copy link
Member

Cheddam commented Jan 15, 2020

@lekoala I appreciate that this feature would be really useful to users, but it'll need to be tackled in a separate PR - I just wanted to make @unclecheese aware of it, and check that this API is going to suit expansion to support it in the future.

@maxime-rainville maxime-rainville self-assigned this Jan 22, 2020
@maxime-rainville maxime-rainville force-pushed the pulls/4/come-on-baby-make-it-search-so-good branch from a1eaed5 to 8f0ec8c Compare January 23, 2020 03:15
Copy link
Contributor

@maxime-rainville maxime-rainville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with the PR and I've re-tested that it works. I'm thinking some of the doc could use simpler language, but otherwise I'm happy.

docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md Outdated Show resolved Hide resolved
docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md Outdated Show resolved Hide resolved
docs/en/02_Developer_Guides/12_Search/01_Searchcontext.md Outdated Show resolved Hide resolved
@emteknetnz
Copy link
Member

@unclecheese when you get a chance would you be able to implement Maxime's recommended docs changes? We should be able to get this merged once those are in

@lekoala
Copy link
Contributor

lekoala commented May 12, 2021

For reference
#9836

@GuySartorelli GuySartorelli force-pushed the pulls/4/come-on-baby-make-it-search-so-good branch from 8f0ec8c to 18cf766 Compare July 1, 2022 03:30
@GuySartorelli
Copy link
Member

I have rebased this on 4, resolved merge conflicts, and updated the docs.
The documentation assumes #10382 will be merged before this. There will likely be a merge conflict between these two PRs' docs, as well.

@GuySartorelli GuySartorelli dismissed maxime-rainville’s stale review July 1, 2022 04:13

The approval came before #10382 was created and may not apply with it as context

@GuySartorelli
Copy link
Member

GuySartorelli commented Jul 7, 2022

Note: The documentation portion should not be merged here. I have started the process of migrating docs to a new repository so the docs will need to be removed from this PR and a new PR raised in the new repo instead.

@GuySartorelli
Copy link
Member

Docs changes have been moved to silverstripe/developer-docs#6

* The name of the default search field
* @var string|null
*/
protected $searchField = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
protected $searchField = null;
protected ?string $searchField = null;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 134 to 136
/**
* @return string|null
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* @return string|null
*/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 142 to 145
/**
* @param string $field
* @return $this
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* @param string $field
* @return $this
*/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

public function setSearchField(string $field): self
{
$this->searchField = $field;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subjective but okay. Done.

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move the contents of this PR into #10382 and close this one, that way there's only a single framework PR which makes testing a lot easier < keep them separate

@GuySartorelli
Copy link
Member

If you agree the changes in this PR are worthwhile keeping then yes, I'll merge the two PRs. Though the combined PR should not be squashed in that case. These are two related but separate changes.

@GuySartorelli GuySartorelli force-pushed the pulls/4/come-on-baby-make-it-search-so-good branch 2 times, most recently from d2dbe74 to 24ea191 Compare July 11, 2022 22:33
@emteknetnz
Copy link
Member

emteknetnz commented Jul 11, 2022

Oh right, sorry got confused with all the PRs. Hold off for now, see how the other PR looks on it's own and then in a better position to judge if this is worthwhile. Doesn't seem like we should combine the two in either case

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking close this one and add an allowlist style config into #10382 would be better

@GuySartorelli GuySartorelli force-pushed the pulls/4/come-on-baby-make-it-search-so-good branch from 24ea191 to 07a6c11 Compare July 25, 2022 05:33
@GuySartorelli
Copy link
Member

We came to the decision not to use an allow-list configuration in the end: #10382 (comment)

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, works good

@emteknetnz emteknetnz merged commit c466ca5 into silverstripe:4 Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants