Skip to content

Commit

Permalink
Merge branch 'feature/plano-de-trabalho-doctrine' into feature/docker…
Browse files Browse the repository at this point in the history
…-osi-compatible

* feature/plano-de-trabalho-doctrine: (37 commits)
  feat: atualiza options da etapa do fazer cultural
  feat: implementa toggle collapse para as metas na inscrição
  feat: valida entregas no backend quando habilitada na oportunidade
  feat: adiciona acompanhamento do plano de trabalho nos detalhes da inscrição
  feat: add hook registration view detalhes
  feat: adiciona cascade nas dependências da tabela registration
  feat: melhora mensagens de validação
  feat: carrega options dos campos selects vindo dos matadados
  feat: add form abaixo do de inscrição e remove validação de entrega quando não configurada
  feat: add validação do plano de trabalho e metas quando enviado a registration
  feat: ajusta nome do hook vazio entity registration na validação
  feat: add fluxo gerenciamento de plano de trabalho na inscrição
  feat: add validação plano de trabalho, metas e entregas
  feat: aplica regras de configuração do plano na configuração da oportunidade para a inscrição
  feat: aplica regra etapa fazer cultural, valor da meta e limitar numero de metas
  feat: configura limitação máxima do projeto para a meta
  feat: limpa classes não usadas e renomeia entidades
  feat: deixa permanente diretório assets do module
  feat: cria metadados das novas entidades
  feat: adiciona fluxo nos controladores
  ...
  • Loading branch information
lpirola committed Nov 25, 2024
2 parents da83213 + 8c3ab20 commit cc5726a
Show file tree
Hide file tree
Showing 28 changed files with 2,362 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/core/Entities/Registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,7 @@ function getSendValidationErrors(string $field_prefix = 'field_', $file_prefix =
}

$app->applyHookBoundTo($this, "{$this->hookPrefix}.sendValidationErrors", [&$errorsResult]);
$app->applyHookBoundTo($this, "entity({$this->getHookClassPath()}).sendValidationErrors", [&$errorsResult]);

Check warning on line 1219 in src/core/Entities/Registration.php

View check run for this annotation

Codecov / codecov/patch

src/core/Entities/Registration.php#L1219

Added line #L1219 was not covered by tests

return $errorsResult;
}
Expand Down
3 changes: 2 additions & 1 deletion src/modules/Opportunities/views/registration/single.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,14 @@
</div>
<?php else: ?>
<?php $this->applyTemplateHook("registration-form-view", 'before', [$phase]) ?>
<?php $this->applyTemplateHook('single-registrationview', 'before') ?>

Check warning on line 276 in src/modules/Opportunities/views/registration/single.php

View check run for this annotation

Codecov / codecov/patch

src/modules/Opportunities/views/registration/single.php#L276

Added line #L276 was not covered by tests
<v1-embed-tool route="registrationview" :id="<?=$phase->id?>"></v1-embed-tool>
<?php $this->applyTemplateHook("registration-form-view", 'after', [$phase]) ?>
<?php $this->applyTemplateHook('single-registrationview', 'after') ?>

Check warning on line 279 in src/modules/Opportunities/views/registration/single.php

View check run for this annotation

Codecov / codecov/patch

src/modules/Opportunities/views/registration/single.php#L279

Added line #L279 was not covered by tests
<?php endif ?>
<?php endif ?>
<?php $phase = $phase->nextPhase; ?>
<?php endwhile ?>

</div>
</mc-tab>

Expand Down
112 changes: 112 additions & 0 deletions src/modules/OpportunityWorkplan/Controllers/Workplan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php

namespace OpportunityWorkplan\Controllers;

use MapasCulturais\App;
use MapasCulturais\Entities\Registration;
use OpportunityWorkplan\Entities\Delivery;
use OpportunityWorkplan\Entities\Workplan as EntitiesWorkplan;
use OpportunityWorkplan\Entities\Goal;
use OpportunityWorkplan\Services\WorkplanService;

class Workplan extends \MapasCulturais\Controller
{
public function GET_index()

Check warning on line 14 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L14

Added line #L14 was not covered by tests
{
$this->requireAuthentication();

Check warning on line 16 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L16

Added line #L16 was not covered by tests

$app = App::i();

Check warning on line 18 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L18

Added line #L18 was not covered by tests

if (!$this->data['id']) {
$app->pass();

Check warning on line 21 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L20-L21

Added lines #L20 - L21 were not covered by tests
}

$registration = $app->repo(Registration::class)->find($this->data['id']);
$workplan = $app->repo(EntitiesWorkplan::class)->findOneBy(['registration' => $registration->id]);

Check warning on line 25 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L24-L25

Added lines #L24 - L25 were not covered by tests

$data = [
'workplan' => null
];

Check warning on line 29 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L27-L29

Added lines #L27 - L29 were not covered by tests

if ($workplan) {
$data = [
'workplan' => $workplan->jsonSerialize(),
];

Check warning on line 34 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L31-L34

Added lines #L31 - L34 were not covered by tests
}


$this->json($data);

Check warning on line 38 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L38

Added line #L38 was not covered by tests
}

public function POST_save()

Check warning on line 41 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L41

Added line #L41 was not covered by tests
{
$this->requireAuthentication();

Check warning on line 43 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L43

Added line #L43 was not covered by tests

$app = App::i();

Check warning on line 45 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L45

Added line #L45 was not covered by tests

$app->disableAccessControl();

Check warning on line 47 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L47

Added line #L47 was not covered by tests

if (!$this->data['registrationId']) {
$app->pass();

Check warning on line 50 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L49-L50

Added lines #L49 - L50 were not covered by tests
}

$registration = $app->repo(Registration::class)->find($this->data['registrationId']);
$workplan = $app->repo(EntitiesWorkplan::class)->findOneBy(['registration' => $registration->id]);
$app->em->beginTransaction();

Check warning on line 55 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L53-L55

Added lines #L53 - L55 were not covered by tests
try {
$workplanService = new WorkplanService();
$workplan = $workplanService->save($registration, $workplan, $this->data);
$app->em->commit();
} catch(\Exception $e) {
$app->em->rollback();
$this->json(['error' => $e->getMessage()], 400);

Check warning on line 62 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L57-L62

Added lines #L57 - L62 were not covered by tests
}

$app->enableAccessControl();

Check warning on line 65 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L65

Added line #L65 was not covered by tests

$this->json([
'workplan' => $workplan->jsonSerialize(),
]);

Check warning on line 69 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L67-L69

Added lines #L67 - L69 were not covered by tests
}


public function DELETE_goal()

Check warning on line 73 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L73

Added line #L73 was not covered by tests
{
$this->requireAuthentication();

Check warning on line 75 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L75

Added line #L75 was not covered by tests

$app = App::i();

Check warning on line 77 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L77

Added line #L77 was not covered by tests

if (!$this->data['id']) {
$app->pass();

Check warning on line 80 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L79-L80

Added lines #L79 - L80 were not covered by tests
}

$goal = $app->repo(Goal::class)->find($this->data['id']);

Check warning on line 83 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L83

Added line #L83 was not covered by tests

if ($goal) {
$app->em->remove($goal);
$app->em->flush();

Check warning on line 87 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L85-L87

Added lines #L85 - L87 were not covered by tests

$this->json(true);

Check warning on line 89 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L89

Added line #L89 was not covered by tests
}
}

public function DELETE_delivery()

Check warning on line 93 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L93

Added line #L93 was not covered by tests
{
$this->requireAuthentication();

Check warning on line 95 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L95

Added line #L95 was not covered by tests

$app = App::i();

Check warning on line 97 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L97

Added line #L97 was not covered by tests

if (!$this->data['id']) {
$app->pass();

Check warning on line 100 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L99-L100

Added lines #L99 - L100 were not covered by tests
}

$delivery = $app->repo(Delivery::class)->find($this->data['id']);

Check warning on line 103 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L103

Added line #L103 was not covered by tests

if ($delivery) {
$app->em->remove($delivery);
$app->em->flush();

Check warning on line 107 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L105-L107

Added lines #L105 - L107 were not covered by tests

$this->json(true);

Check warning on line 109 in src/modules/OpportunityWorkplan/Controllers/Workplan.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Controllers/Workplan.php#L109

Added line #L109 was not covered by tests
}
}
}
75 changes: 75 additions & 0 deletions src/modules/OpportunityWorkplan/Entities/Delivery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
namespace OpportunityWorkplan\Entities;

use Doctrine\ORM\Mapping as ORM;

use MapasCulturais\Traits\EntityMetadata;
use MapasCulturais\Traits\EntityOwnerAgent;

/**
*
* @ORM\Table(name="registration_workplan_goal_delivery")
* @ORM\Entity
* @ORM\entity(repositoryClass="MapasCulturais\Repository")
*/
class Delivery extends \MapasCulturais\Entity {

use EntityMetadata,
EntityOwnerAgent;

/**
*
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;

/**
* @var \MapasCulturais\Entities\Agent
*
* @ORM\ManyToOne(targetEntity="MapasCulturais\Entities\Agent", fetch="LAZY")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="agent_id", referencedColumnName="id", onDelete="CASCADE")
* })
*/
protected $owner;

/**
*
* @ORM\ManyToOne(targetEntity=\OpportunityWorkplan\Entities\Goal::class, inversedBy="deliveries"))
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="goal_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
* })
*/
protected $goal;

/**
* @ORM\OneToMany(targetEntity=\OpportunityWorkplan\Entities\DeliveryMeta::class, mappedBy="owner", cascade={"remove","persist"}, orphanRemoval=true)
*/
protected $__metadata;

/**
* @var \DateTime
*
* @ORM\Column(name="create_timestamp", type="datetime", nullable=false)
*/
protected $createTimestamp;

/**
* @var \DateTime
*
* @ORM\Column(name="update_timestamp", type="datetime", nullable=true)
*/
protected $updateTimestamp;

public function jsonSerialize(): array

Check warning on line 66 in src/modules/OpportunityWorkplan/Entities/Delivery.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Entities/Delivery.php#L66

Added line #L66 was not covered by tests
{
$metadatas = $this->getMetadata();

Check warning on line 68 in src/modules/OpportunityWorkplan/Entities/Delivery.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Entities/Delivery.php#L68

Added line #L68 was not covered by tests

return [
'id' => $this->id,
...$metadatas
];

Check warning on line 73 in src/modules/OpportunityWorkplan/Entities/Delivery.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Entities/Delivery.php#L70-L73

Added lines #L70 - L73 were not covered by tests
}
}
95 changes: 95 additions & 0 deletions src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php

namespace OpportunityWorkplan\Entities;

use Doctrine\ORM\Mapping as ORM;

use MapasCulturais\App;

/**
* Delivery
*
* @ORM\Table(name="registration_workplan_goal_delivery_meta")
* @ORM\Entity
* @ORM\entity(repositoryClass="MapasCulturais\Repository")
*/
class DeliveryMeta extends \MapasCulturais\Entity {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
public $id;

/**
* @var string
*
* @ORM\Column(name="key", type="string", nullable=false)
*/
public $key;

/**
* @var string
*
* @ORM\Column(name="value", type="text", nullable=true)
*/
protected $value;

/**
* @var \OpportunityWorkplan\Entities\Delivery
*
* @ORM\ManyToOne(targetEntity=\OpportunityWorkplan\Entities\Delivery::class)
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="object_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
* })
*/
protected $owner;


/** @ORM\PrePersist */
public function _prePersist($args = null){
App::i()->applyHookBoundTo($this, 'entity(Delivery).meta(' . $this->key . ').insert:before');

Check warning on line 51 in src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php#L50-L51

Added lines #L50 - L51 were not covered by tests
}
/** @ORM\PostPersist */
public function _postPersist($args = null){
App::i()->applyHookBoundTo($this, 'entity(Delivery).meta(' . $this->key . ').insert:after');

Check warning on line 55 in src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php#L54-L55

Added lines #L54 - L55 were not covered by tests
}

/** @ORM\PreRemove */
public function _preRemove($args = null){
App::i()->applyHookBoundTo($this, 'entity(Delivery).meta(' . $this->key . ').remove:before');

Check warning on line 60 in src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php#L59-L60

Added lines #L59 - L60 were not covered by tests
}
/** @ORM\PostRemove */
public function _postRemove($args = null){
App::i()->applyHookBoundTo($this, 'entity(Delivery).meta(' . $this->key . ').remove:after');

Check warning on line 64 in src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php#L63-L64

Added lines #L63 - L64 were not covered by tests
}

/** @ORM\PreUpdate */
public function _preUpdate($args = null){
App::i()->applyHookBoundTo($this, 'entity(Delivery).meta(' . $this->key . ').update:before');

Check warning on line 69 in src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php#L68-L69

Added lines #L68 - L69 were not covered by tests
}
/** @ORM\PostUpdate */
public function _postUpdate($args = null){
App::i()->applyHookBoundTo($this, 'entity(Delivery).meta(' . $this->key . ').update:after');

Check warning on line 73 in src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php#L72-L73

Added lines #L72 - L73 were not covered by tests
}

//============================================================= //
// The following lines ara used by MapasCulturais hook system.
// Please do not change them.
// ============================================================ //

/** @ORM\PrePersist */
public function prePersist($args = null){ parent::prePersist($args); }

Check warning on line 82 in src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php#L82

Added line #L82 was not covered by tests
/** @ORM\PostPersist */
public function postPersist($args = null){ parent::postPersist($args); }

Check warning on line 84 in src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php#L84

Added line #L84 was not covered by tests

/** @ORM\PreRemove */
public function preRemove($args = null){ parent::preRemove($args); }

Check warning on line 87 in src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php#L87

Added line #L87 was not covered by tests
/** @ORM\PostRemove */
public function postRemove($args = null){ parent::postRemove($args); }

Check warning on line 89 in src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php#L89

Added line #L89 was not covered by tests

/** @ORM\PreUpdate */
public function preUpdate($args = null){ parent::preUpdate($args); }

Check warning on line 92 in src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php#L92

Added line #L92 was not covered by tests
/** @ORM\PostUpdate */
public function postUpdate($args = null){ parent::postUpdate($args); }

Check warning on line 94 in src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php

View check run for this annotation

Codecov / codecov/patch

src/modules/OpportunityWorkplan/Entities/DeliveryMeta.php#L94

Added line #L94 was not covered by tests
}
Loading

0 comments on commit cc5726a

Please sign in to comment.