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

Creating and managing additional table actions #1202

Merged
merged 4 commits into from
Oct 29, 2021
Merged

Creating and managing additional table actions #1202

merged 4 commits into from
Oct 29, 2021

Conversation

afatmustafa
Copy link
Contributor

@afatmustafa afatmustafa commented Oct 15, 2021

This PR adds creating and managing additional table actions within the {moduleName}Controller

Description

This feature is actually available in Twill, called "filterLinks", but this PR gives you a more flexible environment while adding additional table actions.

Using Scenario

Imagine you have a newsletter module, for user convenience you want to provide options such as "Send Email", "Edit Email Template" and "Export List" in this table. and at that moment this feature will save you.

Usage

Usage is very simple, just go to the module's controller, use additionalTableActions function and return an array.

   public function additionalTableActions()
    {
        return [
            'exportAction' => [ // Action name.
                'name' => 'Export Newsletter List', // Button action title.
                'variant' => 'primary', // Button style variant. Available variants; primary, secondary, action, editor, validate, aslink, aslink-grey, warning, ghost, outline, tertiary
                'size' => 'small', // Button size. Available sizes; small
                'link' => route('newsletter.export'), // Button action link.
                'target' => '', // Leave it blank for self.
                'type' => 'a', // Leave it blank for "button".
            ]
        ];
    }

Example

In App\Http\Controllers\Admin\NewsletterController.php

    public function additionalTableActions()
    {
        return [
            'sendEmail' => [
                'name' => 'Send Email',
                'variant' => 'action',
                'size' => 'small',
                'link' => route('newsletter.sendEmail'),
                'target' => '',
                'type' => 'a',
            ],
            'editEmailTemplate' => [
                'name' => 'Edit Email Template',
                'variant' => 'primary',
                'size' => 'small',
                'link' => route('newsletter.editEmailTemplate'),
                'target' => '',
                'type' => 'a',
            ],
            'exportAction' => [
                'name' => 'Export List',
                'variant' => 'secondary',
                'size' => 'small',
                'link' => route('newsletter.export'),
                'target' => '',
                'type' => 'a',
            ],
        ];
    }

Ekran Resmi 2021-10-15 22 54 40

This PR adds creating and managing additional table actions within the {moduleName}Controller
@afatmustafa afatmustafa changed the title Add additional table actions Creating and managing additional table actions Oct 15, 2021
Copy link
Contributor

@pboivin pboivin left a comment

Choose a reason for hiding this comment

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

Hi @afatmustafa, thank you for this PR and the detailed description! I think this is definitely an improvement over $filterLinks.

I have included a few comments on specific sections.

src/Http/Controllers/Admin/ModuleController.php Outdated Show resolved Hide resolved
views/layouts/listing.blade.php Outdated Show resolved Hide resolved
views/layouts/listing.blade.php Outdated Show resolved Hide resolved
afatmustafa and others added 3 commits October 21, 2021 01:19
Co-authored-by: Patrick Boivin <pboivin@gmail.com>
Co-authored-by: afatmustafa <mustafa@afat.me>
Co-authored-by: afatmustafa <mustafa@afat.me>
@pboivin pboivin requested a review from ifox October 28, 2021 16:18
@pboivin pboivin merged commit 928cc82 into area17:2.x Oct 29, 2021
@pboivin pboivin mentioned this pull request Nov 1, 2021
@afatmustafa afatmustafa deleted the add-additional-table-actions branch April 25, 2022 19:38
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.

3 participants