• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

contributte / datagrid / 8685602316

13 Mar 2024 12:24PM UTC coverage: 34.102%. Remained the same
8685602316

push

github

web-flow
[7.x] Next (#1060)

* PHP 8.0

* Translator: switch from ITranslator to Translator (#973)

* [7.x] Bootstrap 5 + PHP 8 + vanilla javascript (#1021)

* Bootstrap 5

* Bootstrap 5 (docs)

* Bootstrap 5

* form-control -> form-select

* Bump bootstrap-select for Bootstrap 5 support

* Removed `input-sm` from Bootstrap 3

See https://getbootstrap.com/docs/4.0/migration/#forms-1

* Bootstrap 5: When selectpicker, replace form-select classes with form-control and refresh it

* Hide `underline` also for `dropdown-item`. And merged into one CSS rule.

* Update the filterMultiSelect initialization

* Text-align: left -> start

Co-authored-by: Radim Vaculík <radim.vaculik@gmail.com>
Co-authored-by: Jaroslav Líbal <jaroslav.libal@neatous.cz>

* [7.x] phpstan-deprecation-rules (#1061)

* Fix sort

* Add method for setting custom Action href, v6.x (#853)

* [7.x] Nextras ORM 4 support, closes #984

* Fix ElasticsearchDataSource.php data source (#1041)

* Error: Typed property Ublaboo\DataGrid\InlineEdit\InlineEdit::$itemID must not be accessed before initialization

* composer: allow-plugins: php-http/discovery

* ItemDetailForm: $httpPost: Typed property must not be accessed...

* phpstan: revert  --memory-limit=4G

* NetteDatabaseSelectionHelper: Context -> Explorer, getSupplementalDriver -> getDriver

* Update README.md

* Templates: fix variables

* data-bs-toggle attribute for multiaction button (#1072)

* dependabot.yml (#1078)

* Allow nette/utils:4.0 (#1077)

* Add onColumnShow and onColumnHide event methods (#1076)

* Add onColumnShow and onColumnHide event methods

* Add native type array

* Removed duplicity

* Return value of BackedEnum when reading Doctrine entity property. (#1081)

* Return value of BackedEnum when reading array value (#1083)

* Added method to check if filter is on default values; Closes #1082 (#1084)

* ublaboo -> contributte (#1067) (#1075)

* Delete depe... (continued)

117 of 435 new or added lines in 54 files covered. (26.9%)

1455 existing lines in 67 files now uncovered.

1124 of 3296 relevant lines covered (34.1%)

0.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

37.84
/src/Export/Export.php
1
<?php declare(strict_types = 1);
2

3
namespace Contributte\Datagrid\Export;
4

5
use Contributte\Datagrid\Datagrid;
6
use Contributte\Datagrid\Traits\TButtonClass;
7
use Contributte\Datagrid\Traits\TButtonIcon;
8
use Contributte\Datagrid\Traits\TButtonText;
9
use Contributte\Datagrid\Traits\TButtonTitle;
10
use Contributte\Datagrid\Traits\TButtonTryAddIcon;
11
use Nette\Application\UI\Link;
12
use Nette\Utils\Html;
13

14
class Export
15
{
16

17
        use TButtonTryAddIcon;
18
        use TButtonIcon;
19
        use TButtonClass;
20
        use TButtonTitle;
21
        use TButtonText;
22

23
        /** @var callable */
24
        protected $callback;
25

26
        protected bool $ajax = false;
27

28
        protected ?Link $link = null;
29

30
        protected array $columns = [];
31

32
        protected ?string $confirmDialog = null;
33

34
        protected ?string $target = null;
35

36
        public function __construct(
1✔
37
                protected Datagrid $grid,
38
                string $text,
39
                callable $callback,
40
                protected bool $filtered
41
        )
42
        {
43
                $this->text = $text;
1✔
44
                $this->callback = $callback;
1✔
45
                $this->title = $text;
1✔
46
        }
1✔
47

48
        public function render(): Html
49
        {
50
                $a = Html::el('a', [
×
UNCOV
51
                        'class' => [$this->class],
×
UNCOV
52
                        'title' => $this->grid->getTranslator()->translate($this->getTitle()),
×
UNCOV
53
                        'href' => $this->link,
×
UNCOV
54
                        'target' => $this->target,
×
55
                ]);
56

UNCOV
57
                $this->tryAddIcon(
×
UNCOV
58
                        $a,
×
UNCOV
59
                        $this->getIcon(),
×
60
                        $this->grid->getTranslator()->translate($this->getTitle())
×
61
                );
62

UNCOV
63
                $a->addText($this->grid->getTranslator()->translate($this->text));
×
64

UNCOV
65
                if ($this->isAjax()) {
×
UNCOV
66
                        $a->appendAttribute('class', 'ajax');
×
67
                }
68

UNCOV
69
                if ($this->confirmDialog !== null) {
×
UNCOV
70
                        $a->setAttribute('data-datagrid-confirm', $this->confirmDialog);
×
71
                }
72

UNCOV
73
                return $a;
×
74
        }
75

76
        /**
77
         * @return static
78
         */
79
        public function setConfirmDialog(string $confirmDialog): self
80
        {
UNCOV
81
                $this->confirmDialog = $confirmDialog;
×
82

UNCOV
83
                return $this;
×
84
        }
85

86
        /**
87
         * Tell export which columns to use when exporting data
88
         *
89
         * @return static
90
         */
91
        public function setColumns(array $columns): self
92
        {
UNCOV
93
                $this->columns = $columns;
×
94

UNCOV
95
                return $this;
×
96
        }
97

98
        /**
99
         * Get columns for export
100
         */
101
        public function getColumns(): array
102
        {
103
                return $this->columns;
1✔
104
        }
105

106
        /**
107
         * Export signal url
108
         *
109
         * @return static
110
         */
111
        public function setLink(Link $link): self
1✔
112
        {
113
                $this->link = $link;
1✔
114

115
                return $this;
1✔
116
        }
117

118
        /**
119
         * Tell export whether to be called via ajax or not
120
         *
121
         * @return static
122
         */
123
        public function setAjax(bool $ajax = true): self
124
        {
UNCOV
125
                $this->ajax = $ajax;
×
126

UNCOV
127
                return $this;
×
128
        }
129

130
        public function isAjax(): bool
131
        {
132
                return $this->ajax;
1✔
133
        }
134

135
        /**
136
         * Is export filtered?
137
         */
138
        public function isFiltered(): bool
139
        {
140
                return $this->filtered;
1✔
141
        }
142

143
        /**
144
         * Call export callback
145
         */
146
        public function invoke(iterable $data): void
1✔
147
        {
148
                ($this->callback)($data, $this->grid);
1✔
149
        }
1✔
150

151
        /**
152
         * Adds target to html:a [_blank, _self, _parent, _top]
153
         */
154
        public function setTarget(?string $target = null): void
155
        {
UNCOV
156
                if (in_array($target, ['_blank', '_self', '_parent', '_top'], true)) {
×
UNCOV
157
                        $this->target = $target;
×
158
                }
159
        }
160

161
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc