Skip to content

Commit

Permalink
Merge pull request #4 from netcore/master
Browse files Browse the repository at this point in the history
Error fixes, custom actions <td>
  • Loading branch information
gstvr authored Dec 16, 2017
2 parents 44380f6 + d5a9f6d commit 24bbaa1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
5 changes: 4 additions & 1 deletion Config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
*/
'datatable' => [
// Presenter is used to modify datatable column titles and values if necessary.
'presenter' => \App\Presenters\AdminUsersDatatablePresenter::class,
'presenter' => \App\Presenters\AdminUsersDatatablePresenter::class,

// View from which user actions <td> is imported
'actions_td' => 'user::users.tds.actions'
],

// Example export options config
Expand Down
4 changes: 2 additions & 2 deletions Resources/views/users/tds/actions.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@if(isset($config['allow-view']) && $config['allow-view'] || !isset($config['allow-view']))
@if(isset($config['allow-view']) && $config['allow-view'])
<a href="{{ crud_route('show', $row) }}" class="btn btn-xs btn-default">
<i class="fa fa-eye"></i>
</a>
Expand All @@ -8,7 +8,7 @@
<i class="fa fa-pencil"></i>
</a>

@if(isset($config['allow-delete']) && $config['allow-delete'] || !isset($config['allow-delete']))
@if(isset($config['allow-delete']) && $config['allow-delete'])
{!! Form::open(['url' => crud_route('destroy', $row->id), 'style' => 'display: inline-block']) !!}
{{ method_field('DELETE') }}
<button type="submit" class="btn btn-xs btn-danger" onclick="return confirm('Are you sure?');">
Expand Down
6 changes: 4 additions & 2 deletions Traits/AdminUsersPagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ public function paginate()
$this->modifyDatatableColumns($datatable, $presenter);
}

$actionsTd = config('netcore.module-user.datatable.actions_td');

// Add action column
$datatable->addColumn('action', function ($row) {
return view('user::users.tds.actions', compact('row'))->render();
$datatable->addColumn('action', function ($row) use ($actionsTd) {
return view($actionsTd ?? 'user::users.tds.actions', compact('row'))->render();
});

// Don't escape action column as it contains HTML code.
Expand Down
2 changes: 1 addition & 1 deletion Traits/ReplaceableAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function getReplaceable(): array

foreach ($attributes as $attribute)
{
$replaceable[$prefix . $attribute] = $this[$attribute] ?? null;
$replaceable[strtoupper($prefix . $attribute)] = $this[$attribute] ?? null;
}

return $replaceable;
Expand Down
10 changes: 9 additions & 1 deletion Traits/UserPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ trait UserPermissions
{

/**
* @return \Illuminate\Database\Eloquent\Relations\HasOne
* @return \Illuminate\Database\Eloquent\Relations\HasOne|object
*/
public function role()
{
$module = Module::find('Permission');

if (! $module || !$module->enabled()) {
return (object)[
'levels' => collect()
];
}

return $this->belongsTo(Role::class);
}

Expand Down

0 comments on commit 24bbaa1

Please sign in to comment.