Skip to content

Commit d7f4f25

Browse files
committed
chore: Merge remote-tracking branch 'upstream/master' into feat-add-additional-script-macro
2 parents ab33066 + 252eada commit d7f4f25

File tree

7 files changed

+47
-6
lines changed

7 files changed

+47
-6
lines changed

phpstan.neon.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ parameters:
1515
- identifier: binaryOp.invalid
1616
- identifier: return.type
1717
- identifier: argument.type
18+
- identifier: offsetAccess.nonOffsetAccessible
1819

1920
excludePaths:
2021
- ./src/Html/Fluent.php

src/Html/Builder.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Contracts\Config\Repository;
66
use Illuminate\Contracts\View\Factory;
77
use Illuminate\Support\Collection;
8+
use Illuminate\Support\Facades\Gate;
89
use Illuminate\Support\HtmlString;
910
use Illuminate\Support\Traits\Macroable;
1011
use Yajra\DataTables\Utilities\Helper;
@@ -264,6 +265,20 @@ public function addScript(string $view): static
264265
return $this;
265266
}
266267

268+
public function addScriptIfCannot(string $ability, string $view): static
269+
{
270+
if (! (Gate::allows($ability))) {
271+
$this->addScript($view);
272+
}
273+
274+
return $this;
275+
}
276+
277+
public function getTemplate(): string
278+
{
279+
return $this->template;
280+
}
281+
267282
public function getAdditionalScripts(): array
268283
{
269284
return $this->additionalScripts;

src/Html/Button.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,4 +459,18 @@ public function __call($method, $parameters)
459459

460460
return $this;
461461
}
462+
463+
/**
464+
* Request that the data be refreshed from the server when starting an edit.
465+
*
466+
* @return $this
467+
*
468+
* @see https://editor.datatables.net/reference/type/form-options#refresh
469+
*/
470+
public function refresh(bool $value = true): static
471+
{
472+
$this->attributes['refresh'] = $value;
473+
474+
return $this;
475+
}
462476
}

src/Html/Editor/FormOptions.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,18 @@ public function title(bool|string $value): static
205205

206206
return $this;
207207
}
208+
209+
/**
210+
* Request that the data be refreshed from the server when starting an edit.
211+
*
212+
* @return $this
213+
*
214+
* @see https://editor.datatables.net/reference/type/form-options#refresh
215+
*/
216+
public function refresh(bool $value = true): static
217+
{
218+
$this->attributes['refresh'] = $value;
219+
220+
return $this;
221+
}
208222
}

src/Html/HasEditor.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ trait HasEditor
88
{
99
/**
1010
* Collection of Editors.
11+
*
12+
* @var array<array-key, Editor>
1113
*/
1214
protected array $editors = [];
1315

src/Html/Options/Plugins/ColumnControl.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ public function columnControlFooterSearch(array $content = []): static
7777

7878
public function columnControlSearchDropdown(int|string $target = 0): static
7979
{
80-
$this->addColumnControl($target, ['order', 'searchDropdown'])
81-
->ordering(['indicators' => false, 'handler' => false]);
80+
$this->addColumnControl($target, ['order', 'searchDropdown']);
8281

8382
return $this;
8483
}

tests/Html/Extensions/ColumnControlTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ public function it_can_add_column_control_search_dropdown()
143143
['target' => 1, 'content' => ['order', 'searchDropdown']],
144144
];
145145
$this->assertEquals($expected, $builder->getAttributes()['columnControl']);
146-
147-
// Should also set ordering options
148-
$attributes = $builder->getAttributes();
149-
$this->assertEquals(['indicators' => false, 'handler' => false], $attributes['ordering']);
150146
}
151147

152148
#[Test]

0 commit comments

Comments
 (0)