Skip to content

Commit e3bd6e1

Browse files
committed
chore: Merge remote-tracking branch 'upstream/master' into feat-add-script-if-can-method
2 parents ed39d32 + d24dfd2 commit e3bd6e1

File tree

7 files changed

+60
-6
lines changed

7 files changed

+60
-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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,32 @@ public function addScriptIfCan(string $permission, string $view): static
273273

274274
return $this;
275275
}
276+
277+
public function addScriptIf(bool $condition, string $view): static
278+
{
279+
if ($condition) {
280+
$this->addScript($view);
281+
}
282+
283+
return $this;
284+
}
285+
286+
public function addScriptIfCannot(string $ability, string $view): static
287+
{
288+
if (Gate::denies($ability)) {
289+
$this->addScript($view);
290+
}
291+
292+
return $this;
293+
}
294+
295+
public function getTemplate(): string
296+
{
297+
return $this->template;
298+
}
299+
300+
public function getAdditionalScripts(): array
301+
{
302+
return $this->additionalScripts;
303+
}
276304
}

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)