From 46c9a3742e2d74322f6b499793f5b9bc926411ee Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 8 Dec 2019 00:51:14 -0700 Subject: [PATCH 1/4] Update CollectionController --- app/Http/Controllers/CollectionController.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/app/Http/Controllers/CollectionController.php b/app/Http/Controllers/CollectionController.php index 588340a35..4fc7dfe65 100644 --- a/app/Http/Controllers/CollectionController.php +++ b/app/Http/Controllers/CollectionController.php @@ -205,4 +205,36 @@ class CollectionController extends Controller ]; }); } + + public function deleteId(Request $request) + { + $this->validate($request, [ + 'collection_id' => 'required|int|min:1|exists:collections,id', + 'post_id' => 'required|int|min:1|exists:statuses,id' + ]); + + $profileId = Auth::user()->profile_id; + $collectionId = $request->input('collection_id'); + $postId = $request->input('post_id'); + + $collection = Collection::whereProfileId($profileId)->findOrFail($collectionId); + $count = $collection->items()->count(); + + if($count == 1) { + abort(400, 'You cannot delete the only post of a collection!'); + } + + $status = Status::whereScope('public') + ->whereIn('type', ['photo', 'photo:album', 'video']) + ->findOrFail($postId); + + $item = CollectionItem::whereCollectionId($collection->id) + ->whereObjectType('App\Status') + ->whereObjectId($status->id) + ->firstOrFail(); + + $item->delete(); + + return 200; + } } From 0569846f15fe6d5e9a6304214f3c64023dfd3ef8 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 8 Dec 2019 00:51:31 -0700 Subject: [PATCH 2/4] Update web routes --- routes/web.php | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/web.php b/routes/web.php index a2dc0bc23..66284debb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -156,6 +156,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::get('bookmarks', 'InternalApiController@bookmarks'); Route::get('collection/items/{id}', 'CollectionController@getItems'); Route::post('collection/item', 'CollectionController@storeId'); + Route::delete('collection/item', 'CollectionController@deleteId'); Route::get('collection/{id}', 'CollectionController@get'); Route::post('collection/{id}', 'CollectionController@store'); Route::delete('collection/{id}', 'CollectionController@delete')->middleware('throttle:maxCollectionsPerHour,60')->middleware('throttle:maxCollectionsPerDay,1440')->middleware('throttle:maxCollectionsPerMonth,43800'); From 076023eac97528e37260092c3236e4c739bbf6f9 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 8 Dec 2019 00:53:31 -0700 Subject: [PATCH 3/4] Update CollectionComponent.vue --- .../js/components/CollectionComponent.vue | 116 ++++++++++++++++-- 1 file changed, 109 insertions(+), 7 deletions(-) diff --git a/resources/assets/js/components/CollectionComponent.vue b/resources/assets/js/components/CollectionComponent.vue index bf7c4b58f..18d6ccf5b 100644 --- a/resources/assets/js/components/CollectionComponent.vue +++ b/resources/assets/js/components/CollectionComponent.vue @@ -15,7 +15,7 @@

-     - +     @@ -66,14 +66,17 @@ - +

+ Edit Photos + +
-
+
@@ -89,9 +92,34 @@

Only local, public posts can be added

- + + +
+

Select a Photo to Delete

+
+
+
+
+
+
+
+
+ +
+
+ +
@@ -105,6 +133,16 @@ background: rgba(0,0,0,.68); z-index: 300; } + .scrollbar-hidden::-webkit-scrollbar { + display: none; + } + .delete-border { + border: 4px solid #ff0000; + } + .delete-border .square-content { + background-color: red; + background-blend-mode: screen; + } \ No newline at end of file From 551e078489fca806916ea68912929da966be4330 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 8 Dec 2019 00:54:44 -0700 Subject: [PATCH 4/4] Update compiled assets --- public/js/collections.js | Bin 18544 -> 21833 bytes public/mix-manifest.json | Bin 1739 -> 1739 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/public/js/collections.js b/public/js/collections.js index 1d1498c9246740704add3725306dc0fcb620d0ee..7bba7df6db6330451cfbc3898c60423eb45b9311 100644 GIT binary patch delta 4051 zcma)9TWlOx8P>#huD&#}v$0DqXOErrjCW?dYdeWO>+!}(Y;YCg(1fbedgIRSob?Ww zowJ#XFLf6aq83p~X>yQ2;w2UEf+!d515yzp5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Kag@79epY4RYlu#Uu|9r53w4FF~w~d8DjE~38bmK-TQX{!0JhIIA$1xQv zxg85j6}}<9ud5<_5Z||ou2qwy$y4z?0W+D&YB^@-3{NrnQhcHfd_wp?@m&ForaA%z zsRx@EyymICfAx`MyHbTww-2L*+BI- zk#v!ehAHD_6{x?(Ezt$;x|?X29&te{SKLKq39I`g5#m;2OTV#ZTJwXb5xtQJT?TU$ z_;wnVAJj+F^@HNbFkYmGgMgVN#nQ;S7SSN1c0CaAujx$!)XbO-CqpB(a%GQ|QBD+R zg6&$4H{lUT0>3e~8=<{3HYSo7>$HNCjV=E z6>q#Uv1^MMGoEI6p5tmZGHxL`pH5tC6{;Gad?!>1hjp9gR#uc8T~M%U73jRSfIbz$ zo@%SE+Bd>~pWIsQJ)DxdfzJHzttAxTPbIs6o`3L#FyEZoiCO$IbtZsXrl><9!yv1s zk6e~wIQs3#v@^wK7vmR7P%sNDsAce)3Y?wEOF1L{}Hxh@v+ z!ORFA{&6N409wYmkHv{r=bgu3HzW89%fZ26{49t8j=5XU1SgAZLCFBWeC#Ry>TC!n zSZQD`3mx2~N zc=nWz1OClZo1{D-l6JysB58-iDqxc!92Rz!<{5=14A5U2Z6>(oqOo+C6)Pp%)x|(U z5r{t|hNxmwSF5<+pbq$B=`^B~OP|H)U!-5$R!hy+N=8{x)+Q0~`MEeAxH2a`NMFuP KVfBI23F$xfw}OTM diff --git a/public/mix-manifest.json b/public/mix-manifest.json index f0ac4d11bb95a7b7f4a8912fa78ae854ab891735..cc4135fe07c1ad309ea6cfaf06f765cd14b21cbf 100644 GIT binary patch delta 32 ocmX@jdzyE{UM68