Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from protonemedia/default-table-props
Browse files Browse the repository at this point in the history
Default Table.vue props
  • Loading branch information
pascalbaljet authored Apr 2, 2021
2 parents f892302 + 3044826 commit e14467d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
22 changes: 16 additions & 6 deletions js/Components/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,39 @@ export default {
props: {
meta: {
type: Object,
default: () => {},
default: () => {
return {};
},
required: false,
},
columns: {
type: Object,
default: () => {},
default: () => {
return {};
},
required: false,
},
filters: {
type: Object,
default: () => {},
default: () => {
return {};
},
required: false,
},
search: {
type: Object,
default: () => {},
default: () => {
return {};
},
required: false,
},
onUpdate: {
type: Function,
required: true,
required: false,
},
},
Expand Down Expand Up @@ -96,7 +104,9 @@ export default {
queryBuilderData: {
deep: true,
handler() {
this.onUpdate(this.queryBuilderData);
if (this.onUpdate) {
this.onUpdate(this.queryBuilderData);
}
},
},
},
Expand Down
8 changes: 2 additions & 6 deletions php/InertiaTableServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@ class InertiaTableServiceProvider extends ServiceProvider
public function boot()
{
Response::macro('table', function (callable $withTableBuilder = null) {
$request = request();

$response = $this;
$tableBuilder = new InertiaTable(request());

if ($withTableBuilder) {
$tableBuilder = new InertiaTable($request);
$withTableBuilder($tableBuilder);
$tableBuilder->applyTo($response);
}

return $response;
return $tableBuilder->applyTo($this);
});
}
}

0 comments on commit e14467d

Please sign in to comment.