Skip to content

Commit

Permalink
Fixed: committee members with open seating
Browse files Browse the repository at this point in the history
  • Loading branch information
inghamn committed Oct 7, 2024
1 parent de4215f commit 4b83c5b
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 43 deletions.
4 changes: 0 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"repositories": [{
"type": "vcs",
"url": "https://github.com/City-of-Bloomington/blossom-lib"
}],
"require": {
"php": ">=8.1",
"aura/router": "@stable",
Expand Down
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.

60 changes: 54 additions & 6 deletions src/Web/Committees/Members/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

use Application\Models\Committee;
use Application\Models\SeatTable;
use Application\Models\OfficeTable;
use Web\Seats\List\Controller as SeatsController;
use Web\View;

class Controller extends \Web\Controller
Expand All @@ -23,24 +25,70 @@ public function __invoke(array $params): View

if ($committee->getType() === 'seated') {
$data = SeatTable::currentData(['committee_id'=>$committee->getId()]);
$seat_data = [];
foreach ($data['results'] as $row) {
$seat_data[] = $row;
$seat_data = SeatsController::filter_viewable($data['results']);

switch ($this->outputFormat) {
case 'csv':
return new \Web\Views\CSVView($committee->getName(), $seat_data);
break;

case 'json':
return new \Web\Views\JSONView($seat_data);
break;

default:
return new SeatedView($committee, $seat_data);
}
return new SeatedView($committee, $seat_data);
}
else {
$search = ['current' => true];
if (isset($_GET['current']) && !$_GET['current']) {
$search['current'] = false;
}

$members = [];
$results = $committee->getMembers($search);
foreach ($results as $member) { $members[] = $member; }
$members = self::member_data($results);
return new OpenView($committee, $members, $search['current']);
}
}
return new \Web\View\NotFoundView();
}

private static function member_data($results): array
{
$data = [];
$canView = \Web\View::isAllowed('people', 'viewContactInfo');
$fields = ['email', 'address', 'city', 'state', 'zip'];
$ot = new OfficeTable();
foreach ($results as $m) {
$offices = [];
$person = $m->getPerson();
$search = ['person_id' => $m->getPerson_id(),
'committee_id' => $m->getCommittee_id(),
'current' => date('Y-m-d') ];
foreach ($ot->find($search) as $o) { $offices[] = $o; }

$row = [
'committee_id' => $m->getCommittee_id(),
'committee_name' => $m->getCommittee()->getName(),
'member_id' => $m->getId(),
'member_person_id' => $m->getPerson_id(),
'member_firstname' => $person->getFirstname(),
'member_lastname' => $person->getLastname(),
'member_website' => $person->getWebsite(),
'member_startDate' => $m->getStartDate(),
'member_endDate' => $m->getEndDate(),
'offices' => $offices
];
if ($canView) {
$row['member_email' ] = $person->getEmail();
$row['member_address'] = $person->getAddress();
$row['member_city' ] = $person->getCity();
$row['member_state' ] = $person->getState();
$row['member_zip' ] = $person->getZip();
}
$data[] = $row;
}
return $data;
}
}
23 changes: 11 additions & 12 deletions src/Web/Committees/Members/OpenView.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public function __construct(Committee $committee, array $members, bool $current)
parent::__construct();

$title = $current
? parent::_(['current_member', 'current_members', count($members)])
: parent::_(['past_member', 'past_members', count($members)]);
? parent::_(['current_member', 'current_members', 10])
: parent::_(['past_member', 'past_members', 10]);

$this->vars = [
'committee' => $committee,
Expand All @@ -33,19 +33,18 @@ public function render(): string
return $this->twig->render("{$this->outputFormat}/committees/open_members.twig", $this->vars);
}

private function member_data(Committee $committee, array &$objects): array
private function member_data(Committee $committee, array &$member_data): array
{
$committee_id = $committee->getId();
$userCanEditOffices = parent::isAllowed('offices', 'update');
$userCanEditMembers = parent::isAllowed('members', 'update');
$userCanDeleteMembers = parent::isAllowed('members', 'delete');

$members = [];
foreach ($objects as $m) {
foreach ($member_data as $m) {
$links = [];
$member_id = $m->getId();
$person_id = $m->getPerson_id();
$offices = $m->getPerson()->getOffices($m->getCommittee(), date('Y-m-d'));
$member_id = $m['member_id'];
$person_id = $m['member_person_id'];

if ($userCanEditOffices) {
$links[] = [
Expand All @@ -54,7 +53,7 @@ private function member_data(Committee $committee, array &$objects): array
'class' => 'add'
];
}
foreach ($offices as $o) {
foreach ($m['offices'] as $o) {
if ($userCanEditOffices) {
$links[] = [
'url' => parent::generateUri('offices.update')."?office_id={$o->getId()}",
Expand Down Expand Up @@ -82,10 +81,10 @@ private function member_data(Committee $committee, array &$objects): array
$members[] = [
'member_id' => $member_id,
'person_id' => $person_id,
'name' => $m->getPerson()->getFullname(),
'offices' => $offices,
'startDate' => $m->getStartDate(),
'endDate' => $m->getEndDate(),
'name' => "$m[member_firstname] $m[member_lastname]",
'offices' => $m['offices'],
'startDate' => $m['member_startDate'],
'endDate' => $m['member_endDate'],
'actionLinks' => $links
];
}
Expand Down
2 changes: 0 additions & 2 deletions src/Web/GraylogWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ class GraylogWriter extends AbstractWriter

public function __construct(string $url, int $port)
{
$this->url = $url;

$transport = new UdpTransport($url, $port, UdpTransport::CHUNK_SIZE_LAN);
$this->publisher = new Publisher();
$this->publisher->addTransport($transport);
Expand Down
12 changes: 6 additions & 6 deletions templates/html/committees/open_members.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* @param array members
#}
{% extends "html/layouts/default.twig" %}
{% import "html/macros/forms.twig" as forms %}
{% block content %}

<section>
<header>
<h2>{{ committee.getName() }}
Expand All @@ -25,22 +25,22 @@
</a>
</td>
<td>{{ member.startDate }} - {{ member.endDate }}</td>
<td>{% if row.actionLinks is defined %}
{% for a in row.actionLinks %}<a href="{{ a.url }}">{{ a.label }}</a>{% endfor %}
<td>{% if member.actionLinks is defined %}
{{ include('html/partials/moreLinks.twig', {actionLinks:member.actionLinks}, with_context:false) }}
{% endif %}
</td>
</tr>
{% endfor %}
</table>

{% if isAllowed('members', 'update' ) %}
<a class="btn btn-primary" href="{{ uri('members.update') }}?committee_id={{ committee.getId() }}">{{ _('member_add') }}</a>
{{ forms.actionLink(uri('members.update') ~ '?committee_id=' ~ committee.getId(), _('member_add'), 'add' )}}
{% elseif isAllowed('members', 'appoint') %}
<a class="btn btn-primary" href="{{ uri('members.appoint') }}?committee_id={{ committee.getId() }}">{{ _('member_add') }}</a>
{{ forms.actionLink(uri('members.appoint') ~ '?committee_id=' ~ committee.getId(), _('member_add'), 'add' )}}
{% endif %}

{% if committee.hasVacancy() %}
<a class="btn btn-primary" href="{{ uri('applicants.apply') }}?committee_id={{ committee.getId() }}">{{ _('apply') }}</a>
{{ forms.actionLink(uri('applicants.apply') ~ '?committee_id=' ~ committee.getId(), _('apply'), 'add' )}}
{% endif %}
</section>
{% endblock %}

0 comments on commit 4b83c5b

Please sign in to comment.