Skip to content

Commit

Permalink
Adding Title column to views
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaldreams committed Sep 13, 2019
1 parent 6710229 commit a9ad22d
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 14 deletions.
4 changes: 3 additions & 1 deletion resources/templates/view/4/pages/blank.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
@section('breadcrumb')

@endsection

@section('header')
<h3><i class="fa fa-"></i></h3>
@endsection
@section('tools')

@endsection
Expand Down
12 changes: 7 additions & 5 deletions resources/templates/view/4/pages/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
Create
</li>
@endsection
@section('header')
<h3><i class="fa fa-plus"></i> Create New @@table@@</h3>
@endSection
@section('tools')

@endSection
@section('content')
<div class="row">
<div class='col-md-12'>
<div class='card bg-white'>
<div class="card-body">
@include('@@folder@@.@@partialFilename@@')
</div>
</div>
@include('@@folder@@.@@partialFilename@@')
</div>
</div>
@endSection
5 changes: 4 additions & 1 deletion resources/templates/view/4/pages/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
<a href="{{route('@@indexRoute@@')}}">@@table@@</a>
</li>
<li class="breadcrumb-item">
<a href="{{route('@@showRoute@@',$model->@@routeModelKey@@)}}">{{$model->id}}</a>
<a href="{{route('@@showRoute@@',$model->@@routeModelKey@@)}}">{{$model->@@tableTitle@@}}</a>
</li>
<li class="breadcrumb-item">
Edit
</li>
@endsection
@section('header')
<h3><i class="fa fa-pencil"></i> Edit {{$model->@@tableTitle@@}}</h3>
@endSection

@section('tools')
@@createLink@@
Expand Down
4 changes: 3 additions & 1 deletion resources/templates/view/4/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
@@table@@
</li>
@endsection

@section('header')
<h3><i class="fa fa-list"></i> @@table@@ </h3>
@endsection
@section('tools')
@@createLink@@
@endsection
Expand Down
8 changes: 5 additions & 3 deletions resources/templates/view/4/pages/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
<a href="{{route('@@indexRoute@@')}}">@@table@@</a>
</li>
<li class="breadcrumb-item">
{{$record->id}}
{{$record->@@tableTitle@@}}
</li>

@endsection

@section('header')
<h3><i class="fa fa-eye"></i> {{$record->@@tableTitle@@}}</h3>
@endsection
@section('tools')
<div class="btn-group">
@@buttons@@
@@buttons@@
</div>
@endsection

Expand Down
2 changes: 1 addition & 1 deletion resources/templates/view/4/panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="card-header">
<div class="row">
<div class="col-sm-9">
<a href="{{route('@@showRoute@@',$record->@@routeModelKey@@)}}"> @@headline@@</a>
<a href="{{route('@@showRoute@@',$record->@@routeModelKey@@)}}"> {{$record->@@headline@@}}</a>
</div>
<div class="col-sm-3 text-right">
<div class="btn-group">
Expand Down
6 changes: 6 additions & 0 deletions src/config/laracrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@
'suffix' => 'Factory'
],
'view' => [
/**
* There are one column that used as title for that table. For example title column in posts table. name column in categories table etc
*/
'titles' => [
//table=>column e.g categories=>name
],
/**
* Path to the main folder. Folder path are relative to base_path
*/
Expand Down
1 change: 1 addition & 0 deletions src/lara-crud/View/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function template()
return (new TemplateManager("view/{$this->version}/pages/edit.html", [
'layout' => config('laracrud.view.layout'),
'table' => $this->table->name(),
'tableTitle' => $this->getTitleColumn(),
'folder' => $prefix . $this->form->getFolder(),
'routeModelKey' => $this->dataStore['routeModelKey'] ?? 'id',
'partialFilename' => Str::singular($this->table->name()),
Expand Down
6 changes: 6 additions & 0 deletions src/lara-crud/View/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,10 @@ protected function isIgnoreAble(Column $column)
}
return false;
}

public function getTitleColumn()
{
$titles = config('laracrud.view.titles', []);
return isset($titles[$this->table->name()]) ? $titles[$this->table->name()] : 'id';
}
}
4 changes: 2 additions & 2 deletions src/lara-crud/View/Partial/Panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public function template()
$link = new Link($this->table->name());
$routeKey = $this->model->getRouteKeyName();
$tempMan = new TemplateManager("view/{$this->version}/panel.html", [
'headline' => '{{$record->id}}',
'headline' => $this->getTitleColumn(),
'table' => $this->table->name(),
'routeModelKey' =>$routeKey,
'routeModelKey' => $routeKey,
'showLink' => $link->show($routeKey),
'showRoute' => Page::getRouteName('show', $this->table->name()),
'editLink' => $this->editedBy == 'form' ? $link->edit($routeKey) : $link->editModal($this->table),
Expand Down
1 change: 1 addition & 0 deletions src/lara-crud/View/Show.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function template()
$routeKey = $this->dataStore['routeModelKey'] ?? 'id';
return (new TemplateManager("view/{$this->version}/pages/show.html", [
'table' => $this->table->name(),
'tableTitle' => $this->getTitleColumn(),
'layout' => config('laracrud.view.layout'),
'folder' => $prefix . $this->panel->getFolder(),
'routeModelKey' => $this->model->getRouteKeyName(),
Expand Down

0 comments on commit a9ad22d

Please sign in to comment.