Skip to content

Commit

Permalink
FIX Bootstrap style for clear all button, and add paginator for LogVi…
Browse files Browse the repository at this point in the history
…ewerAdmin
  • Loading branch information
robbieaverill committed Jan 20, 2017
1 parent e8c0870 commit b47f286
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Admin/LogViewerAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SilverLeague\LogViewer\Forms\GridField\GridFieldClearAllButton;
use SilverStripe\Admin\ModelAdmin;
use SilverStripe\Forms\GridField\GridFieldAddNewButton;
use SilverStripe\Forms\GridField\GridFieldPaginator;
use SilverStripe\View\Requirements;

/**
Expand Down Expand Up @@ -65,6 +66,7 @@ public function getEditForm($id = null, $fields = null)
$config = $gridField->getConfig();
$config->removeComponentsByType($config->getComponentByType(GridFieldAddNewButton::class));
$config->addComponent(new GridFieldClearAllButton('buttons-before-left'));
$config->addComponent(new GridFieldPaginator);

return $form;
}
Expand Down
6 changes: 4 additions & 2 deletions src/Forms/GridField/GridFieldClearAllButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ public function getHTMLFragments($gridField)
{
$button = GridField_FormAction::create($gridField, 'clear', 'Clear all', 'clear', null);
$button->setAttribute('data-icon', 'clear-all-logs');
$button->addExtraClass('font-icon-trash-bin action_clear action action-delete');
$button->addExtraClass('font-icon-trash-bin action_clear action action-delete btn btn-secondary');
$button->setForm($gridField->getForm());

return [$this->targetFragment => '<p class="grid-clear-all-button">' . $button->Field() . '</p>'];
return [
$this->targetFragment => '<p class="grid-clear-all-button grid-print-button">' . $button->Field() . '</p>'
];
}

/**
Expand Down
12 changes: 12 additions & 0 deletions tests/Admin/LogViewerAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SilverLeague\LogViewer\Forms\GridField\GridFieldClearAllButton;
use SilverStripe\Dev\FunctionalTest;
use SilverStripe\Forms\GridField\GridFieldAddNewButton;
use SilverStripe\Forms\GridField\GridFieldPaginator;
use SilverStripe\Forms\ReadonlyField;

/**
Expand Down Expand Up @@ -66,6 +67,17 @@ public function testHasClearAllButton()
);
}

/**
* Test that the GridField has a Paginator component
*/
public function testHasPagination()
{
$this->assertInstanceOf(
GridFieldPaginator::class,
$this->getConfig()->getComponentByType(GridFieldPaginator::class)
);
}

/**
* Test that the entry and level fields are displayed in the GridField, and can be exported
*/
Expand Down
5 changes: 4 additions & 1 deletion tests/Forms/GridField/GridFieldClearAllButtonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class GridFieldClearAllButtonTest extends SapphireTest
*/
protected $usesDatabase = true;

/**
* @var GridField
*/
protected $gridField;

/**
Expand Down Expand Up @@ -66,7 +69,7 @@ public function testGetHtmlFragments()
$this->assertContains('Clear all', $fragments['before']);
$this->assertContains('clear-all-logs', $fragments['before']);
$this->assertContains('font-icon-trash-bin action_clear', $fragments['before']);
$this->assertContains('<p class="grid-clear-all-button">', $fragments['before']);
$this->assertContains('<p class="grid-clear-all-button grid-print-button">', $fragments['before']);
}

/**
Expand Down

0 comments on commit b47f286

Please sign in to comment.