Skip to content

Commit cc72ef8

Browse files
Add icons options to HelloBootstrapTable (#18)
Add "icons" option to HelloBootstrapTable Add "icons" option to Configuration Add "child" OptionResolver to "icons" Update Readme Rebuild assets
1 parent 2746dda commit cc72ef8

6 files changed

Lines changed: 115 additions & 50 deletions

File tree

README.md

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Used bootstrap-table version 1.18.3.
66

7-
Inspired by [SgDatatablesBundle](https://github.com/stwe/DatatablesBundle).
7+
Inspired by [SgDatatablesBundle](https://github.com/stwe/DatatablesBundle) and [omines/datatables-bundle](https://github.com/omines/datatables-bundle)
88

99
## Overview
1010

@@ -662,38 +662,59 @@ Table Dataset are provided directly to the `bootstrap-table` as data-attributes
662662

663663
#### Options
664664

665-
| Option | Type | Default |
666-
| -------------------------- | ------ | ----------------------------------------------------------- |
667-
| pagination | bool | true |
668-
| search | bool | true |
669-
| show-columns | bool | true |
670-
| show-footer | bool | true |
671-
| filter-control | bool | false |
672-
| show-refresh | bool | true |
673-
| toolbar | string | "#toolbar" |
674-
| page-list | string | "[10, 25, 50, 100, 200, 500, All]" |
675-
| page-size | int | 25 |
676-
| sort-reset | bool | true |
677-
| pagination-V-Align | string | "both" |
678-
| undefined-text | string | "" |
679-
| locale | string | "en-US" |
680-
| advanced-search | bool | true |
681-
| id-table | string | class name of table with counter. (`$this->getTableName()`) |
682-
| icons-prefix | string | "fa" |
683-
| click-to-select | bool | true |
684-
| show-jump-to | bool | true |
685-
| show-export | bool | true |
686-
| export-types | string | "['csv', 'txt'', 'excel']" |
687-
| export-options | array | see under table* |
688-
| detail-view | bool | false |
689-
| detail-formatter | string | "" |
690-
| detail-view-align | string | "" |
691-
| detail-view-icon | bool | true |
692-
| detail-view-by-click | bool | false |
693-
| sticky-header | bool | true |
694-
| sticky-header-offset-left | int | 0 |
695-
| sticky-header-offset-right | int | 0 |
696-
| sticky-header-offset-y | int | 0 |
665+
| Option | Type | Default |
666+
| -------------------------- | ------ | ---------------------------------------------- |
667+
| pagination | bool | true |
668+
| search | bool | true |
669+
| show-columns | bool | true |
670+
| show-footer | bool | true |
671+
| filter-control | bool | false |
672+
| show-refresh | bool | true |
673+
| toolbar | string | "#toolbar" |
674+
| page-list | string | "[10, 25, 50, 100, 200, 500, All]" |
675+
| page-size | int | 25 |
676+
| sort-reset | bool | true |
677+
| pagination-V-Align | string | "both" |
678+
| undefined-text | string | "" |
679+
| locale | string | "en-US" |
680+
| advanced-search | bool | true |
681+
| id-table | string | class name of table. (`$this->getTableName()`) |
682+
| icons-prefix | string | "fa" |
683+
| icons | array | see under table* |
684+
| click-to-select | bool | true |
685+
| show-jump-to | bool | true |
686+
| show-export | bool | true |
687+
| export-types | string | "['csv', 'txt'', 'excel']" |
688+
| export-options | array | see under table* |
689+
| detail-view | bool | false |
690+
| detail-formatter | string | "" |
691+
| detail-view-align | string | "" |
692+
| detail-view-icon | bool | true |
693+
| detail-view-by-click | bool | false |
694+
| sticky-header | bool | true |
695+
| sticky-header-offset-left | int | 0 |
696+
| sticky-header-offset-right | int | 0 |
697+
| sticky-header-offset-y | int | 0 |
698+
699+
`icons`:
700+
701+
| Option | Type | Default |
702+
| -------------------- | ------ | ------------------------ |
703+
| advancedSearchIcon | string | "fa-filter" |
704+
| paginationSwitchDown | string | "fa-caret-square-o-down" |
705+
| paginationSwitchUp | string | "fa-caret-square-o-up" |
706+
| columns | string | "fa-columns" |
707+
| refresh | string | "fa-sync" |
708+
| export | string | "fa-download" |
709+
| detailOpen | string | "fa-plus" |
710+
| detailClose | string | "fa-minus" |
711+
| toggleOff | string | "fa-toggle-off" |
712+
| toggleOn | string | "fa-toggle-on" |
713+
| fullscreen | string | "fa-arrows-alt" |
714+
| search | string | "fa-search" |
715+
| clearSearch | string | "fa-trash" |
716+
717+
697718

698719
`export-options`:
699720

assets/app.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,6 @@ $(function () {
7575
params.isCallback = true;
7676
params.tableName = tableName;
7777
return params;
78-
},
79-
icons: {
80-
advancedSearchIcon: 'fa-filter',
81-
paginationSwitchDown: 'fa-caret-square-o-down',
82-
paginationSwitchUp: 'fa-caret-square-o-up',
83-
columns: 'fa-columns',
84-
refresh: 'fa-sync',
85-
export: 'fa-download',
86-
detailOpen: 'fa-plus',
87-
detailClose: 'fa-minus',
88-
toggleOff: 'fa-toggle-off',
89-
toggleOn: 'fa-toggle-on',
90-
fullscreen: 'fa-arrows-alt',
91-
search: 'fa-search',
92-
clearSearch: 'fa-trash'
9378
}
9479
});
9580

src/DependencyInjection/Configuration.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ private function addTableDatasetOptions()
9393
->scalarNode('locale')->end()
9494
->booleanNode('advanced-search')->end()
9595
->scalarNode('id-table')->end()
96+
->scalarNode('icons-prefix')->end()
97+
->append($this->addIconsOptions())
9698
->booleanNode('click-to-select')->end()
9799
->booleanNode('show-jump-to')->end()
98100
->booleanNode('show-export')->end()
@@ -110,4 +112,31 @@ private function addTableDatasetOptions()
110112

111113
return $node;
112114
}
115+
116+
private function addIconsOptions()
117+
{
118+
$treeBuilder = new TreeBuilder('icons');
119+
$node = $treeBuilder->getRootNode();
120+
121+
$node
122+
->addDefaultsIfNotSet()
123+
->normalizeKeys(false)
124+
->children()
125+
->scalarNode('advancedSearchIcon')->end()
126+
->scalarNode('paginationSwitchDown')->end()
127+
->scalarNode('paginationSwitchUp')->end()
128+
->scalarNode('columns')->end()
129+
->scalarNode('refresh')->end()
130+
->scalarNode('export')->end()
131+
->scalarNode('detailOpen')->end()
132+
->scalarNode('detailClose')->end()
133+
->scalarNode('toggleOff')->end()
134+
->scalarNode('toggleOn')->end()
135+
->scalarNode('fullscreen')->end()
136+
->scalarNode('search')->end()
137+
->scalarNode('clearSearch')->end()
138+
->end();
139+
140+
return $node;
141+
}
113142
}

src/HelloBootstrapTable.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,35 @@ protected function configureTableDataset(OptionsResolver $resolver)
265265
"advanced-search" => true,
266266
"id-table" => $this->getTableName(),
267267
"icons-prefix" => "fa",
268+
"icons" => function (OptionsResolver $resolver) {
269+
$resolver->setDefaults(array(
270+
"advancedSearchIcon" => "fa-filter",
271+
"paginationSwitchDown" => "fa-caret-square-o-down",
272+
"paginationSwitchUp" => "fa-caret-square-o-up",
273+
"columns" => "fa-columns",
274+
"refresh" => "fa-sync",
275+
"export" => "fa-download",
276+
"detailOpen" => "fa-plus",
277+
"detailClose" => "fa-minus",
278+
"toggleOff" => "fa-toggle-off",
279+
"toggleOn" => "fa-toggle-on",
280+
"fullscreen" => "fa-arrows-alt",
281+
"search" => "fa-search",
282+
"clearSearch" => "fa-trash"
283+
));
284+
285+
$resolver->setAllowedTypes("advancedSearchIcon", ["string"]);
286+
$resolver->setAllowedTypes("paginationSwitchDown", ["string"]);
287+
$resolver->setAllowedTypes("columns", ["string"]);
288+
$resolver->setAllowedTypes("refresh", ["string"]);
289+
$resolver->setAllowedTypes("export", ["string"]);
290+
$resolver->setAllowedTypes("detailOpen", ["string"]);
291+
$resolver->setAllowedTypes("toggleOff", ["string"]);
292+
$resolver->setAllowedTypes("toggleOn", ["string"]);
293+
$resolver->setAllowedTypes("fullscreen", ["string"]);
294+
$resolver->setAllowedTypes("search", ["string"]);
295+
$resolver->setAllowedTypes("clearSearch", ["string"]);
296+
},
268297

269298
//extensions
270299
"click-to-select" => true,
@@ -304,6 +333,7 @@ protected function configureTableDataset(OptionsResolver $resolver)
304333
$resolver->setAllowedTypes("pagination-V-Align", ["string"]);
305334
$resolver->setAllowedTypes("undefined-text", ["string"]);
306335
$resolver->setAllowedTypes("icons-prefix", ["string"]);
336+
$resolver->setAllowedTypes("icons", ["array"]);
307337
$resolver->setAllowedTypes("locale", ["string"]);
308338
$resolver->setAllowedTypes("advanced-search", ["bool"]);
309339
$resolver->setAllowedTypes("id-table", ["string"]);

src/Resources/public/bootstrap-table.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Twig/BootstrapTableTwigExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class BootstrapTableTwigExtension extends AbstractExtension
1515
{
16-
const ASSET_VERSION = "1";
16+
const ASSET_VERSION = "2";
1717

1818
/**
1919
* {@inheritdoc}

0 commit comments

Comments
 (0)