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

Persist GridField readonly state, add view button #8535

Merged

Conversation

lukereative
Copy link

@lukereative lukereative commented Oct 29, 2018

Resolves #3357 (remaining ACs/bugs)

  • Fixes an issue that when the GridField is called via pjax it loses it's readonly state i.e. when pagination buttons are pushed
  • Add a couple missing components to readonly whitelist
  • Add view button to re-enable access to view records as edit buttons will be removed

Copy link

@unclecheese unclecheese left a comment

Choose a reason for hiding this comment

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

Just some minor points of feedback. Nice work.

}
}

// As the edit button may have been removed, add a view button if it doesn't have one
if ($copyConfig->getComponentsByType(GridFieldViewButton::class)->count() === 0) {

Choose a reason for hiding this comment

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

Better expressed as if (!$copyConfig->getComponentByType(...))

Copy link
Author

Choose a reason for hiding this comment

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

Got it mixed up with removeComponentsByType which only has a multiple selector method, I've now changed it to the singular.

@@ -1009,6 +1029,9 @@ public function gridFieldAlterAction($data, $form, HTTPRequest $request)
}

if ($request->getHeader('X-Pjax') === 'CurrentField') {
if ($this->getState(true)->Readonly) {

Choose a reason for hiding this comment

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

true is the default value. This can just be getState()

Copy link
Author

Choose a reason for hiding this comment

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

Done

public function setReadonly($readonly)
{
parent::setReadonly($readonly);
$this->getState()->Readonly($readonly);

Choose a reason for hiding this comment

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

Wondering, only because this is so ugly and IDE unfriendly, is this functionally equivalent to just getState()->Readonly = $readonly? I think it's just a question of whether it uses __call() or __set().

Copy link
Author

Choose a reason for hiding this comment

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

Done

@unclecheese unclecheese merged commit c7b8b80 into silverstripe:4.3 Oct 31, 2018
@unclecheese unclecheese deleted the pulls/4.3/for-your-eyes-readonly branch October 31, 2018 22:13
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.

None yet

2 participants