workflow icon indicating copy to clipboard operation
workflow copied to clipboard

Add option to dashboard widget to show all submissions, or just for the current user

Open engram-design opened this issue 1 year ago • 2 comments

Currently, all submissions are shown in the dashboard widget, including ones users might not have access to, which isn't a good look. Add the option to show all, or just the ones that the current user is the editor/reviewer/publisher on.

engram-design avatar Feb 06 '24 11:02 engram-design

@engram-design That would be great!

We already needed this, so we built it as a custom widget that extends the built-in widget. Just leaving this here in case someone needs it:

use Craft;
use verbb\workflow\elements\Submission;
use verbb\workflow\widgets\Submissions;

class OwnSubmissions extends Submissions
{
    public static function displayName(): string
    {
        return Craft::t('custom_workflows', 'My submissions');
    }

    public function getBodyHtml(): ?string
    {
        $user = Craft::$app->user?->getIdentity();
        if (!$user) {
            return '';
        }
        $submissions = Submission::find()
            ->status($this->status)
            ->limit($this->limit)
            ->editorId($user->id)
            ->all();

        return Craft::$app->getView()->renderTemplate('workflow/_widget/body', [
            'submissions' => $submissions,
        ]);
    }
}

Might make sense to have it as a separate widget (as opposed to an option in the existing widget) so we can provide some users access to only this limited widget.

MoritzLost avatar Apr 05 '24 15:04 MoritzLost

Thanks for that! Yep, might be it's own separate widget, or just adding some settings to chose what to show. Appreciate it 👍

engram-design avatar Apr 05 '24 15:04 engram-design