Skip to content

Commit

Permalink
Created new Settings screen
Browse files Browse the repository at this point in the history
Updates #376
  • Loading branch information
inghamn committed Sep 26, 2024
1 parent e9e7068 commit 8f791f5
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 79 deletions.
26 changes: 13 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions language/en_US/LC_MESSAGES/labels.po
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ msgstr "Edit"
msgid "delete"
msgstr "Delete"

msgid "settings"
msgstr "Settings"

msgid "search"
msgstr "Search"

Expand Down
15 changes: 15 additions & 0 deletions src/Web/Settings/Index/Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* @copyright 2024 City of Bloomington, Indiana
* @license https://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE
*/
declare (strict_types=1);
namespace Web\Settings\Index;

class Controller extends \Web\Controller
{
public function __invoke(array $params): \Web\View
{
return new View();
}
}
49 changes: 49 additions & 0 deletions src/Web/Settings/Index/View.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* @copyright 2024 City of Bloomington, Indiana
* @license https://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE
*/
declare (strict_types=1);
namespace Web\Settings\Index;

class View extends \Web\View
{
public function __construct()
{
parent::__construct();

$this->vars = [
'links' => $this->links()
];
}

public function render(): string
{
return $this->twig->render('html/settings/index.twig', $this->vars);
}

private function links(): array
{
$links = [];
$routes = [
'applicants' => 'applicant',
'departments'=> 'department',
'appointers' => 'appointer',
'races' => 'race',
'users' => 'user',
'tags' => 'tag',
'legislationTypes' => 'legislationType',
'legislationActionTypes' => 'legislationActionType',
'legislationStatuses' => 'legislationStatus'
];
foreach ($routes as $plural=>$single) {
if (parent::isAllowed($plural, 'index')) {
$links[] = [
'url' => parent::generateUri("$plural.index"),
'label' => $this->_([$single, $plural, 10])
];
}
}
return $links;
}
}
4 changes: 4 additions & 0 deletions src/Web/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@
$r->get('index', '' , Web\Seats\List\Controller::class);
});

$map->attach('settings.', '/settings', function ($r) {
$r->get('index', '' , Web\Settings\Index\Controller::class);
});

$map->attach('site.', '/site', function ($r) {
$r->get('updateContent', '/updateContent', Web\Site\Update\Controller::class)->allows(['POST']);
$r->get('index', '' , Web\Site\Content\Controller::class);
Expand Down
37 changes: 0 additions & 37 deletions templates/html/layouts/partials/admin_menu.twig

This file was deleted.

31 changes: 2 additions & 29 deletions templates/html/layouts/partials/user_menu.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,8 @@
{{ USER.getFullname() }}
</button>
<ul class="dropdown-menu">
{% if isAllowed('applicants', 'index') %}
<li><a class="dropdown-item" href="{{ uri('applicants.index') }}">{{ _(['applicant', 'applicants', 10]) }}</a></li>
{% endif %}
{% if isAllowed('departments', 'index') %}
<li><a class="dropdown-item" href="{{ uri('departments.index') }}">{{ _(['department', 'departments', 10]) }}</a></li>
{% endif %}
{% if isAllowed('appointers', 'index') %}
<li><a class="dropdown-item" href="{{ uri('appointers.index') }}">{{ _(['appointer', 'appointers', 10]) }}</a></li>
{% endif %}
{% if isAllowed('races', 'index') %}
<li><a class="dropdown-item" href="{{ uri('races.index') }}">{{ _(['race', 'races', 10]) }}</a></li>
{% endif %}
{% if isAllowed('users', 'index') %}
<li><a class="dropdown-item" href="{{ uri('users.index') }}">{{ _(['user', 'users', 10]) }}</a></li>
{% endif %}
{% if isAllowed('tags', 'index') %}
<li><a class="dropdown-item" href="{{ uri('tags.index') }}">{{ _(['tag', 'tags', 10]) }}</a></li>
{% endif %}
{% if isAllowed('legislationTypes', 'index') %}
<li><a class="dropdown-item" href="{{ uri('legislationTypes.index') }}">{{ _(['legislationType', 'legislationTypes', 10]) }}</a></li>
{% endif %}
{% if isAllowed('legislationActionTypes', 'index') %}
<li><a class="dropdown-item" href="{{ uri('legislationActionTypes.index') }}">{{ _(['legislationActionType', 'legislationActionTypes', 10]) }}</a></li>
{% endif %}
{% if isAllowed('legislationStatuses', 'index') %}
<li><a class="dropdown-item" href="{{ uri('legislationStatuses.index') }}">{{ _(['legislationStatus', 'legislationStatuses', 10]) }}</a></li>
{% endif %}
{% if isAllowed('site', 'siteContent') %}
<li><a class="dropdown-item" href="{{ uri('site.index') }}">{{ _('siteContent') }}</a></li>
{% if isAllowed('settings', 'index') %}
<li><a class="dropdown-item" href="{{ uri('settings.index') }}">{{ _('settings') }}</a></li>
{% endif %}

<li><a class="dropdown-item" href="{{ uri('login.logout') }}">{{ _('logout') }}</a></li>
Expand Down
17 changes: 17 additions & 0 deletions templates/html/settings/index.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{#
* @copyright 2024 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE
* @param array links
#}
{% extends "html/layouts/default.twig" %}
{% block content %}
<section>
<header><h1>{{ _('settings') }}</h1></header>

<ul>{% for l in links %}
<li><a href="{{ l.url }}">{{ l.label }}</a></li>
{% endfor %}
<ul>
</section>

{% endblock %}

0 comments on commit 8f791f5

Please sign in to comment.