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 22, 2024
2 parents 6b5d63e + 8c3ab20 commit 106879a
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]);

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') ?>
<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') ?>
<?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()
{
$this->requireAuthentication();

$app = App::i();

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

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

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

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


$this->json($data);
}

public function POST_save()
{
$this->requireAuthentication();

$app = App::i();

$app->disableAccessControl();

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

$registration = $app->repo(Registration::class)->find($this->data['registrationId']);
$workplan = $app->repo(EntitiesWorkplan::class)->findOneBy(['registration' => $registration->id]);
$app->em->beginTransaction();
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);
}

$app->enableAccessControl();

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


public function DELETE_goal()
{
$this->requireAuthentication();

$app = App::i();

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

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

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

$this->json(true);
}
}

public function DELETE_delivery()
{
$this->requireAuthentication();

$app = App::i();

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

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

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

$this->json(true);
}
}
}
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
{
$metadatas = $this->getMetadata();

return [
'id' => $this->id,
...$metadatas
];
}
}
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');
}
/** @ORM\PostPersist */
public function _postPersist($args = null){
App::i()->applyHookBoundTo($this, 'entity(Delivery).meta(' . $this->key . ').insert:after');
}

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

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

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

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

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

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

0 comments on commit 106879a

Please sign in to comment.