forked from mapasculturais/mapasculturais
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/plano-de-trabalho-doctrine' into feature/docker…
…-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
Showing
28 changed files
with
2,362 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
src/modules/OpportunityWorkplan/Controllers/Workplan.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); } | ||
} |
Oops, something went wrong.