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

ENH UI updated for versioned objects and all its relations #11101

Open
wants to merge 1 commit into
base: 5
Choose a base branch
from

Conversation

sabina-talipova
Copy link
Contributor

@sabina-talipova sabina-talipova commented Dec 20, 2023

Description

These changes add additional checking for the presence of changes in child classes (which have the Versioned extension) and if these changes exist, then the “MODIFIED” badge will be added to the name of the object. In my opinion, this is the only suitable badge, since there are several points that make the use of other badges difficult. For example, if the object itself has several child objects and these objects have different states, for example, one has the “DRAFT” state, and the other has the “ARCHIVED” state.

Parent issue

@sabina-talipova sabina-talipova force-pushed the pulls/5/versioned-ui branch 3 times, most recently from ce8d69b to f79ecfa Compare December 21, 2023 19:37
@sabina-talipova sabina-talipova marked this pull request as ready for review December 21, 2023 20:00
*/
private function getStatusFlags(DataObject $record): array
{
if ($record->hasExtension(Versioned::class)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check that this class does not have the Versioned extension is needed in order, firstly, not to have a duplicate badge and, secondly, not to override the badge of the current state of the current object.

Copy link
Member

Choose a reason for hiding this comment

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

So there is already a versioned badge, and this PR is adding a new one? Is the original status badge wrong? Where is the code for the original status badge. Would it make sense to move this code there, or at least deprecate the old code since it's presumably wrong?

@@ -417,7 +420,7 @@ protected function getFormActions()
throw new LogicException(get_class($this->record) . ' must implement ' . DataObjectInterface::class);
}

$noChangesClasses = 'btn-outline-primary font-icon-tick';
$noChangesClasses = $this->stagesDifferRecursive() ? 'btn-primary font-icon-save' : 'btn-outline-primary font-icon-tick';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check is needed to highlight “Save” if child versioned objects have changes

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

Not a proper review, just something I noticed at a glance.

@@ -1483,7 +1483,7 @@ public function loadDataFrom($data, $mergeStrategy = 0, $fieldList = null)
* @param FieldList $fieldList An optional list of fields to process. This can be useful when you have a
* form that has some fields that save to one object, and some that save to another.
*/
public function saveInto(DataObjectInterface $dataObject, $fieldList = null)
public function saveInto(ViewableData|DataObjectInterface $dataObject, $fieldList = null)
Copy link
Member

Choose a reason for hiding this comment

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

We can't change the method signature of public API

Suggested change
public function saveInto(ViewableData|DataObjectInterface $dataObject, $fieldList = null)
public function saveInto(DataObjectInterface $dataObject, $fieldList = null)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

SilverStripe\Forms\Tests\GridField\GridFieldTest\Cheerleader:
cheerleader1_team1:
Name: Heather
Team: =>SilverStripe\Forms\Tests\GridField\GridFieldTest\Team.team1
Copy link
Member

Choose a reason for hiding this comment

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

Add a blank line at end of file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@@ -0,0 +1,8 @@
SilverStripe\Forms\Tests\GridField\GridFieldTest\Team:
team1:
Copy link
Member

Choose a reason for hiding this comment

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

Indentation in this file is wrong, should be 2 spaces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@@ -0,0 +1,8 @@
SilverStripe\Forms\Tests\GridField\GridFieldTest\Team:
team1:
Copy link
Member

Choose a reason for hiding this comment

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

Indentation in this file is wrong, should be 2 spaces

Also add a blank line at end of the file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

*/
private function getStatusFlags(DataObject $record): array
{
if ($record->hasExtension(Versioned::class)) {
Copy link
Member

Choose a reason for hiding this comment

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

So there is already a versioned badge, and this PR is adding a new one? Is the original status badge wrong? Where is the code for the original status badge. Would it make sense to move this code there, or at least deprecate the old code since it's presumably wrong?

* @param string $columnName
* @return string HTML for the column. Return NULL to skip.
*/
public function getColumnContent($gridField, $record, $columnName)
Copy link
Member

Choose a reason for hiding this comment

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

Strongly type params and return type, remove docblocks for param types unless there is useful information for a param/return type. Do this for all methods in the PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a small problem, because interface GridField_ColumnProvider still doesn't support strong types, so I can update only few methods.

@sabina-talipova
Copy link
Contributor Author

So there is already a versioned badge, and this PR is adding a new one?

We need this check in case when parent DataObject has Versioned extension and has current status DRAFT or any other status than in child / grandchild objects, since this badge will be provided in Versioned extension. In another cases, I assume we should add this badge only if parent object doesn't have Versioned extension, but child / grandchild objects does.

Is the original status badge wrong?

We have the original status badge only if parent object has Versioned extension.

Where is the code for the original status badge. Would it make sense to move this code there, or at least deprecate the old code since it's presumably wrong?

All status badges are part of Versioned extension. So the main problem that require these changes it's if the parent object in the relations doesn't have Versioned extension

@michalkleiner
Copy link
Contributor

Wouldn't it be confusing if the parent object doesn't have Versioned extension and would still show Modified? Perhaps we need another label when it's just the children?

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

4 participants