Skip to content

Commit 106879a

Browse files
committed
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 ...
2 parents 6b5d63e + 8c3ab20 commit 106879a

File tree

28 files changed

+2362
-1
lines changed

28 files changed

+2362
-1
lines changed

src/core/Entities/Registration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,7 @@ function getSendValidationErrors(string $field_prefix = 'field_', $file_prefix =
12161216
}
12171217

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

12201221
return $errorsResult;
12211222
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,14 @@
273273
</div>
274274
<?php else: ?>
275275
<?php $this->applyTemplateHook("registration-form-view", 'before', [$phase]) ?>
276+
<?php $this->applyTemplateHook('single-registrationview', 'before') ?>
276277
<v1-embed-tool route="registrationview" :id="<?=$phase->id?>"></v1-embed-tool>
277278
<?php $this->applyTemplateHook("registration-form-view", 'after', [$phase]) ?>
279+
<?php $this->applyTemplateHook('single-registrationview', 'after') ?>
278280
<?php endif ?>
279281
<?php endif ?>
280282
<?php $phase = $phase->nextPhase; ?>
281283
<?php endwhile ?>
282-
283284
</div>
284285
</mc-tab>
285286

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?php
2+
3+
namespace OpportunityWorkplan\Controllers;
4+
5+
use MapasCulturais\App;
6+
use MapasCulturais\Entities\Registration;
7+
use OpportunityWorkplan\Entities\Delivery;
8+
use OpportunityWorkplan\Entities\Workplan as EntitiesWorkplan;
9+
use OpportunityWorkplan\Entities\Goal;
10+
use OpportunityWorkplan\Services\WorkplanService;
11+
12+
class Workplan extends \MapasCulturais\Controller
13+
{
14+
public function GET_index()
15+
{
16+
$this->requireAuthentication();
17+
18+
$app = App::i();
19+
20+
if (!$this->data['id']) {
21+
$app->pass();
22+
}
23+
24+
$registration = $app->repo(Registration::class)->find($this->data['id']);
25+
$workplan = $app->repo(EntitiesWorkplan::class)->findOneBy(['registration' => $registration->id]);
26+
27+
$data = [
28+
'workplan' => null
29+
];
30+
31+
if ($workplan) {
32+
$data = [
33+
'workplan' => $workplan->jsonSerialize(),
34+
];
35+
}
36+
37+
38+
$this->json($data);
39+
}
40+
41+
public function POST_save()
42+
{
43+
$this->requireAuthentication();
44+
45+
$app = App::i();
46+
47+
$app->disableAccessControl();
48+
49+
if (!$this->data['registrationId']) {
50+
$app->pass();
51+
}
52+
53+
$registration = $app->repo(Registration::class)->find($this->data['registrationId']);
54+
$workplan = $app->repo(EntitiesWorkplan::class)->findOneBy(['registration' => $registration->id]);
55+
$app->em->beginTransaction();
56+
try {
57+
$workplanService = new WorkplanService();
58+
$workplan = $workplanService->save($registration, $workplan, $this->data);
59+
$app->em->commit();
60+
} catch(\Exception $e) {
61+
$app->em->rollback();
62+
$this->json(['error' => $e->getMessage()], 400);
63+
}
64+
65+
$app->enableAccessControl();
66+
67+
$this->json([
68+
'workplan' => $workplan->jsonSerialize(),
69+
]);
70+
}
71+
72+
73+
public function DELETE_goal()
74+
{
75+
$this->requireAuthentication();
76+
77+
$app = App::i();
78+
79+
if (!$this->data['id']) {
80+
$app->pass();
81+
}
82+
83+
$goal = $app->repo(Goal::class)->find($this->data['id']);
84+
85+
if ($goal) {
86+
$app->em->remove($goal);
87+
$app->em->flush();
88+
89+
$this->json(true);
90+
}
91+
}
92+
93+
public function DELETE_delivery()
94+
{
95+
$this->requireAuthentication();
96+
97+
$app = App::i();
98+
99+
if (!$this->data['id']) {
100+
$app->pass();
101+
}
102+
103+
$delivery = $app->repo(Delivery::class)->find($this->data['id']);
104+
105+
if ($delivery) {
106+
$app->em->remove($delivery);
107+
$app->em->flush();
108+
109+
$this->json(true);
110+
}
111+
}
112+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
namespace OpportunityWorkplan\Entities;
3+
4+
use Doctrine\ORM\Mapping as ORM;
5+
6+
use MapasCulturais\Traits\EntityMetadata;
7+
use MapasCulturais\Traits\EntityOwnerAgent;
8+
9+
/**
10+
*
11+
* @ORM\Table(name="registration_workplan_goal_delivery")
12+
* @ORM\Entity
13+
* @ORM\entity(repositoryClass="MapasCulturais\Repository")
14+
*/
15+
class Delivery extends \MapasCulturais\Entity {
16+
17+
use EntityMetadata,
18+
EntityOwnerAgent;
19+
20+
/**
21+
*
22+
* @ORM\Id
23+
* @ORM\Column(type="integer")
24+
* @ORM\GeneratedValue(strategy="IDENTITY")
25+
*/
26+
protected $id;
27+
28+
/**
29+
* @var \MapasCulturais\Entities\Agent
30+
*
31+
* @ORM\ManyToOne(targetEntity="MapasCulturais\Entities\Agent", fetch="LAZY")
32+
* @ORM\JoinColumns({
33+
* @ORM\JoinColumn(name="agent_id", referencedColumnName="id", onDelete="CASCADE")
34+
* })
35+
*/
36+
protected $owner;
37+
38+
/**
39+
*
40+
* @ORM\ManyToOne(targetEntity=\OpportunityWorkplan\Entities\Goal::class, inversedBy="deliveries"))
41+
* @ORM\JoinColumns({
42+
* @ORM\JoinColumn(name="goal_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
43+
* })
44+
*/
45+
protected $goal;
46+
47+
/**
48+
* @ORM\OneToMany(targetEntity=\OpportunityWorkplan\Entities\DeliveryMeta::class, mappedBy="owner", cascade={"remove","persist"}, orphanRemoval=true)
49+
*/
50+
protected $__metadata;
51+
52+
/**
53+
* @var \DateTime
54+
*
55+
* @ORM\Column(name="create_timestamp", type="datetime", nullable=false)
56+
*/
57+
protected $createTimestamp;
58+
59+
/**
60+
* @var \DateTime
61+
*
62+
* @ORM\Column(name="update_timestamp", type="datetime", nullable=true)
63+
*/
64+
protected $updateTimestamp;
65+
66+
public function jsonSerialize(): array
67+
{
68+
$metadatas = $this->getMetadata();
69+
70+
return [
71+
'id' => $this->id,
72+
...$metadatas
73+
];
74+
}
75+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
3+
namespace OpportunityWorkplan\Entities;
4+
5+
use Doctrine\ORM\Mapping as ORM;
6+
7+
use MapasCulturais\App;
8+
9+
/**
10+
* Delivery
11+
*
12+
* @ORM\Table(name="registration_workplan_goal_delivery_meta")
13+
* @ORM\Entity
14+
* @ORM\entity(repositoryClass="MapasCulturais\Repository")
15+
*/
16+
class DeliveryMeta extends \MapasCulturais\Entity {
17+
/**
18+
* @ORM\Id
19+
* @ORM\Column(type="integer")
20+
* @ORM\GeneratedValue(strategy="IDENTITY")
21+
*/
22+
public $id;
23+
24+
/**
25+
* @var string
26+
*
27+
* @ORM\Column(name="key", type="string", nullable=false)
28+
*/
29+
public $key;
30+
31+
/**
32+
* @var string
33+
*
34+
* @ORM\Column(name="value", type="text", nullable=true)
35+
*/
36+
protected $value;
37+
38+
/**
39+
* @var \OpportunityWorkplan\Entities\Delivery
40+
*
41+
* @ORM\ManyToOne(targetEntity=\OpportunityWorkplan\Entities\Delivery::class)
42+
* @ORM\JoinColumns({
43+
* @ORM\JoinColumn(name="object_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
44+
* })
45+
*/
46+
protected $owner;
47+
48+
49+
/** @ORM\PrePersist */
50+
public function _prePersist($args = null){
51+
App::i()->applyHookBoundTo($this, 'entity(Delivery).meta(' . $this->key . ').insert:before');
52+
}
53+
/** @ORM\PostPersist */
54+
public function _postPersist($args = null){
55+
App::i()->applyHookBoundTo($this, 'entity(Delivery).meta(' . $this->key . ').insert:after');
56+
}
57+
58+
/** @ORM\PreRemove */
59+
public function _preRemove($args = null){
60+
App::i()->applyHookBoundTo($this, 'entity(Delivery).meta(' . $this->key . ').remove:before');
61+
}
62+
/** @ORM\PostRemove */
63+
public function _postRemove($args = null){
64+
App::i()->applyHookBoundTo($this, 'entity(Delivery).meta(' . $this->key . ').remove:after');
65+
}
66+
67+
/** @ORM\PreUpdate */
68+
public function _preUpdate($args = null){
69+
App::i()->applyHookBoundTo($this, 'entity(Delivery).meta(' . $this->key . ').update:before');
70+
}
71+
/** @ORM\PostUpdate */
72+
public function _postUpdate($args = null){
73+
App::i()->applyHookBoundTo($this, 'entity(Delivery).meta(' . $this->key . ').update:after');
74+
}
75+
76+
//============================================================= //
77+
// The following lines ara used by MapasCulturais hook system.
78+
// Please do not change them.
79+
// ============================================================ //
80+
81+
/** @ORM\PrePersist */
82+
public function prePersist($args = null){ parent::prePersist($args); }
83+
/** @ORM\PostPersist */
84+
public function postPersist($args = null){ parent::postPersist($args); }
85+
86+
/** @ORM\PreRemove */
87+
public function preRemove($args = null){ parent::preRemove($args); }
88+
/** @ORM\PostRemove */
89+
public function postRemove($args = null){ parent::postRemove($args); }
90+
91+
/** @ORM\PreUpdate */
92+
public function preUpdate($args = null){ parent::preUpdate($args); }
93+
/** @ORM\PostUpdate */
94+
public function postUpdate($args = null){ parent::postUpdate($args); }
95+
}

0 commit comments

Comments
 (0)