Compare commits

..

2 Commits

  1. 63
      app/Http/Controllers/DashController.php
  2. 18
      app/Http/Controllers/ProfileController.php
  3. 66
      app/Models/Table.php
  4. 1
      resources/views/auth/login.blade.php
  5. 1
      resources/views/auth/passwords/email.blade.php
  6. 1
      resources/views/auth/passwords/reset.blade.php
  7. 1
      resources/views/auth/register.blade.php
  8. 2
      resources/views/layouts/app.blade.php
  9. 1
      resources/views/profile/edit-account.blade.php
  10. 3
      resources/views/profile/edit-profile.blade.php
  11. 11
      resources/views/profile/view.blade.php
  12. 16
      resources/views/table/_sort-dropdown.blade.php
  13. 1
      resources/views/table/conf.blade.php
  14. 1
      resources/views/table/create.blade.php
  15. 1
      resources/views/table/propose/layout.blade.php
  16. 1
      resources/views/table/revisions.blade.php
  17. 1
      resources/views/table/view.blade.php
  18. 22
      resources/views/welcome.blade.php

@ -20,71 +20,20 @@ class DashController extends Controller
return back(); return back();
} }
$defaultSort = 'last-updated';
$sort = \Input::get('tableSort', $defaultSort);
$data['sortOptions'] = [
'most-visited' => 'Most Visited',
'last-updated' => 'Last Updated',
'most-updated' => 'Most Changed',
// 'most-discussed' => 'Most Discussed',
// 'most-liked' => 'Most Liked',
'newest' => 'Newest',
'oldest' => 'Oldest',
'most-rows' => 'Longest',
'least-rows' => 'Shortest',
];
if (!in_array($sort, array_keys($data['sortOptions']))) {
$sort = $defaultSort;
}
$data['tableSort'] = $sort;
$data['users'] = User::orderBy('updated_at', 'desc') $data['users'] = User::orderBy('updated_at', 'desc')
->withCount(['tables']) ->withCount(['tables'])
->paginate(10, ['id', 'title', 'name', 'tables_count'], 'userPage') ->paginate(10, ['id', 'title', 'name', 'tables_count'], 'userPage')
->appends(\Input::except('userPage')); ->appends(\Input::except('userPage'));
$tableQuery = Table::forList(); $sort = Table::resolveSortType(\Input::get('tableSort'));
switch ($sort) { $data['sortOptions'] = Table::getSortOptions();
case 'most-visited':
$tableQuery = $tableQuery->orderBy('visits', 'desc');
break;
case 'last-updated':
$tableQuery = $tableQuery->orderBy('updated_at', 'desc');
break;
case 'most-updated':
$tableQuery = $tableQuery->orderBy('revisions_count', 'desc');
break;
case 'most-discussed':
$tableQuery = $tableQuery->orderBy('comments_count', 'desc');
break;
case 'most-liked':
$tableQuery = $tableQuery->orderBy('favourites_count', 'desc');
break;
case 'most-rows':
$tableQuery = $tableQuery
->join('revisions', 'revisions.id', '=', 'tables.revision_id')
->orderBy('revisions.row_count', 'desc');
break;
case 'least-rows':
$tableQuery = $tableQuery
->join('revisions', 'revisions.id', '=', 'tables.revision_id')
->orderBy('revisions.row_count', 'asc');
break;
case 'newest':
$tableQuery = $tableQuery->orderBy('created_at', 'desc');
break;
case 'oldest':
$tableQuery = $tableQuery->orderBy('created_at', 'asc');
break;
}
$data['tables'] = $tableQuery->paginate(10, ['*'], 'tablePage') $data['tables'] = Table::forList()->tableSort($sort)
->paginate(10, ['*'], 'tablePage')
->appends(\Input::except('tablePage')); ->appends(\Input::except('tablePage'));
$data['tableSort'] = $sort;
$data['showGreeter'] = !$dismiss && !$request->cookie('dismiss-greeter', false); $data['showGreeter'] = !$dismiss && !$request->cookie('dismiss-greeter', false);
return view('welcome', $data); return view('welcome', $data);

@ -3,6 +3,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Table;
use App\Models\User; use App\Models\User;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -18,14 +19,15 @@ class ProfileController extends Controller
*/ */
public function view(User $user) public function view(User $user)
{ {
$tables = $user->tables()->forList()->orderByDesc('updated_at')->paginate(10); $data['user'] = $user;
$tables_count = $user->tables()->count(); $data['tables_count'] = $user->tables()->count();
return view('profile.view')->with(compact( $data['tableSort'] = $sort = Table::resolveSortType(\Input::get('tableSort'));
'tables', $data['sortOptions'] = Table::getSortOptions();
'user',
'tables_count' $data['tables'] = $user->tables()->forList()->tableSort($sort)->paginate(10);
));
return view('profile.view', $data);
} }
/** /**

@ -150,6 +150,8 @@ class Table extends BaseModel
} }
} }
if ($name == 'handle') return '@' . $this->cachedOwner()->name . '/' . $this->name;
if ($name == 'draftSessionKey') return "proposal.{$this->id}"; if ($name == 'draftSessionKey') return "proposal.{$this->id}";
return parent::__get($name); return parent::__get($name);
@ -192,4 +194,68 @@ class Table extends BaseModel
->with('owner:id,name,title') ->with('owner:id,name,title')
->withCount(['favourites', 'forks', 'revisions', 'proposals', 'comments']); ->withCount(['favourites', 'forks', 'revisions', 'proposals', 'comments']);
} }
public static function getSortOptions()
{
return [
'most-visited' => 'Most Visited',
'last-updated' => 'Last Updated',
'most-updated' => 'Most Changed',
// 'most-discussed' => 'Most Discussed',
// 'most-liked' => 'Most Liked',
'newest' => 'Newest',
'oldest' => 'Oldest',
'most-rows' => 'Longest',
'least-rows' => 'Shortest',
];
}
public static function resolveSortType($sort)
{
$defaultSort = 'last-updated';
if (!in_array($sort, array_keys(self::getSortOptions()))) {
$sort = $defaultSort;
}
return $sort;
}
public function scopeTableSort(Builder $query, $sort)
{
switch ($sort) {
case 'most-visited':
$query = $query->orderBy('visits', 'desc');
break;
case 'last-updated':
$query = $query->orderBy('updated_at', 'desc');
break;
case 'most-updated':
$query = $query->orderBy('revisions_count', 'desc');
break;
case 'most-discussed':
$query = $query->orderBy('comments_count', 'desc');
break;
case 'most-liked':
$query = $query->orderBy('favourites_count', 'desc');
break;
case 'most-rows':
$query = $query
->join('revisions', 'revisions.id', '=', 'tables.revision_id')
->orderBy('revisions.row_count', 'desc');
break;
case 'least-rows':
$query = $query
->join('revisions', 'revisions.id', '=', 'tables.revision_id')
->orderBy('revisions.row_count', 'asc');
break;
case 'newest':
$query = $query->orderBy('created_at', 'desc');
break;
case 'oldest':
$query = $query->orderBy('created_at', 'asc');
break;
}
return $query;
}
} }

@ -1,4 +1,5 @@
@extends('layouts.app') @extends('layouts.app')
@section('title', "Login")
@section('content') @section('content')
<div class="container"> <div class="container">

@ -1,4 +1,5 @@
@extends('layouts.app') @extends('layouts.app')
@section('title', "Forgotten Password")
@section('content') @section('content')
<div class="container"> <div class="container">

@ -1,4 +1,5 @@
@extends('layouts.app') @extends('layouts.app')
@section('title', "Reset Password")
@section('content') @section('content')
<div class="container"> <div class="container">

@ -1,4 +1,5 @@
@extends('layouts.app') @extends('layouts.app')
@section('title', "Register")
@section('content') @section('content')
<div class="container"> <div class="container">

@ -8,7 +8,7 @@
<!-- CSRF Token --> <!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}"> <meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title> <title>@yield('title', 'MISSING TITLE') - datatable.directory</title>
<!-- Scripts --> <!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script> <script src="{{ asset('js/app.js') }}" defer></script>

@ -1,6 +1,7 @@
{{-- Profile edit form --}} {{-- Profile edit form --}}
@extends('layouts.app') @extends('layouts.app')
@section('title', "Account Settings")
@section('content') @section('content')
@php(Widget::setLayout(3, 7)) @php(Widget::setLayout(3, 7))

@ -1,6 +1,7 @@
{{-- Profile edit form --}} {{-- Profile edit form --}}
@extends('layouts.app') @extends('layouts.app')
@section('title', "Edit Profile")
@section('content') @section('content')
<form method="POST" action="{{route('profile.store')}}" class="row justify-content-center" <form method="POST" action="{{route('profile.store')}}" class="row justify-content-center"
@ -10,7 +11,7 @@
<div class="col-md-10"> <div class="col-md-10">
@php(Widget::setLayout(3, 7)) @php(Widget::setLayout(3, 7))
{!! Widget::header(1, 'Profile Settings') !!} {!! Widget::header(1, 'Edit Profile') !!}
{!! Widget::par(' {!! Widget::par('
Username can be changed on the Username can be changed on the
<a href="'.e(route('account.edit')).'">account settings</a> page. <a href="'.e(route('account.edit')).'">account settings</a> page.

@ -1,5 +1,6 @@
{{-- User's dashboard / profile page --}} {{-- User's dashboard / profile page --}}
@extends('layouts.app') @extends('layouts.app')
@section('title', "$user->title's Tables")
@php @php
/** @var \App\Models\Table[] $tables */ /** @var \App\Models\Table[] $tables */
@ -76,12 +77,18 @@
@icon(fa-table fa-pr fa-large) @icon(fa-table fa-pr fa-large)
<h2> <h2>
@if(authed() && user()->is($user)) @if(authed() && user()->is($user))
Your Tables Your Tables:
@else @else
User's Tables User's Tables:
@endif @endif
</h2> </h2>
@include('table._sort-dropdown', [
'link' => route('profile.view',
Input::except(['tableSort', 'page'])
+ ['tableSort' => '__sort'] + ['user' => $user->name])
])
<nav class="ml-auto" aria-label="Pages of the table list"> <nav class="ml-auto" aria-label="Pages of the table list">
{{ $tables->links(null, ['ulClass' => 'pagination-sm mb-0 pagination-outline-light']) }} {{ $tables->links(null, ['ulClass' => 'pagination-sm mb-0 pagination-outline-light']) }}
</nav> </nav>

@ -0,0 +1,16 @@
<span>
<a class="nav-link dropdown-toggle link-no-color pl-1 ml-1 pr-2"
data-toggle="dropdown" href="#" role="button" aria-haspopup="true"
aria-expanded="false">{{ $sortOptions[$tableSort] }}</a>
<span class="dropdown-menu">
@foreach($sortOptions as $k => $label)
<a class="dropdown-item"
href="{{ str_replace('__sort', $k, $link) }}">
{{ $label }}
</a>
{{--@endif--}}
@endforeach
</span>
</span>
{{-- route('dash', Input::except(['tableSort', 'tablePage']) + ['tableSort' => $k]) --}}

@ -1,6 +1,7 @@
{{-- Basic table view --}} {{-- Basic table view --}}
@extends('layouts.app') @extends('layouts.app')
@section('title', "Table Settings - \"$table->title\"")
@php @php
/** @var \App\Models\Table $table */ /** @var \App\Models\Table $table */

@ -1,6 +1,7 @@
{{-- New table form --}} {{-- New table form --}}
@extends('layouts.app') @extends('layouts.app')
@section('title', "New Table")
@section('content') @section('content')
<form method="POST" action="{{route('table.storeNew')}}" class="row justify-content-center" <form method="POST" action="{{route('table.storeNew')}}" class="row justify-content-center"

@ -1,6 +1,7 @@
{{-- Basic table view --}} {{-- Basic table view --}}
@extends('layouts.app') @extends('layouts.app')
@section('title', "Draft Change - \"$table->title\"")
@php @php
/** @var \App\Models\Table $table */ /** @var \App\Models\Table $table */

@ -1,6 +1,7 @@
{{-- List of table revisions --}} {{-- List of table revisions --}}
@extends('layouts.app') @extends('layouts.app')
@section('title', "Revisions - $table->title")
@php @php
/** @var \App\Models\Table $table */ /** @var \App\Models\Table $table */

@ -1,6 +1,7 @@
{{-- Basic table view --}} {{-- Basic table view --}}
@extends('layouts.app') @extends('layouts.app')
@section('title', "Table \"$table->title\"")
@php @php
/** @var \App\Models\Table $table */ /** @var \App\Models\Table $table */

@ -6,6 +6,7 @@
@endphp @endphp
@extends('layouts.app') @extends('layouts.app')
@section('title', "All Tables")
@section('content') @section('content')
@if($showGreeter) @if($showGreeter)
@ -50,21 +51,12 @@
<div class="card-header card-header-extra"> <div class="card-header card-header-extra">
@icon(fa-table fa-pr fa-large) @icon(fa-table fa-pr fa-large)
<h2>Tables:</h2> <h2>Tables:</h2>
<span>
<a class="nav-link dropdown-toggle link-no-color pl-1 ml-1 pr-2" @include('table._sort-dropdown', [
data-toggle="dropdown" href="#" role="button" aria-haspopup="true" 'link' => route('dash',
aria-expanded="false">{{ $sortOptions[$tableSort] }}</a> Input::except(['tableSort', 'tablePage'])
<div class="dropdown-menu"> + ['tableSort' => '__sort'])
@foreach($sortOptions as $k => $label) ])
{{--@if($k != $tableSort)--}}
<a class="dropdown-item"
href="{{ route('dash', Input::except(['tableSort', 'tablePage']) + ['tableSort' => $k]) }}">
{{ $label }}
</a>
{{--@endif--}}
@endforeach
</div>
</span>
<nav class="ml-auto" aria-label="Pages of the table list"> <nav class="ml-auto" aria-label="Pages of the table list">
{{ $tables->links(null, [ {{ $tables->links(null, [

Loading…
Cancel
Save