Skip to content

Commit

Permalink
Merge branch 'bezhanSalleh:3.x' into 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
igwen6w authored Feb 5, 2024
2 parents 9ec57b2 + 2a200ef commit 1d0708e
Show file tree
Hide file tree
Showing 10 changed files with 370 additions and 199 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

All notable changes to `filament-shield` will be documented in this file.

## 3.2.1 - 2024-01-25

**Full Changelog**: https://github.com/bezhanSalleh/filament-shield/compare/3.2.0...3.2.1

## 3.2.0 - 2024-01-24

### What's Changed

* Feature/performance boost by @bezhanSalleh in https://github.com/bezhanSalleh/filament-shield/pull/319

> Filament `v3.2`
Republish `RoleResource`

* Update filament-shield.php by @noxoua in https://github.com/bezhanSalleh/filament-shield/pull/312

* Add traditional chinese translation by @cssf998811 in https://github.com/bezhanSalleh/filament-shield/pull/321


### New Contributors

* @noxoua made their first contribution in https://github.com/bezhanSalleh/filament-shield/pull/312
* @cssf998811 made their first contribution in https://github.com/bezhanSalleh/filament-shield/pull/321

**Full Changelog**: https://github.com/bezhanSalleh/filament-shield/compare/3.1.3...3.2.0

## 3.1.3 - 2024-01-12

### What's Changed
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
],
"require": {
"php": "^8.1",
"filament/filament": "^3.0",
"filament/filament": "^3.2",
"spatie/laravel-package-tools": "^1.9",
"spatie/laravel-permission": "^6.0"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.0",
"nunomaduro/larastan": "^2.1",
"larastan/larastan": "^2.0",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.10",
"phpstan/extension-installer": "^1.3",
Expand Down
28 changes: 14 additions & 14 deletions resources/lang/uk/filament-shield.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
|------------------------------------------------- -------------------------
*/

'column.name' => 'Ім\'я',
'column.guard_name' => 'Ім\'я гварда',
'column.name' => 'Назва',
'column.guard_name' => 'Назва гварда',
'column.roles' => 'Ролі',
'column.permissions' => 'Дозволи',
'column.updated_at' => 'Оновлено',
Expand All @@ -19,8 +19,8 @@
|------------------------------------------------- -------------------------
*/

'field.name' => 'Ім\'я',
'field.guard_name' => 'Ім\'я гварда',
'field.name' => 'Назва',
'field.guard_name' => 'Назва гварда',
'field.permissions' => 'Дозволи',
'field.select_all.name' => 'Вибрати все',
'field.select_all.message' => 'Включити всі дозволи, які <span class="text-primary font-medium">Доступні</span> для цієї ролі',
Expand Down Expand Up @@ -65,16 +65,16 @@

'resource_permission_prefixes_labels' => [
'view' => 'Перегляд',
'view_any' => 'Може дивитися будь-яке',
'create' => 'Створення',
'update' => 'Оновлення',
'delete' => 'Видалення',
'delete_any' => 'Може видалити будь-який',
'force_delete' => 'Примусово видалити',
'force_delete_any' => 'Може примусово видалити будь-який',
'restore' => 'Відновлення',
'reorder' => 'Зміна порядку',
'restore_any' => 'Може відновити будь-який',
'view_any' => 'Перегляд будь-якого',
'create' => 'Створити',
'update' => 'Оновити',
'delete' => 'Видалити',
'delete_any' => 'Видалити будь-яке',
'force_delete' => 'Примусове видалення',
'force_delete_any' => 'Примусове видалення будь-якого',
'restore' => 'Відновити',
'reorder' => 'Змінити порядок',
'restore_any' => 'Відновити будь-яке',
'replicate' => 'Копіювати',
],
];
80 changes: 80 additions & 0 deletions resources/lang/zh_TW/filament-shield.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Table Columns
|--------------------------------------------------------------------------
*/

'column.name' => '角色名',
'column.guard_name' => '守衛',
'column.roles' => '角色',
'column.permissions' => '權限',
'column.updated_at' => '更新時間',

/*
|--------------------------------------------------------------------------
| Form Fields
|--------------------------------------------------------------------------
*/

'field.name' => '角色名',
'field.guard_name' => '守衛',
'field.permissions' => '權限',
'field.select_all.name' => '全選',
'field.select_all.message' => '啟用當前為該角色 <span class="text-primary font-medium">啟用的</span> 所有權限',

/*
|--------------------------------------------------------------------------
| Navigation & Resource
|--------------------------------------------------------------------------
*/

'nav.group' => 'Filament Shield',
'nav.role.label' => '角色',
'nav.role.icon' => 'heroicon-o-shield-check',
'resource.label.role' => '角色',
'resource.label.roles' => '角色',

/*
|--------------------------------------------------------------------------
| Section & Tabs
|--------------------------------------------------------------------------
*/

'section' => '實體',
'resources' => '資源',
'widgets' => '小工具',
'pages' => '頁面',
'custom' => '自訂',

/*
|--------------------------------------------------------------------------
| Messages
|--------------------------------------------------------------------------
*/

'forbidden' => '無權訪問',

/*
|--------------------------------------------------------------------------
| Resource Permissions' Labels
|--------------------------------------------------------------------------
*/

'resource_permission_prefixes_labels' => [
'view' => '檢視',
'view_any' => '列表',
'create' => '建立',
'update' => '編輯',
'delete' => '刪除',
'delete_any' => '批量刪除',
'force_delete' => '永久刪除',
'force_delete_any' => '批量永久刪除',
'restore' => '還原',
'reorder' => '重新排序',
'restore_any' => '批量還原',
'replicate' => '複製',
],
];
174 changes: 174 additions & 0 deletions resources/views/forms/shield-toggle.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
@php
$offColor = $getOffColor() ?? 'gray';
$onColor = $getOnColor() ?? 'primary';
$statePath = $getStatePath();
@endphp

<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
:inline-label-vertical-alignment="\Filament\Support\Enums\VerticalAlignment::Center"
>
@capture($content)
<button
wire:key="{{ $this->getId() }}"
x-data="{
state: $wire.{{ $applyStateBindingModifiers("\$entangle('{$statePath}')") }},
checkboxes: [],
checkboxLists: [],
toggleAll: function () {
this.state = ! this.state;
this.checkboxLists.forEach(checkboxList => {
Alpine.$data(checkboxList.parentNode).areAllCheckboxesChecked = false;
Alpine.$data(checkboxList.parentNode).checkIfAllCheckboxesAreChecked()
Alpine.$data(checkboxList.parentNode).updateVisibleCheckboxListOptions();
Alpine.$data(checkboxList.parentNode).toggleAllCheckboxes();
})
this.checkboxes.forEach(checkbox => {
checkbox.checked = this.state;
});
this.updateStateBasedOnCheckboxes();
},
updateStateBasedOnCheckboxes: function () {
this.state = this.checkboxes.every(checkbox => checkbox.checked );
},
init: function() {
this.checkboxLists = Array.from(document.querySelectorAll('.fi-fo-checkbox-list'))
this.checkboxes = Array.from(document.querySelectorAll('.fi-fo-checkbox-list-option-label input[type=\'checkbox\']'));
this.checkboxes.forEach((checkbox) => {
checkbox.addEventListener('change', () => {
this.updateStateBasedOnCheckboxes();
});
});
$nextTick(() => {
this.updateStateBasedOnCheckboxes();
});
$watch('state', (value, old) => {
console.log('new',value,' - old',old)
if (value === old) {
this.toggleAll();
}
});
}
}"
x-init="init()"
x-on:click="toggleAll();"
x-bind:class="
state
? '{{
match ($onColor) {
'gray' => 'fi-color-gray bg-gray-200 dark:bg-gray-700',
default => 'fi-color-custom bg-custom-600',
}
}}'
: '{{
match ($offColor) {
'gray' => 'fi-color-gray bg-gray-200 dark:bg-gray-700',
default => 'fi-color-custom bg-custom-600',
}
}}'
"
x-bind:style="
state
? '{{
\Filament\Support\get_color_css_variables(
$onColor,
shades: [600],
alias: 'forms::components.toggle.on',
)
}}'
: '{{
\Filament\Support\get_color_css_variables(
$offColor,
shades: [600],
alias: 'forms::components.toggle.off',
)
}}'
"
{{
$attributes
->merge([
'aria-checked' => 'false',
'autofocus' => $isAutofocused(),
'disabled' => $isDisabled(),
'id' => $getId(),
'role' => 'switch',
'type' => 'button',
'wire:loading.attr' => 'disabled',
'wire:target' => $statePath,
], escape: false)
->merge($getExtraAttributes(), escape: false)
->merge($getExtraAlpineAttributes(), escape: false)
->class(['fi-fo-toggle relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent outline-none transition-colors duration-200 ease-in-out disabled:pointer-events-none disabled:opacity-70'])
}}
>
<span
class="relative inline-block w-5 h-5 transition duration-200 ease-in-out transform bg-white rounded-full shadow pointer-events-none ring-0"
x-bind:class="{
'translate-x-5 rtl:-translate-x-5': state,
'translate-x-0': ! state,
}"
>
<span
class="absolute inset-0 flex items-center justify-center w-full h-full transition-opacity"
aria-hidden="true"
x-bind:class="{
'opacity-0 ease-out duration-100': state,
'opacity-100 ease-in duration-200': ! state,
}"
>
@if ($hasOffIcon())
<x-filament::icon
:icon="$getOffIcon()"
@class([
'fi-fo-toggle-off-icon h-3 w-3',
match ($offColor) {
'gray' => 'text-gray-400 dark:text-gray-700',
default => 'text-custom-600',
},
])
/>
@endif
</span>

<span
class="absolute inset-0 flex items-center justify-center w-full h-full transition-opacity"
aria-hidden="true"
x-bind:class="{
'opacity-100 ease-in duration-200': state,
'opacity-0 ease-out duration-100': ! state,
}"
>
@if ($hasOnIcon())
<x-filament::icon
:icon="$getOnIcon()"
x-cloak="x-cloak"
@class([
'fi-fo-toggle-on-icon h-3 w-3',
match ($onColor) {
'gray' => 'text-gray-400 dark:text-gray-700',
default => 'text-custom-600',
},
])
/>
@endif
</span>
</span>
</button>
@endcapture

@if ($isInline())
<x-slot name="labelPrefix">
{{ $content() }}
</x-slot>
@else
{{ $content() }}
@endif
</x-dynamic-component>
1 change: 1 addition & 0 deletions src/FilamentShieldServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function configurePackage(Package $package): void
->name('filament-shield')
->hasConfigFile()
->hasTranslations()
->hasViews()
->hasCommands($this->getCommands());
}

Expand Down
12 changes: 12 additions & 0 deletions src/Forms/ShieldSelectAllToggle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace BezhanSalleh\FilamentShield\Forms;

use Filament\Forms\Components\Toggle;

class ShieldSelectAllToggle extends Toggle
{
protected string $view = 'filament-shield::forms.shield-toggle';
}
Loading

0 comments on commit 1d0708e

Please sign in to comment.