diff --git a/app/Livewire/EntityListing.php b/app/Livewire/EntityListing.php new file mode 100644 index 0000000000..d448934035 --- /dev/null +++ b/app/Livewire/EntityListing.php @@ -0,0 +1,60 @@ +entities = new Collection(); + $this->campaign = $campaign; + + $this->loadEntities(); + } + + public function loadEntities() + { + CampaignLocalization::forceCampaign($this->campaign); + UserCache::campaign($this->campaign); + Avatar::campaign($this->campaign); + CampaignCache::campaign($this->campaign); + + $campaign = $this->campaign; + + $this->authorize('access', $campaign); + $entities = $campaign->entities() + ->lastSync(request()->get('lastSync')) + ->paginate(12, ['*'], 'page', $this->pageNumber); + + $this->pageNumber += 1; + + $this->hasMorePages = $entities->hasMorePages(); + + $this->entities->push(...$entities->items()); + } + + public function render() + { + return view('livewire.entity-listing'); + } +} diff --git a/app/Policies/CampaignPolicy.php b/app/Policies/CampaignPolicy.php index eed3b68fc4..face574b69 100644 --- a/app/Policies/CampaignPolicy.php +++ b/app/Policies/CampaignPolicy.php @@ -246,27 +246,27 @@ public function unboost(?User $user, Campaign $campaign): bool public function galleryManage(?User $user, Campaign $campaign): bool { return $user && ( - UserCache::user($user)->admin() || + UserCache::user($user)->admin() || $this->checkPermission(CampaignPermission::ACTION_GALLERY, $user, $campaign) - ); + ); } public function galleryBrowse(?User $user, Campaign $campaign): bool { return $user && ( - UserCache::user($user)->admin() || + UserCache::user($user)->admin() || $this->checkPermission(CampaignPermission::ACTION_GALLERY, $user, $campaign) || $this->checkPermission(CampaignPermission::ACTION_GALLERY_BROWSE, $user, $campaign) - ); + ); } public function galleryUpload(?User $user, Campaign $campaign): bool { return $user && ( - UserCache::user($user)->admin() || + UserCache::user($user)->admin() || $this->checkPermission(CampaignPermission::ACTION_GALLERY, $user, $campaign) || $this->checkPermission(CampaignPermission::ACTION_GALLERY_UPLOAD, $user, $campaign) - ); + ); } diff --git a/app/Renderers/DatagridRenderer2.php b/app/Renderers/DatagridRenderer2.php index b528e59040..d475ea333a 100644 --- a/app/Renderers/DatagridRenderer2.php +++ b/app/Renderers/DatagridRenderer2.php @@ -275,6 +275,6 @@ public function rowAttributes(mixed $row): string foreach($row->rowAttributes() as $attr => $val) { $attributes[] = 'data-' . $attr . '="' . $val . '"'; } - return implode(' ' , $attributes); + return implode(' ', $attributes); } } diff --git a/app/Services/Permissions/PermissionService.php b/app/Services/Permissions/PermissionService.php index 58d51ae705..6bf462065e 100644 --- a/app/Services/Permissions/PermissionService.php +++ b/app/Services/Permissions/PermissionService.php @@ -136,10 +136,10 @@ public function createTemporaryTable(): self if (count($batch) > 0) { DB::statement("INSERT INTO tmp_permissions (id) VALUES (" . implode(') ,(', $batch) . ")"); } -// dump(in_array(329259, $batch)); -// $wa = DB::table('tmp_permissions') -// ->where('id', 329259)->get(); -// dd($wa); + // dump(in_array(329259, $batch)); + // $wa = DB::table('tmp_permissions') + // ->where('id', 329259)->get(); + // dd($wa); $this->tempPermissionCreated = true; return $this; } diff --git a/composer.json b/composer.json index 646ce5745d..fa5fbb8a38 100644 --- a/composer.json +++ b/composer.json @@ -32,6 +32,7 @@ "laravel/ui": "^4.2.1", "laravelcollective/html": "^6.0", "league/flysystem-aws-s3-v3": "^3.5", + "livewire/livewire": "^3.3", "mailerlite/mailerlite-php": "^1.0", "mcamara/laravel-localization": "^1.7", "orhanerday/open-ai": "^4.7", diff --git a/composer.lock b/composer.lock index 637b16169d..608699cfc3 100644 --- a/composer.lock +++ b/composer.lock @@ -4383,6 +4383,80 @@ ], "time": "2023-11-24T15:40:42+00:00" }, + { + "name": "livewire/livewire", + "version": "v3.3.0", + "source": { + "type": "git", + "url": "https://github.com/livewire/livewire.git", + "reference": "7c1f609515e74ef1197c08e56a5606571b3ec1d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/livewire/livewire/zipball/7c1f609515e74ef1197c08e56a5606571b3ec1d9", + "reference": "7c1f609515e74ef1197c08e56a5606571b3ec1d9", + "shasum": "" + }, + "require": { + "illuminate/database": "^10.0", + "illuminate/support": "^10.0", + "illuminate/validation": "^10.0", + "league/mime-type-detection": "^1.9", + "php": "^8.1", + "symfony/http-kernel": "^6.2" + }, + "require-dev": { + "calebporzio/sushi": "^2.1", + "laravel/framework": "^10.0", + "laravel/prompts": "^0.1.6", + "mockery/mockery": "^1.3.1", + "orchestra/testbench": "^8.0", + "orchestra/testbench-dusk": "^8.0", + "phpunit/phpunit": "^9.0", + "psy/psysh": "@stable" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Livewire\\LivewireServiceProvider" + ], + "aliases": { + "Livewire": "Livewire\\Livewire" + } + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Livewire\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Caleb Porzio", + "email": "calebporzio@gmail.com" + } + ], + "description": "A front-end framework for Laravel.", + "support": { + "issues": "https://github.com/livewire/livewire/issues", + "source": "https://github.com/livewire/livewire/tree/v3.3.0" + }, + "funding": [ + { + "url": "https://github.com/livewire", + "type": "github" + } + ], + "time": "2023-12-11T18:04:00+00:00" + }, { "name": "maennchen/zipstream-php", "version": "2.4.0", diff --git a/resources/views/dashboard/widgets/_recent_list.blade.php b/resources/views/dashboard/widgets/_recent_list.blade.php index e0e6a484d4..8abcbcca8d 100644 --- a/resources/views/dashboard/widgets/_recent_list.blade.php +++ b/resources/views/dashboard/widgets/_recent_list.blade.php @@ -1,47 +1,4 @@ -
-@foreach ($entities as $entity) -
- - - -
- {!! $entity->tooltipedLink($entity->name, false) !!} - - @if ($entity->is_private) - - @endif -
- -
- - @if ($entity->created_at->equalTo($entity->updated_at)) - {{ !empty($entity->created_by) ? \App\Facades\UserCache::name($entity->created_by) : __('crud.history.unknown') }} - @else - {{ !empty($entity->updated_by) ? \App\Facades\UserCache::name($entity->updated_by) : __('crud.history.unknown') }} - @endif - -@can('history', [$entity, $campaign]) - @if (!empty($entity->updated_at)) - - {{ $entity->updated_at->diffForHumans() }} - - @endif -@endcan -
-
- -@endforeach - -@if($entities->hasMorePages()) -
- - {{ __('crud.actions.next') }} - - -
-@endif -
+
+@livewire('entity-listing', ['campaign' => $campaign]) +
\ No newline at end of file diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index fb96d8b8d2..88fb9f8891 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -68,6 +68,8 @@ @endif @includeWhen(!empty($campaign), 'layouts._theme') + + @livewireStyles {{-- Hide the sidebar if the there is no current campaign --}} @@ -170,5 +172,6 @@ @yield('scripts') @includeWhen(config('tracking.consent'), 'partials.cookieconsent') +@livewireScripts diff --git a/resources/views/livewire/entity-listing.blade.php b/resources/views/livewire/entity-listing.blade.php new file mode 100644 index 0000000000..8be62a5ba3 --- /dev/null +++ b/resources/views/livewire/entity-listing.blade.php @@ -0,0 +1,50 @@ +
+ + +
+ +@foreach ($entities as $entity) +
+ + + +
+ {!! $entity->tooltipedLink($entity->name, false) !!} + + @if ($entity->is_private) + + @endif +
+ +
+ + {{ !empty($entity->updated_by) ? \App\Facades\UserCache::name($entity->updated_by) : __('crud.history.unknown') }} + +@can('history', [$entity, $campaign]) + @if (!empty($entity->updated_at)) + + {{ $entity->updated_at->diffForHumans() }} + + @endif +@endcan +
+
+ +@endforeach + +@if($hasMorePages) +
+ +
+@endif + +
+ +