-
Notifications
You must be signed in to change notification settings - Fork 894
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
[WIP-discussion] Allow show operation to use the panel query #5271
base: main
Are you sure you want to change the base?
Conversation
[ci skip] [skip ci]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the approach yes. A bit scared to do it, but yeah, we should probably do something like this. Only one question
$this->data['title'] = $this->crud->getTitle() ?? trans('backpack::crud.preview').' '.$this->crud->entity_name; | ||
if ($this->crud->get('show.usePanelQuery')) { | ||
$this->data['entry'] = $this->crud->query->withTrashed()->findOrFail($id); | ||
$this->data['entry'] = $this->crud->setLocaleOnModel($this->data['entry']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. Writing a descriptive comment for you 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... something here is fishy to me. Why aren't we using getEntryWithLocale()
and we are using setLocaleOnModel()
? Looks to me like we're using a setter, instead of a getter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this do the same thing or no?
$this->data['entry'] = $this->crud->setLocaleOnModel($this->data['entry']); | |
$this->data['entry'] = $this->crud->getEntryWithLocale($id); |
[ci skip] [skip ci]
Back to you @pxpm |
WHY
BEFORE - What was wrong? What was happening before this PR?
Heads up: This is working, but it's just a POC to be discussed. We may need to add documentation about it if we decide to do it.
Reported in #5204 and we also had some discussions about it.
In my understanding, and the user reporting the issue, all the operations should be performing their queries over the Panel Query. This would be a huge change in behavior and we may miss use cases that we will break doing such a global change on a non-breaking version.
AFTER - What is happening after this PR?
I've thought about this for a while and decided to "experiment" with the feature in the show operation behind a configuration.
I think this is the way to go now, without risking breaking all people apps. We may eventually turn it
true
by default in a future version.HOW
How did you achieve that, in technical terms?
I introduced the
usePanelQuery
config in show operation, that will tell the operation if it should perform thefindOrFail
in the model, or in panel query.Is it a breaking change?
I don't think so no, it need to be enabled.
How can we test the before & after?
Steps described in the linked issue. But to sum up, create a constrain on the crud query and watch it being applied in the List but not in the show operation.