Skip to content

Commit

Permalink
Use auto-applying site filter, instead of adding new site query param.
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseleite committed Nov 16, 2020
1 parent a3769af commit adbeaeb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
5 changes: 2 additions & 3 deletions resources/js/components/entries/Widget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,15 @@ export default {
props: {
collection: String,
site: String,
},
data() {
return {
cols: [{ label: "Title", field: "title", visible: true }],
listingKey: 'entries',
requestUrl: cp_url(`collections/${this.collection}/entries?site=${this.site}`),
requestUrl: cp_url(`collections/${this.collection}/entries`),
}
}
},
}
</script>
2 changes: 1 addition & 1 deletion resources/views/widgets/collection.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</div>
<collection-widget
collection="{{ $collection->handle() }}"
site="{{ $site->handle() }}"
:filters="{{ $filters->toJson() }}"
initial-sort-column="{{ $sortColumn }}"
initial-sort-direction="{{ $sortDirection }}"
:initial-per-page="{{ $limit }}"
Expand Down
4 changes: 0 additions & 4 deletions src/Http/Controllers/CP/Collections/EntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ protected function indexQuery($collection)
{
$query = $collection->queryEntries();

if ($site = request('site')) {
$query->where('site', $site);
}

if ($search = request('search')) {
if ($collection->hasSearchIndex()) {
return $collection->searchIndex()->ensureExists()->search($search);
Expand Down
6 changes: 4 additions & 2 deletions src/Widgets/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Statamic\Widgets;

use Statamic\Facades\Collection as CollectionAPI;
use Statamic\Facades\Site;
use Statamic\Facades\Scope;
use Statamic\Facades\User;

class Collection extends Widget
Expand Down Expand Up @@ -31,7 +31,9 @@ public function html()

return view('statamic::widgets.collection', [
'collection' => $collection,
'site' => Site::selected(),
'filters' => Scope::filters('entries', [
'collection' => $collection->handle(),
]),
'title' => $this->config('title', $collection->title()),
'button' => __('New :thing', ['thing' => $collection->entryBlueprint()->title()]),
'limit' => $this->config('limit', 5),
Expand Down

0 comments on commit adbeaeb

Please sign in to comment.