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

WIP: NEW Add Title, Last Edited and Last Editor as default columns in all CMS reports #2234

Conversation

robbieaverill
Copy link
Contributor

@robbieaverill robbieaverill commented Aug 14, 2018

Adds more default columns to all CMS reports.

image

image

The "Last Editor" column isn't able to be exported to CSV though, which should probably block this being merged. This is because there's no dot notation link available to get from the page to the Member who saved the latest version of it.

Resolves silverstripe/silverstripe-reports#108

@clarkepaul
Copy link
Contributor

Nice one :)
Is the "Last editor" the same person as when it was last published, or could it be the person who last saved the item? I presume they match.

I think the column headers might make more sense if it was either:

  1. Last edited & Author (could be saved or published)
  2. Last published & Published by (only show last published)

With my preference being 1, and a shorter date format for smaller screens if it isn't a huge effort e.g. 2 August 2018, 11.06pm

],
'AuthorID' => [
'title' => _t(__CLASS__ . '.LastEditor', 'Last Editor'),
'formatting' => function ($value, SiteTree $item) {
Copy link
Member

Choose a reason for hiding this comment

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

If you added this as a getter to SiteTree, would that make it exportable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it would, but it's also couple it a bit more to versioned. I'm sure I can customise the export fields with callbacks, I just haven't looked at it enough yet 😆

@robbieaverill robbieaverill self-assigned this Aug 21, 2018
@robbieaverill robbieaverill changed the title NEW Add Title, Last Edited and Last Editor as default columns in all CMS reports WIP: NEW Add Title, Last Edited and Last Editor as default columns in all CMS reports Aug 21, 2018
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.

Silly idea. If you add this method to SiteTree, you can just replace the AuthorID col with LastEditor.Title. This fixed the CSV issue. Or we could add it to Versioned.

    /**
     * @return Member|null
     */
    public function LastEditor()
    {
        $latestVersion = Versioned::get_latest_version(SiteTree::class, $this->ID);
        if (!$latestVersion) {
            return null;
        }

        /** @var Member $member */
        return Member::get()->byID($latestVersion->AuthorID);
    }

/** @var Member $member */
$member = Member::get()->byID($latestVersion->AuthorID);
if ($member) {
return sprintf('%s %s', $member->FirstName, $member->Surname);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return sprintf('%s %s', $member->FirstName, $member->Surname);
return $member->Title;

@robbieaverill
Copy link
Contributor Author

I realise versioned is a dependency of the CMS and will always be, but it'd still be nice if I could achieve this without adding coupling to this module - will look at this again on hackday

@brynwhyman
Copy link

brynwhyman commented May 8, 2019

Another idea for an additional column would be the 'stage' of the page, ie published, published (with changes), or draft. This is something that's provided in https://github.com/silverstripe/silverstripe-sitewidecontent-report

@robbieaverill
Copy link
Contributor Author

I'm probably not going to get this finished, so closing, but I'll leave the branch around if anyone wants to use it later

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.

Context of report items being presented
5 participants