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

Add bulk actions #93

Merged
merged 2 commits into from
Dec 29, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,39 @@ textarea:focus, input[type="text"]:focus, input[type="password"]:focus, input[ty
}
.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1 {
@extend .span1;
}


// Custom edits for including btn-groups within btn-groups
// (useful for including dropdown buttons within a btn-group)
// https://github.com/twbs/bootstrap/issues/2140
.btn-group > .btn-group > .btn.dropdown-toggle {
margin-left: 0;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
border-radius: 0px;
}
.btn-group > .btn-group:last-child > .btn.dropdown-toggle {
margin-left: 0;
-webkit-border-top-right-radius: 4px;
-moz-border-radius-topright: 4px;
border-top-right-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
-moz-border-radius-bottomright: 4px;
border-bottom-right-radius: 4px;
border-left: 1px;
}
.btn-group > .btn-group:first-child > .btn.dropdown-toggle {
margin-right: 0;
-webkit-border-top-left-radius: 4px;
-moz-border-radius-topleft: 4px;
border-top-left-radius: 4px;
-webkit-border-bottom-left-radius: 4px;
-moz-border-radius-bottomleft: 4px;
border-bottom-left-radius: 4px;
border-right:1px;
}
// remove space between consecutive dropdown btn-groups.
.btn-group.dropdown+.btn-group.dropdown {
margin-left: 0;
}
16 changes: 16 additions & 0 deletions src/Kunstmaan/AdminListBundle/AdminList/AdminList.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,22 @@ public function getListActions()
return $this->configurator->getListActions();
}

/**
* @return array
*/
public function getBulkActions()
{
return $this->configurator->getBulkActions();
}

/**
* @return bool
*/
public function hasBulkActions()
{
return $this->configurator->hasBulkActions();
}

/**
* @return Pagerfanta
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Kunstmaan\AdminListBundle\AdminList\BulkAction;

/**
* A bulk action can be used to configure actions which can be executed on a selection of list rows.
*/
interface BulkActionInterface
{
/**
* @return array
*/
public function getUrl();

/**
* @return string
*/
public function getLabel();

/**
* @return string
*/
public function getIcon();

/**
* @return string
*/
public function getTemplate();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

namespace Kunstmaan\AdminListBundle\AdminList\BulkAction;

/**
* The simple bulk action is a default implementation of the bulk action interface, this can be used
* in very simple use cases.
*/
class SimpleBulkAction implements BulkActionInterface
{
/**
* @var array
*/
private $url;

/**
* @var string
*/
private $icon;

/**
* @var string
*/
private $label;

/**
* @var null|string
*/
private $template;

/**
* @param array $url The url path and parameters
* @param string $label The label
* @param string $icon The icon
* @param string $template The template
*/
public function __construct(array $url, $label, $icon = null, $template = null)
{
$this->url = $url;
$this->icon = $icon;
$this->label = $label;
$this->template = $template;
}

/**
* @return array
*/
public function getUrl()
{
return $this->url;
}

/**
* @return string
*/
public function getIcon()
{
return $this->icon;
}

/**
* @return string
*/
public function getLabel()
{
return $this->label;
}

/**
* @return string
*/
public function getTemplate()
{
return $this->template;
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
<?php

namespace Kunstmaan\AdminListBundle\AdminList\Configurator;

use Doctrine\ORM\PersistentCollection;
use InvalidArgumentException;

use Kunstmaan\AdminListBundle\AdminList\BulkAction\BulkActionInterface;
use Kunstmaan\AdminListBundle\AdminList\ListAction\ListActionInterface;
use Kunstmaan\AdminListBundle\AdminList\ItemAction\ItemActionInterface;
use Kunstmaan\AdminListBundle\AdminList\ItemAction\SimpleItemAction;
use Kunstmaan\AdminListBundle\AdminList\FilterType\FilterTypeInterface;
use Kunstmaan\AdminListBundle\AdminList\FilterBuilder;
use Kunstmaan\AdminListBundle\AdminList\Field;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\HttpFoundation\Request;

use Pagerfanta\Pagerfanta;

/**
* Abstract admin list configurator, this implements the most common functionality from the AdminListConfiguratorInterface
*/
Expand Down Expand Up @@ -46,6 +44,11 @@ abstract class AbstractAdminListConfigurator implements AdminListConfiguratorInt
*/
private $listActions = array();

/**
* @var BulkActionInterface[]
*/
private $bulkActions = array();

/**
* @var AbstractType
*/
Expand Down Expand Up @@ -402,6 +405,18 @@ public function getItemActions()
return $this->itemActions;
}

/**
* @param ListActionInterface $listAction
*
* @return AdminListConfiguratorInterface
*/
public function addListAction(ListActionInterface $listAction)
{
$this->listActions[] = $listAction;

return $this;
}

/**
* @return bool
*/
Expand All @@ -419,17 +434,33 @@ public function getListActions()
}

/**
* @param ListActionInterface $listAction
* @param BulkActionInterface $bulkAction
*
* @return AdminListConfiguratorInterface
*/
public function addListAction(ListActionInterface $listAction)
public function addBulkAction(BulkActionInterface $bulkAction)
{
$this->listActions[] = $listAction;
$this->bulkActions[] = $bulkAction;

return $this;
}

/**
* @return bool
*/
public function hasBulkActions()
{
return !empty($this->bulkActions);
}

/**
* @return BulkActionInterface[]
*/
public function getBulkActions()
{
return $this->bulkActions;
}

/**
* @return string
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
namespace Kunstmaan\AdminListBundle\AdminList\Configurator;

use InvalidArgumentException;

use Kunstmaan\AdminListBundle\AdminList\BulkAction\BulkActionInterface;
use Kunstmaan\AdminListBundle\AdminList\ListAction\ListActionInterface;
use Kunstmaan\AdminListBundle\AdminList\ItemAction\ItemActionInterface;
use Kunstmaan\AdminListBundle\AdminList\Field;
use Kunstmaan\AdminListBundle\AdminList\FilterBuilder;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\AbstractType;

use Pagerfanta\Pagerfanta;

/**
Expand Down Expand Up @@ -119,7 +117,6 @@ public function canAdd();
*/
public function canExport();


/**
* @return array
*/
Expand Down Expand Up @@ -155,6 +152,16 @@ public function hasListActions();
*/
public function getListActions();

/**
* @return bool
*/
public function hasBulkActions();

/**
* @return BulkActionInterface[]
*/
public function getBulkActions();

/**
* @param array|object $item The item
* @param string $columnName The column name
Expand Down

This file was deleted.

Loading