mirror of
https://github.com/prurigro/hypothetical.git
synced 2024-11-22 07:54:11 -05:00
Add export functionality to the dashboard edit-list feature, and clean up the edit-list blade a bit
This commit is contained in:
parent
318ca8a80c
commit
a9455f99a0
4 changed files with 52 additions and 38 deletions
40
readme.md
40
readme.md
|
@ -34,24 +34,6 @@ First add a function to generate the page:
|
|||
* `rows`: A function returning an array containing the data to be shown on this page
|
||||
* `cols`: An array containing a set of arrays where the first element of each is the visible column name and the second is the column name in the array
|
||||
|
||||
#### Export Functionality
|
||||
|
||||
Viewable models must have an entry in the switch statement of the `getExport` function to make the export button work:
|
||||
|
||||
```php
|
||||
switch ($model) {
|
||||
case 'contact':
|
||||
$headings = [ 'Date', 'Name', 'Email', 'Message' ];
|
||||
$items = Contact::select('created_at', 'name', 'email', 'message')->get();
|
||||
break;
|
||||
default:
|
||||
abort(404);
|
||||
}
|
||||
```
|
||||
|
||||
* `$headings`: The visible column names in the same order as the array containing the items to be exported
|
||||
* `$items`: A function returning an array containing the data to be exported
|
||||
|
||||
### Adding an Editable Model to the Dashboard
|
||||
|
||||
#### Editable List of Rows
|
||||
|
@ -67,7 +49,8 @@ Viewable models must have an entry in the switch statement of the `getExport` fu
|
|||
'rows' => Shows::getShowsList(),
|
||||
'column' => 'title',
|
||||
'sortcol' => false,
|
||||
'delete' => true
|
||||
'delete' => true,
|
||||
'export' => true
|
||||
]);
|
||||
}
|
||||
```
|
||||
|
@ -96,6 +79,7 @@ Viewable models must have an entry in the switch statement of the `getExport` fu
|
|||
* `column`: The column name in the array that contains the data to display in each row
|
||||
* `sortcol`: The name of the column containing the sort order or `false` to disable
|
||||
* `delete`: A delete button will appear in the list if this is set to `true`
|
||||
* `export`: An export button will appear in the heading if this is set to `true`
|
||||
|
||||
#### Delete Functionality
|
||||
|
||||
|
@ -255,3 +239,21 @@ Add an array to the menu array in `resources/views/dashboard/elements/menu.blade
|
|||
[ 'Contact', 'contact' ]
|
||||
])
|
||||
```
|
||||
|
||||
#### Additional Requirement for Export Functionality
|
||||
|
||||
Viewable models and editable models with `export` set to `true` must have an entry in the switch statement of the `getExport` function to make the export button work:
|
||||
|
||||
```php
|
||||
switch ($model) {
|
||||
case 'contact':
|
||||
$headings = [ 'Date', 'Name', 'Email', 'Message' ];
|
||||
$items = Contact::select('created_at', 'name', 'email', 'message')->get();
|
||||
break;
|
||||
default:
|
||||
abort(404);
|
||||
}
|
||||
```
|
||||
|
||||
* `$headings`: The visible column names in the same order as the array containing the items to be exported
|
||||
* `$items`: A function returning an array containing the data to be exported
|
||||
|
|
5
resources/assets/sass/dashboard.scss
vendored
5
resources/assets/sass/dashboard.scss
vendored
|
@ -106,8 +106,10 @@ body {
|
|||
color: $c-dashboard-light;
|
||||
font-weight: bold;
|
||||
|
||||
.btn {
|
||||
.dashboard-heading {
|
||||
float: right;
|
||||
|
||||
.btn {
|
||||
position: relative;
|
||||
bottom: 3px;
|
||||
min-width: 70px;
|
||||
|
@ -121,6 +123,7 @@ body {
|
|||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.form-control:focus {
|
||||
|
|
|
@ -7,8 +7,11 @@
|
|||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{{ $heading }}
|
||||
|
||||
<div class="dashboard-heading">
|
||||
@yield('dashboard-heading')
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
@yield('dashboard-body')
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
@extends('dashboard.core')
|
||||
|
||||
@section('dashboard-heading')
|
||||
@if($export == true)
|
||||
<a href="/dashboard/export/{{ $model }}"><button type="button" class="btn btn-default">Export</button></a>
|
||||
@endif
|
||||
|
||||
<button type="button" class="new-button btn btn-default">New</button>
|
||||
@endsection
|
||||
|
||||
@section('dashboard-body')
|
||||
@set('sort_data', $sortcol != false ? "data-sort=$sortcol" : '')
|
||||
@set('sort_icon', $sortcol != false ? '<i class="fa fa-bars sort-icon" title="Click and drag to reorder"></i>' : '')
|
||||
@set('delete_button', $delete == true ? '<button type="button" class="delete-button btn btn-danger">Delete</button>' : '')
|
||||
|
||||
<ul id="edit-list" class="list-group edit-list" data-model="{{ $model }}" {{ $sort_data }}>
|
||||
<ul id="edit-list" class="list-group edit-list" data-model="{{ $model }}" {{ $sortcol != false ? "data-sort=$sortcol" : '' }}>
|
||||
<input type="hidden" name="_token" id="token" value="{{ csrf_token() }}" />
|
||||
|
||||
@foreach($rows as $row)
|
||||
|
@ -17,13 +17,19 @@
|
|||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-xs-9 title-column">
|
||||
{!! $sort_icon !!}
|
||||
@if($sortcol != false)
|
||||
<i class="fa fa-bars sort-icon" title="Click and drag to reorder"></i>
|
||||
@endif
|
||||
|
||||
{{ $row[$column] }}
|
||||
</div>
|
||||
|
||||
<div class="col-xs-3 button-column">
|
||||
<button type="button" class="edit-button btn btn-warning">Edit</button>
|
||||
{!! $delete_button !!}
|
||||
|
||||
@if($delete == true)
|
||||
<button type="button" class="delete-button btn btn-danger">Delete</button>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue