diff --git a/composer.lock b/composer.lock index 18fac89..fcc1818 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1d1b63194eb2f772a3df2e696acfa7a8", + "content-hash": "ed93de9f762ac8145d5810e47fb131af", "packages": [ { "name": "brick/math", @@ -1061,12 +1061,18 @@ }, { "name": "kraenkvisuell/nova-sortable", - "version": "dev-master", - "dist": { - "type": "path", - "url": "../nova-sortable", + "version": "v3.1.3", + "source": { + "type": "git", + "url": "https://github.com/kraenkvisuell/nova-sortable.git", "reference": "9484f792247abbfbbb14b377e321918fe5cb8f4b" }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kraenkvisuell/nova-sortable/zipball/9484f792247abbfbbb14b377e321918fe5cb8f4b", + "reference": "9484f792247abbfbbb14b377e321918fe5cb8f4b", + "shasum": "" + }, "require": { "php": ">=7.3.0", "spatie/eloquent-sortable": "^3.10.0|^4.0" @@ -1084,6 +1090,7 @@ "KraenkVisuell\\NovaSortable\\": "src/" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -1094,9 +1101,16 @@ "laravel", "nova" ], - "transport-options": { - "relative": true - } + "support": { + "source": "https://github.com/kraenkvisuell/nova-sortable/tree/v3.1.3" + }, + "funding": [ + { + "url": "https://github.com/kraenkvisuell", + "type": "github" + } + ], + "time": "2022-05-03T15:47:02+00:00" }, { "name": "laravel/framework", diff --git a/config/nova-cms-portfolio.php b/config/nova-cms-portfolio.php index 5374662..a6fe76c 100644 --- a/config/nova-cms-portfolio.php +++ b/config/nova-cms-portfolio.php @@ -22,6 +22,7 @@ 'has_custom_portfolio_image' => true, 'has_embed_code' => true, 'has_move_to_slideshow' => false, + 'has_move_to_new_slideshow' => false, 'has_select_portfolio_image' => true, 'has_projects_zip_upload' => false, 'has_quick_upload' => true, diff --git a/resources/lang/nova-cms-portfolio/de/works.php b/resources/lang/nova-cms-portfolio/de/works.php index 7862be7..df7a8d9 100644 --- a/resources/lang/nova-cms-portfolio/de/works.php +++ b/resources/lang/nova-cms-portfolio/de/works.php @@ -10,7 +10,8 @@ 'embed_url' => 'Embed URL (Youtube, Vimeo etc.)', 'is_artist_discipline_image' => 'Repräsentiert Künstler in Disziplin', 'is_artist_portfolio_image' => 'Ist Künstler-Portfolio-Bild', - 'move_to_different_project' => 'In anderes :attribute verschieben', + 'move_to_different_slideshow' => 'In andere(s) :attribute verschieben', + 'move_to_new_slideshow' => 'In neue(s) :attribute verschieben', 'overview_categories' => 'Kat. (Übersicht)', 'representation_categories' => 'Kat. (Repräsentiert...)', 'represents_artist_in_discipline_category' => 'In allgemeiner Kategorie-Übersicht zeigen', diff --git a/resources/lang/nova-cms-portfolio/en/works.php b/resources/lang/nova-cms-portfolio/en/works.php index 42eea0f..b8682ef 100644 --- a/resources/lang/nova-cms-portfolio/en/works.php +++ b/resources/lang/nova-cms-portfolio/en/works.php @@ -10,7 +10,8 @@ 'embed_url' => 'Embed URL (Youtube, Vimeo etc.)', 'is_artist_discipline_image' => 'represents artist in discipline', 'is_artist_portfolio_image' => 'is artist portfolio image', - 'move_to_different_project' => 'move to different :attribute', + 'move_to_different_slideshow' => 'move to different :attribute', + 'move_to_new_slideshow' => 'move to new :attribute', 'overview_categories' => 'category prio in overview', 'representation_categories' => 'cat. (represents...)', 'represents_artist_in_discipline_category' => 'represents artist on frontpage category', diff --git a/src/Nova/Actions/MoveToNewSlideshow.php b/src/Nova/Actions/MoveToNewSlideshow.php new file mode 100644 index 0000000..ea2c7de --- /dev/null +++ b/src/Nova/Actions/MoveToNewSlideshow.php @@ -0,0 +1,144 @@ + config('nova-cms-portfolio.custom_slideshow_label') + ?: ucfirst(__('nova-cms-portfolio::slideshows.slideshow')), + ] + )); + } + + public function handle(ActionFields $fields, Collection $works) + { + $oldSlideshow = Slideshow::find($works->first()->slideshow_id); + + $newSlideshow = Slideshow::create([ + 'artist_id' => $oldSlideshow->artist_id, + 'title' => $fields->title, + 'slug' => $fields->slug, + 'is_published' => $fields->is_published, + 'is_visible_in_overview' => $fields->is_visible_in_overview, + ]); + + foreach ($works as $work) { + $work->slideshow_id = $newSlideshow->id; + $work->sort_order += 1000; + $work->save(); + } + + $newSlideshow->categories()->attach($fields->category_id); + + $oldSlideshow->refreshWorksOrder(); + $newSlideshow->refreshWorksOrder(); + + if ($fields->afterwards == 'go_to_other_slideshow') { + return Action::push('/resources/slideshows/'.$newSlideshow->id); + } + } + + public function fields() + { + $currentSlideshow = Slideshow::where('id', request()->input('viaResourceId')) + ->with([ + 'categories', + ]) + ->first(); + + $categoryOptions = Category::all()->sortBy('title')->pluck('title', 'id'); + + $visibleInArtistOverviewLabel = config('nova-cms-portfolio.custom_visible_in_artist_overview_label') + ?: ucfirst(__('nova-cms-portfolio::slideshows.visible_in_artist_overview')); + + return [ + Text::make(__('nova-cms::pages.title'), 'title') + ->required() + ->rules('required'), + + Slug::make(__('nova-cms::pages.slug'), 'slug')->from('title') + ->rules('required'), + + Select::make( + __('nova-cms-portfolio::categories.category'), + 'category_id' + ) + ->required() + ->rules('required') + ->options($categoryOptions) + ->default($currentSlideshow->categories->first()->id), + + Boolean::make(ucfirst(__('nova-cms-portfolio::portfolio.published')), 'is_published') + ->default(true), + + Boolean::make($visibleInArtistOverviewLabel, 'is_visible_in_overview') + ->default(true), + + Select::make( + ucfirst(__('nova-cms-portfolio::portfolio.afterwards')), + 'afterwards' + ) + ->required() + ->rules('required') + ->options([ + 'go_to_other_slideshow' => __( + 'nova-cms-portfolio::portfolio.go_where_moved_to' + ), + 'stay_on_this_slideshow' => __( + 'nova-cms-portfolio::portfolio.stay_here' + ), + + ]) + ->default('go_to_other_slideshow'), + + ]; + } + + protected function getSlideshows() + { + return Cache::remember( + 'nova.artist.projects.'.request()->input('viaResourceId'), + now()->addSeconds(5), + function () { + $currentSlideshow = Slideshow::where('id', request()->input('viaResourceId')) + ->with([ + 'artist.slideshows', + 'artist.categories', + 'categories', + ]) + ->first(); + + $slideshows = []; + + foreach ($currentSlideshow->artist->categories as $category) { + foreach ($currentSlideshow->artist->slideshows as $slideshow) { + if ( + $currentSlideshow->id != $slideshow->id + && $slideshow->categories->firstWhere('id', $category->id) + ) { + $slideshows[$slideshow->id] = $category->title.': '.$slideshow->title; + } + } + } + + return $slideshows; + } + ); + } +} diff --git a/src/Nova/Actions/MoveToSlideshow.php b/src/Nova/Actions/MoveToSlideshow.php index cf6c1ad..88d6293 100644 --- a/src/Nova/Actions/MoveToSlideshow.php +++ b/src/Nova/Actions/MoveToSlideshow.php @@ -14,7 +14,7 @@ class MoveToSlideshow extends Action public function name() { return ucfirst(__( - 'nova-cms-portfolio::works.move_to_different_project', + 'nova-cms-portfolio::works.move_to_different_slideshow', [ 'attribute' => config('nova-cms-portfolio.custom_slideshow_label') ?: ucfirst(__('nova-cms-portfolio::slideshows.slideshow')), diff --git a/src/Nova/Slideshow.php b/src/Nova/Slideshow.php index a8fd274..e53478d 100644 --- a/src/Nova/Slideshow.php +++ b/src/Nova/Slideshow.php @@ -166,26 +166,6 @@ class="w-auto h-12 mr-1 inline-block" return $html; })->asHtml(), - - // Line::make('', function () { - // if ($this->works->where('is_artist_discipline_image', true)->count()) { - // return '
' - // .__('nova-cms-portfolio::works.is_artist_discipline_image') - // .'
'; - // } - - // return ''; - // })->asHtml(), - - // Line::make('', function () { - // if ($this->works->where('is_artist_portfolio_image', true)->count()) { - // return '
' - // .__('nova-cms-portfolio::works.is_artist_portfolio_image') - // .'
'; - // } - - // return ''; - // })->asHtml(), ]) ->onlyOnIndex(); @@ -205,10 +185,12 @@ class="btn btn-xs $fields[] = Slug::make(__('nova-cms::pages.slug'), 'slug')->from('title') ->rules('required') - ->onlyOnForms(); + ->onlyOnForms() + ->default(true); $fields[] = Boolean::make(ucfirst(__('nova-cms-portfolio::portfolio.published')), 'is_published') - ->onlyOnForms(); + ->onlyOnForms() + ->default(true); if (config('nova-cms-portfolio.has_visible_in_artist_overview')) { $fields[] = Boolean::make($visibleInArtistOverviewLabel, 'is_visible_in_overview') diff --git a/src/Nova/Work.php b/src/Nova/Work.php index 58a2aa5..ca9e378 100644 --- a/src/Nova/Work.php +++ b/src/Nova/Work.php @@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Cache; use Kraenkvisuell\NovaCmsMedia\MediaLibrary; use Kraenkvisuell\NovaCmsPortfolio\Models\Slideshow; +use Kraenkvisuell\NovaCmsPortfolio\Nova\Actions\MoveToNewSlideshow; use Kraenkvisuell\NovaCmsPortfolio\Nova\Actions\MoveToSlideshow; use Kraenkvisuell\NovaCmsPortfolio\Nova\Actions\ToggleArtistPortfolioImage; use Kraenkvisuell\NovaCmsPortfolio\Nova\Actions\ToggleRepresentsArtistInCategory; @@ -299,6 +300,10 @@ public function actions(Request $request) $actions[] = MoveToSlideshow::make(); } + if (config('nova-cms-portfolio.has_move_to_new_slideshow')) { + $actions[] = MoveToNewSlideshow::make(); + } + if (config('nova-cms-portfolio.has_select_portfolio_image')) { $actions[] = ToggleArtistPortfolioImage::make() ->onlyOnTableRow()