Skip to content

Commit

Permalink
Fix decision
Browse files Browse the repository at this point in the history
  • Loading branch information
Aarhunt committed Jun 9, 2024
1 parent 9775753 commit dd69e0b
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 107 deletions.
15 changes: 15 additions & 0 deletions .idea/codeception.xml

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

11 changes: 9 additions & 2 deletions .idea/gewisdb.iml

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

8 changes: 4 additions & 4 deletions module/Database/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,28 +171,28 @@
'info' => [
'type' => Segment::class,
'options' => [
'route' => '/info/:type/:number/:point/:decision/:sequence',
'route' => '/info/:type/:number/:point/:decision/:subdecision',
'defaults' => ['action' => 'info'],
'constraints' => [
'type' => 'ALV|BV|VV|Virt',
'number' => '[0-9]*',
'point' => '[0-9]*',
'decision' => '[0-9]*',
'sequence' => '[0-9]*',
'subdecision' => '[0-9]*',
],
],
],
'view' => [
'type' => Segment::class,
'options' => [
'route' => '/:type/:number/:point/:decision/:sequence',
'route' => '/:type/:number/:point/:decision/:subdecision',
'defaults' => ['action' => 'view'],
'constraints' => [
'type' => 'ALV|BV|VV|Virt',
'number' => '[0-9]*',
'point' => '[0-9]*',
'decision' => '[0-9]*',
'sequence' => '[0-9]*',
'subdecision' => '[0-9]*',
],
],
],
Expand Down
58 changes: 0 additions & 58 deletions module/Database/src/Form/Fieldset/Minutes.php

This file was deleted.

1 change: 1 addition & 0 deletions module/Database/src/Form/Minutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function __construct(
],
]);

$minutes->setName('fmeeting');
$this->add($minutes);
}

Expand Down
2 changes: 1 addition & 1 deletion module/Database/src/Hydrator/Minutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function hydrate(

$subdecision = new MinutesModel();

$subdecision->setMeeting($data['meeting']);
$subdecision->setTarget($data['fmeeting']);

$subdecision->setMember($data['author']);
$subdecision->setApproval(boolval($data['approve']));

Check failure on line 31 in module/Database/src/Hydrator/Minutes.php

View workflow job for this annotation

GitHub Actions / php-codesniffer / PHP_CodeSniffer (8.3)

Function boolval() should not be referenced via a fallback global name, but via a use statement.
Expand Down
75 changes: 37 additions & 38 deletions module/Database/src/Model/SubDecision/Minutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class Minutes extends SubDecision
{
/**
* Reference to the meetings
* Reference to the meeting.
*/
#[OneToOne(
targetEntity: Meeting::class,
Expand Down Expand Up @@ -50,15 +50,15 @@ class Minutes extends SubDecision
/**
* Get the target.
*/
public function getMeeting(): Meeting
public function getTarget(): Meeting
{
return $this->meeting;
}

/**
* Set the target.
*/
public function setMeeting(Meeting $meeting): void
public function setTarget(Meeting $meeting): void
{
$this->meeting = $meeting;
}
Expand Down Expand Up @@ -95,49 +95,48 @@ public function setChanges(bool $changes): void
$this->changes = $changes;
}

#[\Override] protected function getTemplate(): string

Check failure on line 98 in module/Database/src/Model/SubDecision/Minutes.php

View workflow job for this annotation

GitHub Actions / php-codesniffer / PHP_CodeSniffer (8.3)

Class \Override should not be referenced via a fully qualified name, but via a use statement.

Check failure on line 98 in module/Database/src/Model/SubDecision/Minutes.php

View workflow job for this annotation

GitHub Actions / php-codesniffer / PHP_CodeSniffer (8.3)

Expected 0 blank lines between attribute and its target, both are on same line.
{
return 'De notulen van de %NUMBER%e %TYPE%%AUTHOR% worden%APPROVAL%%THANK%%CHANGES%.';
}

#[\Override] protected function getAlternativeTemplate(): string

Check failure on line 103 in module/Database/src/Model/SubDecision/Minutes.php

View workflow job for this annotation

GitHub Actions / php-codesniffer / PHP_CodeSniffer (8.3)

Class \Override should not be referenced via a fully qualified name, but via a use statement.
{
return 'The minutes of the %NUMBER%th %TYPE%%AUTHOR% are%APPROVAL%%THANK%%CHANGES%.';
}

/**
* Get the content.
*
* @
*/
public function getContent(): string
{
$target = $this->getMeeting();
$template = $this->getTemplate();
$template = str_replace('%TYPE%', $this->getMeetingType()->value, $template);
$template = str_replace('%NUMBER%', strval($this->getMeetingNumber()), $template);

if (MeetingTypes::ALV === $target->getType()) {
if (null !== $this->getMember()) {
$template = str_replace('%AUTHOR%', ' door ' . $this->getMember()->getFullName(), $template);
$template = str_replace('%THANK%', '', $template);
}
} else {
$template = str_replace('%AUTHOR%', '', $template);
}

if ($this->getApproval()) {
$template = str_replace('%APPROVAL%', ' goedgekeurd', $template);
if ($this->getChanges()) {
$template = str_replace('%CHANGES%', ' met genoemde wijzigingen en', $template);
} else {
$template = str_replace('%CHANGES%', '', $template);
}
$template = str_replace('%THANK%', ' met dank aan de notulist', $template);
} else {
$template = str_replace('%APPROVAL%', ' afgekeurd', $template);
$template = str_replace('%CHANGES%', '', $template);
$template = str_replace('%THANK%', '', $template);
}

return $template;
}

/**
* Decision template
*/
protected function getTemplate(): string
$replacements = [
'%TYPE%' => $this->getTarget()->getType()->value,
'%NUMBER%' => strval($this->getTarget()->getNumber()),
'%APPROVAL%' => $this->getApproval() ? ' goedgekeurd' : ' afgekeurd',
'%AUTHOR%' => MeetingTypes::BV === $this->getTarget()->getType() ? ''
: ' door ' . $this->getMember()->getFullName(),
'%CHANGES%' => $this->getApproval() && $this->getChanges() ? ' met genoemde wijzigingen' : '',
'%THANK%' => MeetingTypes::BV === $this->getTarget()->getType() ? ' met dank aan de notulist' : '',
];

return $this->replaceContentPlaceholders($this->getTemplate(), $replacements);
}
#[\Override] public function getAlternativeContent(): string
{
return 'De notulen van de %NUMBER%e %TYPE%%AUTHOR% worden %APPROVAL%%CHANGES%%THANK%.';
$replacements = [
'%TYPE%' => $this->getTarget()->getType()->value,
'%NUMBER%' => strval($this->getTarget()->getNumber()),
'%APPROVAL%' => $this->getApproval() ? ' approved' : ' disapproved',
'%AUTHOR%' => MeetingTypes::BV === $this->getTarget()->getType() ? ''
: ' by ' . $this->getMember()->getFullName(),
'%CHANGES%' => $this->getApproval() && $this->getChanges() ? ' with mentioned changes' : '',
'%THANK%' => MeetingTypes::BV === $this->getTarget()->getType() ? ' thanks to the minute taker' : '',
];

return $this->replaceContentPlaceholders($this->getAlternativeTemplate(), $replacements);
}
}
16 changes: 13 additions & 3 deletions module/Database/view/database/meeting/minutesform.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use Laminas\View\Renderer\PhpRenderer;
var ret = [];
$.each(data.json, function (idx, meeting) {
var result = meeting.meeting_type + ' ' + meeting.meeting_number;

ret.push({
label: result,
value: result,
Expand All @@ -32,6 +33,9 @@ use Laminas\View\Renderer\PhpRenderer;
});
},
select: function(event, ui) {
let meeting = ui.item.id;
$('#minutes-meeting-type').val(meeting.meeting_type);
$('#minutes-meeting-number').val(meeting.meeting_number);
}
});
});
Expand Down Expand Up @@ -105,9 +109,15 @@ $element->setAttribute('placeholder', $this->translate('Meeting'));
<?= $this->formElementErrors($element) ?>
</div>

<p class="minutes-meeting-display" style="display: none;">
<strong><?= $this->translate('Minutes') ?></strong> <strong class="minutes-meeting-num"></strong>: <span class="minutes-meeting-content"></span>
</p>
<?php
$fs = $form->get('fmeeting');
$minutesMeetingType = $fs->get('type');
$minutesMeetingType->setAttribute('id', 'minutes-meeting-type');
$minutesMeetingNum = $fs->get('number');
$minutesMeetingNum->setAttribute('id', 'minutes-meeting-number');
?>
<?= $this->formHidden($minutesMeetingType) ?>
<?= $this->formHidden($minutesMeetingNum) ?>

<?php
$fs = $form->get('author');
Expand Down
2 changes: 1 addition & 1 deletion module/Report/src/Service/Meeting.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public function generateSubDecision(
$reportSubDecision->setOrganType($subdecision->getOrganType());
}
} elseif ($subdecision instanceof DatabaseSubDecisionModel\Minutes) {
$ref = $subdecision->getMeeting();
$ref = $subdecision->getTarget();
$meeting = $meetingRepo->find([
'type' => $ref->getType(),
'number' => $ref->getNumber(),
Expand Down

0 comments on commit dd69e0b

Please sign in to comment.