Skip to content

Commit

Permalink
Merge pull request #36 from kenepa/minor-updates
Browse files Browse the repository at this point in the history
Minor improvements for closing modal
  • Loading branch information
Jehizkia authored Apr 24, 2024
2 parents 802fa10 + 2d47261 commit 15f1876
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
12 changes: 9 additions & 3 deletions resources/views/components/resource-lock-observer.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function resourceLockObserverInit() {
};
window.addEventListener('close-modal', event => {
if (event.detail.id.endsWith('-table-action')) {
if (event.detail.id === 'resourceIsLockedNotice' ) {
Livewire.dispatch('resourceLockObserver::unload')
}
})
Expand All @@ -35,10 +35,16 @@ function resourceLockObserverInit() {
</p>
</div>

<div x-data="{url: '/'}" @open-modal.window="(event) => { url = event.detail.returnUrl}" class="flex flex-col justify-center space-y-2">
<div x-data="{
url: '/',
unlock() {
Livewire.dispatch('resourceLockObserver::unlock')
Livewire.dispatch('close-modal', {id: 'resourceIsLockedNotice'})
}
}" @open-modal.window="(event) => { url = event.detail.returnUrl}" class="flex flex-col justify-center space-y-2">

@if ($isAllowedToUnlock)
<button wire:click="$dispatch('resourceLockObserver::unlock')" style="--c-400:var(--danger-400);--c-500:var(--danger-500);--c-600:var(--danger-600);" class="fi-btn fi-btn-size-md relative grid-flow-col items-center justify-center font-semibold outline-none transition duration-75 focus:ring-2 disabled:pointer-events-none disabled:opacity-70 rounded-lg fi-btn-color-danger gap-1.5 px-3 py-2 text-sm inline-grid shadow-sm bg-custom-600 text-white hover:bg-custom-500 dark:bg-custom-500 dark:hover:bg-custom-400 focus:ring-custom-500/50 dark:focus:ring-custom-400/50 fi-ac-btn-action">
<button x-on:click="unlock()" style="--c-400:var(--danger-400);--c-500:var(--danger-500);--c-600:var(--danger-600);" class="fi-btn fi-btn-size-md relative grid-flow-col items-center justify-center font-semibold outline-none transition duration-75 focus:ring-2 disabled:pointer-events-none disabled:opacity-70 rounded-lg fi-btn-color-danger gap-1.5 px-3 py-2 text-sm inline-grid shadow-sm bg-custom-600 text-white hover:bg-custom-500 dark:bg-custom-500 dark:hover:bg-custom-400 focus:ring-custom-500/50 dark:focus:ring-custom-400/50 fi-ac-btn-action">
{{ __('resource-lock::modal.unlock_button') }}
</button>
@endif
Expand Down
6 changes: 1 addition & 5 deletions src/Resources/Pages/Concerns/UsesLocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function lockResource($record)
$this->resourceLockType = class_basename($record);

if ($record->isLockedByCurrentUser()) {
// Do Nothing
$record->lock();
} elseif ($record->isLocked()) {
$this->openLockedResourceModal();
} else {
Expand Down Expand Up @@ -55,10 +55,6 @@ protected function openLockedResourceModal(): void

protected function closeLockedResourceModal(): void
{
$this->dispatch('close-modal', [
'id' => 'resourceIsLockedNotice',
]);

$this->dispatch(
'close-modal',
id: 'resourceIsLockedNotice'
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/ResourceLockResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static function getNavigationBadge(): ?string

public static function getNavigationLabel(): string
{
return config('resource-lock.manager.navigation_label', 'Resource Lock Manager');
return __(config('resource-lock.manager.navigation_label', 'Resource Lock Manager'));
}

public static function getNavigationGroup(): ?string
Expand Down

0 comments on commit 15f1876

Please sign in to comment.