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
|
* `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
|
* `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
|
### Adding an Editable Model to the Dashboard
|
||||||
|
|
||||||
#### Editable List of Rows
|
#### 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(),
|
'rows' => Shows::getShowsList(),
|
||||||
'column' => 'title',
|
'column' => 'title',
|
||||||
'sortcol' => false,
|
'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
|
* `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
|
* `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`
|
* `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
|
#### Delete Functionality
|
||||||
|
|
||||||
|
@ -255,3 +239,21 @@ Add an array to the menu array in `resources/views/dashboard/elements/menu.blade
|
||||||
[ 'Contact', 'contact' ]
|
[ '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
|
||||||
|
|
25
resources/assets/sass/dashboard.scss
vendored
25
resources/assets/sass/dashboard.scss
vendored
|
@ -106,19 +106,22 @@ body {
|
||||||
color: $c-dashboard-light;
|
color: $c-dashboard-light;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|
||||||
.btn {
|
.dashboard-heading {
|
||||||
float: right;
|
float: right;
|
||||||
position: relative;
|
|
||||||
bottom: 3px;
|
|
||||||
min-width: 70px;
|
|
||||||
height: 26px;
|
|
||||||
padding-top: 1px;
|
|
||||||
padding-bottom: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
.btn {
|
||||||
color: $c-text;
|
position: relative;
|
||||||
text-decoration: none;
|
bottom: 3px;
|
||||||
|
min-width: 70px;
|
||||||
|
height: 26px;
|
||||||
|
padding-top: 1px;
|
||||||
|
padding-bottom: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: $c-text;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,10 @@
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
{{ $heading }}
|
{{ $heading }}
|
||||||
@yield('dashboard-heading')
|
|
||||||
|
<div class="dashboard-heading">
|
||||||
|
@yield('dashboard-heading')
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
@extends('dashboard.core')
|
@extends('dashboard.core')
|
||||||
|
|
||||||
@section('dashboard-heading')
|
@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>
|
<button type="button" class="new-button btn btn-default">New</button>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('dashboard-body')
|
@section('dashboard-body')
|
||||||
@set('sort_data', $sortcol != false ? "data-sort=$sortcol" : '')
|
<ul id="edit-list" class="list-group edit-list" data-model="{{ $model }}" {{ $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 }}>
|
|
||||||
<input type="hidden" name="_token" id="token" value="{{ csrf_token() }}" />
|
<input type="hidden" name="_token" id="token" value="{{ csrf_token() }}" />
|
||||||
|
|
||||||
@foreach($rows as $row)
|
@foreach($rows as $row)
|
||||||
|
@ -17,13 +17,19 @@
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-9 title-column">
|
<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] }}
|
{{ $row[$column] }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-xs-3 button-column">
|
<div class="col-xs-3 button-column">
|
||||||
<button type="button" class="edit-button btn btn-warning">Edit</button>
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue