diff --git a/app/Http/Controllers/ItemController.php b/app/Http/Controllers/ItemController.php index 001f9921..6e705856 100644 --- a/app/Http/Controllers/ItemController.php +++ b/app/Http/Controllers/ItemController.php @@ -90,12 +90,20 @@ class ItemController extends Controller * * @return \Illuminate\Http\Response */ - public function index() + public function index(Request $request) { + $trash = (bool)$request->input('trash'); + $data['apps'] = Item::all(); - return view('items.list', $data); + $data['trash'] = Item::onlyTrashed()->get(); + if($trash) { + return view('items.trash', $data); + } else { + return view('items.list', $data); + } } + /** * Show the form for creating a new resource. * @@ -197,11 +205,35 @@ class ItemController extends Controller * @param int $id * @return \Illuminate\Http\Response */ - public function destroy($id) + public function destroy(Request $request, $id) { // - Item::find($id)->delete(); - return redirect()->route('dash') + $force = (bool)$request->input('force'); + if($force) { + Item::withTrashed() + ->where('id', $id) + ->forceDelete(); + } else { + Item::find($id)->delete(); + } + + return redirect()->route('items.index') ->with('success','Item deleted successfully'); } + + /** + * Restore the specified resource from soft deletion. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function restore($id) + { + // + Item::withTrashed() + ->where('id', $id) + ->restore(); + return redirect()->route('items.index') + ->with('success','Item restored successfully'); + } } diff --git a/app/Item.php b/app/Item.php index f1a11265..2121698d 100644 --- a/app/Item.php +++ b/app/Item.php @@ -4,16 +4,25 @@ namespace App; use Illuminate\Database\Eloquent\Model; use Symfony\Component\ClassLoader\ClassMapGenerator; - +use Illuminate\Database\Eloquent\SoftDeletes; class Item extends Model { + use SoftDeletes; + // protected $fillable = [ 'title', 'url', 'colour', 'icon', 'description', 'pinned', 'order' ]; + /** + * The attributes that should be mutated to dates. + * + * @var array + */ + protected $dates = ['deleted_at']; + public static function supportedList() { return [ diff --git a/database/migrations/2018_01_27_155922_create_items_table.php b/database/migrations/2018_01_27_155922_create_items_table.php index 2a2a99dc..66bf466e 100644 --- a/database/migrations/2018_01_27_155922_create_items_table.php +++ b/database/migrations/2018_01_27_155922_create_items_table.php @@ -22,6 +22,7 @@ class CreateItemsTable extends Migration $table->text('description')->nullable(); $table->boolean('pinned')->default(false); $table->integer('order')->default(0); + $table->softDeletes(); $table->timestamps(); }); } diff --git a/public/css/app.css b/public/css/app.css index 68ed6731..015145d1 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -357,11 +357,65 @@ body { .message-container { width: 100%; + padding: 10px 20px; } -.message-container .alert { - margin: 30px; +.message-container2 { + width: 100%; + padding: 10px 20px; +} + +.alert { + margin: 30px auto; text-align: center; + max-width: 800px; + background: #f1f4f7; + padding: 5px 20px; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-pack: center; + -ms-flex-pack: center; + justify-content: center; + padding-left: 80px; + -webkit-box-shadow: 0 0 15px 3px rgba(0, 0, 0, 0.3); + box-shadow: 0 0 15px 3px rgba(0, 0, 0, 0.3); +} + +.alert.alert-success, +.alert.alert-danger { + position: relative; +} + +.alert.alert-success:before, +.alert.alert-danger:before { + content: "\F00C"; + font-family: 'Font Awesome 5 Pro'; + font-weight: 900; + position: absolute; + top: 0; + left: 0; + bottom: 0; + width: 60px; + background: #1cd41c; + text-align: center; + color: white; + line-height: 57px; + font-size: 24px; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + -webkit-box-pack: center; + -ms-flex-pack: center; + justify-content: center; + display: -webkit-box; + display: -ms-flexbox; + display: flex; +} + +.alert.alert-danger:before { + content: "\F00D"; + background: #c00; } #app.header .appheader { @@ -658,9 +712,22 @@ div.create .input input { margin-right: 10px; } +.sidenav { + position: relative; +} + +.sidenav .close-sidenav { + position: absolute; + top: 20px; + right: 20px; + font-size: 24px; + color: #ccc; +} + .sidenav h2 { font-weight: 300; padding: 20px; + margin: 0; } .sidenav ul { @@ -687,6 +754,12 @@ div.create .input input { color: #46b0e6; } +.trashed { + font-size: 11px; + color: #91a1b3; + margin-left: 20px; +} + /*! Huebee v2.0.0 http://huebee.buzz ---------------------------------------------- */ diff --git a/public/js/app.js b/public/js/app.js index 9ed5f252..519cd71c 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -9,8 +9,15 @@ !function(t,e){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",e):"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}("undefined"!=typeof window?window:this,function(){function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var n=this._events=this._events||{},i=n[t]=n[t]||[];return i.indexOf(e)==-1&&i.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var n=this._onceEvents=this._onceEvents||{},i=n[t]=n[t]||{};return i[e]=!0,this}},e.off=function(t,e){var n=this._events&&this._events[t];if(n&&n.length){var i=n.indexOf(e);return i!=-1&&n.splice(i,1),this}},e.emitEvent=function(t,e){var n=this._events&&this._events[t];if(n&&n.length){var i=0,o=n[i];e=e||[];for(var s=this._onceEvents&&this._onceEvents[t];o;){var r=s&&s[o];r&&(this.off(t,o),delete s[o]),o.apply(this,e),i+=r?0:1,o=n[i]}return this}},t}),function(t,e){"function"==typeof define&&define.amd?define("unipointer/unipointer",["ev-emitter/ev-emitter"],function(n){return e(t,n)}):"object"==typeof module&&module.exports?module.exports=e(t,require("ev-emitter")):t.Unipointer=e(t,t.EvEmitter)}(window,function(t,e){function n(){}function i(){}var o=i.prototype=Object.create(e.prototype);o.bindStartEvent=function(t){this._bindStartEvent(t,!0)},o.unbindStartEvent=function(t){this._bindStartEvent(t,!1)},o._bindStartEvent=function(e,n){n=void 0===n||!!n;var i=n?"addEventListener":"removeEventListener";t.navigator.pointerEnabled?e[i]("pointerdown",this):t.navigator.msPointerEnabled?e[i]("MSPointerDown",this):(e[i]("mousedown",this),e[i]("touchstart",this))},o.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},o.getTouch=function(t){for(var e=0;e.5;var o=this.colorGrid[e.toUpperCase()];this.updateCursor(o),this.setTexts(),this.setBackgrounds(),n||this.emitEvent("change",[e,t.hue,t.sat,t.lum])}},f.setTexts=function(){if(this.setTextElems)for(var t=0;t
@endif - @if (count($errors) < 0) + @if (count($errors) > 0)
    diff --git a/resources/views/items/list.blade.php b/resources/views/items/list.blade.php index 6ca15641..8cab77e5 100644 --- a/resources/views/items/list.blade.php +++ b/resources/views/items/list.blade.php @@ -3,7 +3,13 @@ @section('content')
    -
    Application list
    +
    + Application list + @if( isset($trash) && $trash->count() > 0 ) + View trash ({{ $trash->count() }}) + @endif + +
    Add
    diff --git a/resources/views/items/trash.blade.php b/resources/views/items/trash.blade.php new file mode 100644 index 00000000..5c52a0a0 --- /dev/null +++ b/resources/views/items/trash.blade.php @@ -0,0 +1,54 @@ +@extends('app') + +@section('content') +
    +
    +
    + Showing Deleted Applications +
    +
    + Cancel +
    +
    + + + + + + + + + + + + + @if($trash->first()) + @foreach($trash as $app) + + + + + + + + @endforeach + @else + + + + @endif + + + +
    TitleDescriptionUrlRestoreDelete
    {{ $app->title }}{{ $app->description }}{{ $app->url }} + {!! Form::open(['method' => 'DELETE','route' => ['items.destroy', $app->id],'style'=>'display:inline']) !!} + + + {!! Form::close() !!} +
    + No items found +
    +
    + + +@endsection \ No newline at end of file diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php index 115027f7..c5fdaca8 100644 --- a/resources/views/welcome.blade.php +++ b/resources/views/welcome.blade.php @@ -4,8 +4,15 @@ @if($apps->first()) @include('sortable') @else - There are currently no Applications, add one here +
    +
    +

    There are currently no pinned Applications, Add an application here or Pin an item to the dash

    +
    + +
    +
    @include('add') +
    @endif diff --git a/routes/web.php b/routes/web.php index 1836da53..30000759 100644 --- a/routes/web.php +++ b/routes/web.php @@ -17,6 +17,7 @@ Route::resources([ 'items' => 'ItemController', ]); Route::get('items/pin/{id}', 'ItemController@pin')->name('items.pin'); +Route::get('items/restore/{id}', 'ItemController@restore')->name('items.restore'); Route::get('items/unpin/{id}', 'ItemController@unpin')->name('items.unpin'); Route::get('items/pintoggle/{id}/{ajax?}', 'ItemController@pinToggle')->name('items.pintoggle'); Route::post('order', 'ItemController@setOrder')->name('items.order'); \ No newline at end of file