-
Notifications
You must be signed in to change notification settings - Fork 920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prettify model preview page #781
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,11 +198,30 @@ public function show($id) | |
{ | ||
$this->crud->hasAccessOrFail('show'); | ||
|
||
// set columns from db | ||
$this->crud->setFromDb(); | ||
|
||
// cycle through old columns for removal | ||
foreach($this->crud->columns as $old_id => $column) { | ||
// replace any relationship columns | ||
if(array_key_exists('model', $column)) { | ||
$this->crud->columns[$column['name']] = $this->crud->columns[$old_id]; | ||
} | ||
// remove old numbered columns | ||
if(is_integer($old_id)) { | ||
unset($this->crud->columns[$old_id]); | ||
} | ||
|
||
} | ||
|
||
// get the info for that entry | ||
$this->data['entry'] = $this->crud->getEntry($id); | ||
$this->data['crud'] = $this->crud; | ||
$this->data['title'] = trans('backpack::crud.preview').' '.$this->crud->entity_name; | ||
|
||
// remove preview button from stack:line | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? I forget why... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because you're already on the "preview" page :-) |
||
$this->crud->removeButton('preview'); | ||
|
||
// load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package | ||
return view($this->crud->getShowView(), $this->data); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{{-- regular object attribute --}} | ||
<td>{!! $entry->{$column['name']} !!}</td> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
@section('content-header') | ||
<section class="content-header"> | ||
<h1> | ||
{{ trans('backpack::crud.preview') }} <span>{{ $crud->entity_name }}</span> | ||
{{ trans('backpack::crud.preview') }} <span class="text-lowercase">{{ $crud->entity_name }}</span> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we have |
||
</h1> | ||
<ol class="breadcrumb"> | ||
<li><a href="{{ url(config('backpack.base.route_prefix'), 'dashboard') }}">{{ trans('backpack::crud.admin') }}</a></li> | ||
|
@@ -15,19 +15,50 @@ | |
|
||
@section('content') | ||
@if ($crud->hasAccess('list')) | ||
<a href="{{ url($crud->route) }}"><i class="fa fa-angle-double-left"></i> {{ trans('backpack::crud.back_to_all') }} <span>{{ $crud->entity_name_plural }}</span></a><br><br> | ||
<a href="{{ url($crud->route) }}"><i class="fa fa-angle-double-left"></i> {{ trans('backpack::crud.back_to_all') }} <span class="text-lowercase">{{ $crud->entity_name_plural }}</span></a><br><br> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
@endif | ||
|
||
<!-- Default box --> | ||
<div class="box"> | ||
<div class="box-header with-border"> | ||
<h3 class="box-title"> | ||
{{ trans('backpack::crud.preview') }} | ||
<span>{{ $crud->entity_name }}</span> | ||
<span class="text-lowercase">{{ $crud->entity_name }}</span> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
</h3> | ||
</div> | ||
<div class="box-body"> | ||
{{ dump($entry) }} | ||
<table class="table table-striped table-bordered"> | ||
<tbody> | ||
@foreach ($crud->columns as $column) | ||
<tr> | ||
<td> | ||
<strong>{{ $column['label'] }}</strong> | ||
</td> | ||
@if (!isset($column['type'])) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indenting below is odd. |
||
@include('crud::columns.text') | ||
@else | ||
@if(view()->exists('vendor.backpack.crud.columns.'.$column['type'])) | ||
@include('vendor.backpack.crud.columns.'.$column['type']) | ||
@else | ||
@if(view()->exists('crud::columns.'.$column['type'])) | ||
@include('crud::columns.'.$column['type']) | ||
@else | ||
@include('crud::columns.text') | ||
@endif | ||
@endif | ||
@endif | ||
</tr> | ||
@endforeach | ||
@if ($crud->buttons->where('stack', 'line')->count()) | ||
<tr> | ||
<td><strong>Actions</td> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You sure that doesn't have a translation key? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed! Thank you. |
||
<td> | ||
@include('crud::inc.button_stack', ['stack' => 'line']) | ||
</td> | ||
</tr> | ||
@endif | ||
</tbody> | ||
</table> | ||
</div><!-- /.box-body --> | ||
</div><!-- /.box --> | ||
|
||
|
@@ -36,10 +67,8 @@ | |
|
||
@section('after_styles') | ||
<link rel="stylesheet" href="{{ asset('vendor/backpack/crud/css/crud.css') }}"> | ||
<link rel="stylesheet" href="{{ asset('vendor/backpack/crud/css/show.css') }}"> | ||
@endsection | ||
|
||
@section('after_scripts') | ||
<script src="{{ asset('vendor/backpack/crud/js/crud.js') }}"></script> | ||
<script src="{{ asset('vendor/backpack/crud/js/show.js') }}"></script> | ||
@endsection | ||
@endsection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space after if!!!
Why exists vs isset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed! Thanks.