Skip to content

feat: add Editor 2.4.0 tags field support #232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ parameters:

ignoreErrors:
- '#Unsafe usage of new static\(\).#'
- identifier: missingType.generics
- identifier: missingType.iterableValue

excludePaths:

checkMissingIterableValueType: false

checkGenericClassInNonGenericObjectType: false
- ./src/Html/Fluent.php
143 changes: 143 additions & 0 deletions src/Html/Editor/Fields/Tags.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<?php

namespace Yajra\DataTables\Html\Editor\Fields;

use Illuminate\Contracts\Support\Arrayable;

/**
* @see https://editor.datatables.net/reference/field/tags
*/
class Tags extends Field
{
protected string $type = 'tags';

/**
* @see https://editor.datatables.net/reference/field/tags#ajax
*/
public function ajax(bool|string|null $url = true): static
{
$this->attributes['ajax'] = $url;

return $this;
}

/**
* @see https://editor.datatables.net/reference/field/tags#display
*/
public function display(string $display): static
{
$this->attributes['display'] = $display;

return $this;
}

/**
* @see https://editor.datatables.net/reference/field/tags#escapeLabelHtml
*/
public function escapeLabelHtml(bool $escape): static
{
$this->attributes['escapeLabelHtml'] = $escape;

return $this;
}

/**
* @see https://editor.datatables.net/reference/field/tags#i18n
*/
public function i18n(array $i18n): static
{
$options = isset($this->attributes['i18n'])
? (array) $this->attributes['i18n']
: [];

$this->attributes['i18n'] = array_merge($options, $i18n);

return $this;
}

/**
* @see https://editor.datatables.net/reference/field/tags#i18n
*/
public function addButton(string $text): static
{
return $this->i18n(['addButton' => $text]);
}

/**
* @see https://editor.datatables.net/reference/field/tags#i18n
*/
public function inputPlaceholder(string $text): static
{
return $this->i18n(['inputPlaceholder' => $text]);
}

/**
* @see https://editor.datatables.net/reference/field/tags#i18n
*/
public function noResults(string $text): static
{
return $this->i18n(['noResults' => $text]);
}

/**
* @see https://editor.datatables.net/reference/field/tags#i18n
*/
public function title(string $text): static
{
return $this->i18n(['title' => $text]);
}

/**
* @see https://editor.datatables.net/reference/field/tags#i18n
*/
public function placeholder(string $text): static
{
return $this->i18n(['placeholder' => $text]);
}

/**
* @see https://editor.datatables.net/reference/field/tags#limit
*/
public function limit(int $limit): static
{
$this->attributes['limit'] = $limit;

return $this;
}

/**
* @see https://editor.datatables.net/reference/field/tags#multiple
*/
public function multiple(bool $multiple = true): static
{
$this->attributes['multiple'] = $multiple;

return $this;
}

/**
* @see https://editor.datatables.net/reference/field/tags#options
*/
public function options(array|Arrayable $options): static
{
return parent::options($options);
}

/**
* @see https://editor.datatables.net/reference/field/tags#separator
*/
public function separator(string $separator = ','): static
{
return parent::separator($separator);
}

/**
* @see https://editor.datatables.net/reference/field/tags#unique
*/
public function unique(bool $unique = true): static
{
$this->attributes['unique'] = $unique;

return $this;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace Yajra\DataTables\Html\Tests;
namespace Yajra\DataTables\Html\Tests\Html\Builder;

use PHPUnit\Framework\Attributes\Test;
use Yajra\DataTables\Html\Tests\TestCase;

class BuilderOptionsLanguageTest extends TestCase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

namespace Yajra\DataTables\Html\Tests;
namespace Yajra\DataTables\Html\Tests\Html\Builder;

use PHPUnit\Framework\Attributes\Test;
use Yajra\DataTables\Html\Builder;
use Yajra\DataTables\Html\Button;
use Yajra\DataTables\Html\SearchPane;
use Yajra\DataTables\Html\Tests\TestCase;

class BuilderOptionsPluginsTest extends TestCase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

namespace Yajra\DataTables\Html\Tests;
namespace Yajra\DataTables\Html\Tests\Html\Builder;

use PHPUnit\Framework\Attributes\Test;
use Yajra\DataTables\Html\Builder;
use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Html\Tests\TestCase;

class BuilderOptionsTest extends TestCase
{
Expand Down
3 changes: 2 additions & 1 deletion tests/BuilderTest.php → tests/Html/Builder/BuilderTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Yajra\DataTables\Html\Tests;
namespace Yajra\DataTables\Html\Tests\Html\Builder;

use Illuminate\Support\HtmlString;
use PHPUnit\Framework\Attributes\Test;
Expand All @@ -9,6 +9,7 @@
use Yajra\DataTables\Html\ColumnDefinition;
use Yajra\DataTables\Html\ColumnDefinitions;
use Yajra\DataTables\Html\Editor\Editor;
use Yajra\DataTables\Html\Tests\TestCase;

class BuilderTest extends TestCase
{
Expand Down
3 changes: 2 additions & 1 deletion tests/LayoutTest.php → tests/Html/Builder/LayoutTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

namespace Yajra\DataTables\Html\Tests;
namespace Yajra\DataTables\Html\Tests\Html\Builder;

use InvalidArgumentException;
use Livewire\Exceptions\ComponentNotFoundException;
use PHPUnit\Framework\Attributes\Test;
use Yajra\DataTables\Html\Builder;
use Yajra\DataTables\Html\Enums\LayoutPosition;
use Yajra\DataTables\Html\Layout;
use Yajra\DataTables\Html\Tests\TestCase;
use Yajra\DataTables\Html\Tests\TestComponents\TestInlineView;
use Yajra\DataTables\Html\Tests\TestComponents\TestLivewire;
use Yajra\DataTables\Html\Tests\TestComponents\TestView;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

namespace Yajra\DataTables\Html\Tests;
namespace Yajra\DataTables\Html\Tests\Html\Column;

use PHPUnit\Framework\Attributes\Test;
use Yajra\DataTables\Html\ColumnDefinition;
use Yajra\DataTables\Html\Tests\TestCase;

class ColumnDefinitionTest extends TestCase
{
Expand Down
3 changes: 2 additions & 1 deletion tests/ColumnTest.php → tests/Html/Column/ColumnTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

namespace Yajra\DataTables\Html\Tests;
namespace Yajra\DataTables\Html\Tests\Html\Column;

use PHPUnit\Framework\Attributes\Test;
use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Html\Tests\TestCase;

class ColumnTest extends TestCase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

namespace Yajra\DataTables\Html\Tests;
namespace Yajra\DataTables\Html\Tests\Html\Editor;

use PHPUnit\Framework\Attributes\Test;
use Yajra\DataTables\Html\Editor\FormOptions;
use Yajra\DataTables\Html\Tests\TestCase;

class EditorFormOptionsTest extends TestCase
{
Expand Down
3 changes: 2 additions & 1 deletion tests/EditorTest.php → tests/Html/Editor/EditorTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

namespace Yajra\DataTables\Html\Tests;
namespace Yajra\DataTables\Html\Tests\Html\Editor;

use PHPUnit\Framework\Attributes\Test;
use Yajra\DataTables\Html\Editor\Editor;
use Yajra\DataTables\Html\Editor\Fields\Text;
use Yajra\DataTables\Html\Tests\TestCase;

class EditorTest extends TestCase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

namespace Yajra\DataTables\Html\Tests;
namespace Yajra\DataTables\Html\Tests\Html\Editor\Fields;

use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use PHPUnit\Framework\Attributes\Test;
use Yajra\DataTables\Html\Editor\Fields\Options;
use Yajra\DataTables\Html\Tests\Models\User;
use Yajra\DataTables\Html\Tests\TestCase;

class FieldOptionsTest extends TestCase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

namespace Yajra\DataTables\Html\Tests;
namespace Yajra\DataTables\Html\Tests\Html\Editor\Fields;

use PHPUnit\Framework\Attributes\Test;
use Yajra\DataTables\Html\Editor\Fields;
use Yajra\DataTables\Html\Tests\Models\User;
use Yajra\DataTables\Html\Tests\TestCase;

class FieldTest extends TestCase
{
Expand Down
Loading
Loading