Permalink
Browse files

Split clients list into active and inactive views as with projects

  • Loading branch information...
lovett committed Feb 5, 2019
1 parent 6d0422e commit da7be9296c4a284ab0bfe0890eded60674684309
Showing with 49 additions and 7 deletions.
  1. +12 −1 app/Client.php
  2. +32 −3 app/Helpers/LinkHelper.php
  3. +2 −1 app/Http/Controllers/ClientController.php
  4. +1 −0 phpcs.xml
  5. +2 −2 resources/views/layouts/app.blade.php
@@ -33,7 +33,18 @@ class Client extends Model
'status' => 'clients.active',
'locality' => 'clients.locality',
'created' => 'clients.created_at',
'active' => 'clients.active',
];
/**
* Alternate values that should be mapped to incoming search keywords.
*
* @var array
*/
public static $searchAliases = [
'clients.active' => [
'active' => true,
'inactive' => false,
],
];
/**
@@ -176,11 +176,16 @@ public static function getSubnav()
}
if ($resource === 'project') {
$links[] = self::projectIndexLink();
$links[] = self::projectsIndexLink();
$links[] = self::inactiveProjectsLink();
}
if ($resource !== 'project') {
if ($resource === 'client') {
$links[] = self::clientsIndexLink();
$links[] = self::inactiveClientsLink();
}
if (empty($links)) {
$links[] = self::navLink("{$resource}.index", "{$capitalizedResource} List", []);
}
@@ -206,7 +211,7 @@ public static function firstRouteSegment()
/**
* The default list view of the project list is a preset search.
*/
public static function projectIndexLink()
public static function projectsIndexLink()
{
return self::navLink(
'project.index',
@@ -215,6 +220,18 @@ public static function projectIndexLink()
);
}
/**
* The default list view of the client list is a preset search.
*/
public static function clientsIndexLink()
{
return self::navLink(
'client.index',
'Clients',
['q' => 'status:active']
);
}
/**
* Secondary view of the project list limited to inactive projects.
*/
@@ -226,4 +243,16 @@ public static function inactiveProjectsLink()
['q' => 'status:inactive']
);
}
/**
* Secondary view of the client list limited to inactive projects.
*/
public static function inactiveClientsLink()
{
return self::navLink(
'client.index',
'Inactive Clients',
['q' => 'status:inactive']
);
}
}
@@ -48,7 +48,8 @@ public function index(Request $request)
if ($query !== null) {
$searchFields = $this->parseSearchQuery(
$query,
Client::$searchables
Client::$searchables,
Client::$searchAliases
);
$clients = Client::search($clients, $searchFields);
@@ -22,6 +22,7 @@
<exclude name="Squiz.Commenting.FileComment.MissingPackageTag" />
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn" />
<exclude name="Squiz.Commenting.LongConditionClosingComment.Missing" />
<exclude name="Squiz.ControlStructures.ElseIfDeclaration.NotAllowed" />
<exclude name="Squiz.ControlStructures.SwitchDeclaration.BreakIndent" />
<exclude name="Squiz.Files.FileExtension.ClassFound" />
<exclude name="Squiz.Operators.ComparisonOperatorUsage.ImplicitTrue" />
@@ -68,8 +68,8 @@
{!! LinkHelper::primaryNavLink('dashboard', 'Dashboard') !!}
{!! LinkHelper::primaryNavLink('time.index', 'Time') !!}
{!! LinkHelper::primaryNavLink('invoice.index', 'Invoices') !!}
{!! LinkHelper::projectIndexLink() !!}
{!! LinkHelper::primaryNavLink('client.index', 'Clients') !!}
{!! LinkHelper::projectsIndexLink() !!}
{!! LinkHelper::clientsIndexLink() !!}
{!! LinkHelper::primaryNavLink('estimate.index', 'Estimates') !!}
<li class="nav-item">
<a href="{{ route('logout') }}"

0 comments on commit da7be92

Please sign in to comment.