Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task #324 #439

Merged
merged 7 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Controller\Api\WelcomeApiController;
use Symfony\Component\HttpFoundation\Request;
use App\Controller\Api\OpportunityApiController;

$routes = [
'/api' => [
Expand All @@ -14,6 +15,9 @@
Request::METHOD_POST => [WelcomeApiController::class, 'create'],
Request::METHOD_DELETE => [WelcomeApiController::class, 'delete'],
],
'/api/findOpportunitiesModels' => [
Request::METHOD_GET => [OpportunityApiController::class, 'findOpportunitiesModels'],
]
];

$files = glob(__DIR__.'/api/*.php');
Expand Down
7 changes: 7 additions & 0 deletions app/src/Controller/Api/OpportunityApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,11 @@ public function delete(array $params): JsonResponse
return new JsonResponse(['error' => $exception->getMessage()], Response::HTTP_BAD_REQUEST);
}
}

public function findOpportunitiesModels(): JsonResponse
{
$models = $this->repository->findOpportunitiesModels();

return new JsonResponse($models);
}
}
54 changes: 52 additions & 2 deletions app/src/Repository/OpportunityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public function save(Opportunity $opportunity): void
$this->mapaCulturalEntityManager->persist($opportunity);
$this->mapaCulturalEntityManager->flush();
}

public function findOpportunitiesByAgentId(int $agentId): array
{
$queryBuilder = $this->getEntityManager()
Expand All @@ -50,10 +49,61 @@ public function findOpportunitiesByAgentId(int $agentId): array

return $queryBuilder->getQuery()->getArrayResult();
}

public function softDelete(Opportunity $opportunity): void
{
$opportunity->setStatus(EntityStatusEnum::TRASH->getValue());
$this->save($opportunity);
}

public function findOpportunitiesModels(): array {
$app = \MapasCulturais\App::i();
$em = $app->em;
$queryBuilder = $em->createQueryBuilder()
->select(
'o.id',
'o.name',
'(COUNT(p.id) + 2) AS numeroFases',
'o.registrationTo',
'o.registrationFrom',
'o.shortDescription AS descricao',
'o.registrationProponentTypes AS tipoAgente'
)
->from(Opportunity::class, 'o')
->leftJoin(Opportunity::class, 'p', 'WITH', 'p.parent = o.id')
->where('o.parent IS NULL')
->andWhere('o.status = -1')
->groupBy('o.id, o.name');

$results = $queryBuilder->getQuery()->getArrayResult();

foreach ($results as &$result) {
if (isset($result['registrationTo']) && isset($result['registrationFrom'])) {
$registrationTo = $result['registrationTo'];
$registrationFrom = $result['registrationFrom'];

if (!$registrationTo instanceof \DateTime) {
$registrationTo = new \DateTime($registrationTo);
}
if (!$registrationFrom instanceof \DateTime) {
$registrationFrom = new \DateTime($registrationFrom);
}

$interval = $registrationFrom->diff($registrationTo);
$days = $interval->days;

$result['tempoEstimado'] = "$days dias";
} else {
$result['tempoEstimado'] = 'N/A';
}

if (isset($result['tipoAgente'])){

$result['tipoAgente'] = implode(', ', $result['tipoAgente']);
}else {
$result['tipoAgente'] = 'N/A';
}
}
return $results;
}

}
4 changes: 2 additions & 2 deletions src/modules/EvaluationMethodQualification/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected function _register()
return json_encode($val);
},
'unserialize' => function ($val) {
return json_decode($val);
return $val !== null ? json_decode($val) : null;
}
]);

Expand All @@ -168,7 +168,7 @@ protected function _register()
return json_encode($val);
},
'unserialize' => function ($val) {
return json_decode($val);
return $val !== null ? json_decode($val) : null;
}
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

');
?>
<article class="panel__row panel-entity-card" :class="classes">
<article class="panel__row panel-entity-card" :class="{classes, 'col-6': entity.isModel == 1}">
<header class="panel-entity-card__header">
<div class="left">
<slot name="picture" :entity="entity">
Expand Down
14 changes: 14 additions & 0 deletions src/modules/Panel/components/panel--entity-tabs/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ app.component('panel--entity-tabs', {
},

created() {
fetch('/api/findOpportunitiesModels')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
this.models = data;
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
});
},

data() {
Expand Down Expand Up @@ -43,6 +56,7 @@ app.component('panel--entity-tabs', {
archived: { status: 'EQ(-2)', ...query },
},
showPrivateKey: false,
models: [],

}
},
Expand Down
94 changes: 58 additions & 36 deletions src/modules/Panel/components/panel--entity-tabs/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
$this->applyComponentHook('.sortOptions', [&$tabs]);

?>
<mc-tabs class="entity-tabs" sync-hash>
<mc-tabs class="entity-tabs models" sync-hash>
<?php $this->applyComponentHook('begin') ?>
<template #header="{ tab }">
<?php $this->applyComponentHook('tab', 'begin') ?>
Expand Down Expand Up @@ -76,43 +76,65 @@
</template>

<template #default="{entities}">
<slot name='before-list' :entities="entities" :query="queries['<?=$status?>']"></slot>
<slot v-for="entity in entities" :key="entity.__objectId" :entity="entity" :moveEntity="moveEntity">
<registration-card v-if="entity.__objectType=='registration'" :entity="entity" pictureCard hasBorders class="panel__row">
<template #entity-actions-left>
<slot name="entity-actions-left" :entity="entity"></slot>
</template>
</registration-card>
<panel--entity-card v-if="entity.__objectType!='registration'" :key="entity.id" :entity="entity"
@undeleted="moveEntity(entity, $event)"
@deleted="moveEntity(entity, $event)"
@archived="moveEntity(entity, $event)"
@published="moveEntity(entity, $event)"
:on-delete-remove-from-lists="false"
>
<template #title="{ entity }">
<slot name="card-title" :entity="entity"></slot>
</template>
<template #subtitle="{ entity }">
<slot name="card-content" :entity="entity">
<span v-if="entity.type">
<?=i::__('Tipo: ')?> <strong>{{ entity.type.name }}</strong>
<slot name='before-list' :entities="entities" :query="queries['<?=$status?>']"></slot>
<slot v-for="entity in entities" :key="entity.__objectId" :entity="entity" :moveEntity="moveEntity">
<registration-card v-if="entity.__objectType == 'registration'" :entity="entity" pictureCard hasBorders class="panel__row">
<template #entity-actions-left>
<slot name="entity-actions-left" :entity="entity"></slot>
</template>
</registration-card>
<panel--entity-card v-if="entity.__objectType != 'registration'" :key="entity.id" :entity="entity"
@undeleted="moveEntity(entity, $event)"
@deleted="moveEntity(entity, $event)"
@archived="moveEntity(entity, $event)"
@published="moveEntity(entity, $event)"
:on-delete-remove-from-lists="false"
>
<template #title="{ entity }">
<slot name="card-title" :entity="entity"></slot>
</template>
<template #subtitle="{ entity }">
<slot name="card-content" :entity="entity">
<span v-if="entity.type && entity.isModel != null">
<span class="card-info">MEU MODELO</span>
<div class="card-desc">
<div v-for="model in models" :key="model.id">

<span v-if="model.id == entity.id">
<p>{{ model.descricao }}</p>
<mc-icon name="project" class="icon-model"></mc-icon>
<strong><?=i::__('Tipo de Oportunidade: ')?></strong>{{ entity.type.name }}
<br>
<mc-icon name="circle-checked" class="icon-model"></mc-icon>
<strong><?=i::__('Número de fases: ')?></strong>{{ model.numeroFases }}
<br>
<mc-icon name="date" class="icon-model"></mc-icon>
<strong><?=i::__('Tempo estimado: ')?></strong>{{ model.tempoEstimado }}
<br>
<mc-icon name="agent" class="icon-model"></mc-icon>
<strong><?=i::__('Tipo de agente: ')?></strong> {{ model.tipoAgente }}
</span>
</slot>
</template>
<template #entity-actions-left>
<slot name="entity-actions-left" :entity="entity"></slot>
</template>
<template #entity-actions-center>
<slot name="entity-actions-center" :entity="entity"></slot>
</template>
<template #entity-actions-right>
<slot name="entity-actions-right" :entity="entity"></slot>
</template>
</panel--entity-card>
</div>
</div>
</span>
<span v-if="entity.type && entity.isModel == null">
<?=i::__('Tipo: ')?> <strong>{{ entity.type.name }}</strong>
</span>
</slot>
<slot name='after-list' :entities="entities" :query="queries['<?=$status?>']"></slot>
</template>
</template>
<template #entity-actions-left>
<slot name="entity-actions-left" :entity="entity"></slot>
</template>
<template #entity-actions-center>
<slot name="entity-actions-center" :entity="entity"></slot>
</template>
<template #entity-actions-right>
<slot name="entity-actions-right" :entity="entity"></slot>
</template>
</panel--entity-card>
</slot>
<slot name='after-list' :entities="entities" :query="queries['<?=$status?>']"></slot>
</template>
</mc-entities>
<?php $this->applyComponentHook($status, 'end') ?>
</mc-tab>
Expand Down
30 changes: 29 additions & 1 deletion src/themes/BaseV2/assets-src/sass/2.components/_entity-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,11 @@
font-size: 14px;
line-height: 19px;
}
.models &{
position: absolute;
bottom: 30px;
left: 15px;
}
}

&.right {
Expand Down Expand Up @@ -628,6 +633,11 @@
justify-content: center;
}
}
.models &{
position: absolute;
bottom: 30px;
right: 25px;
}
}

button {
Expand Down Expand Up @@ -664,4 +674,22 @@
}
}
}
}
}

article.panel-entity-card.col-6{
min-width: 450px;
max-width: 450px;
min-height: 530px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
.panel-entity-card__header--info{
margin-top: 85px;
margin-left: -80px;
}
}
.icon-model{
font-size: size(20) !important;
color: #117C83;
margin-right: 8px;
margin-top: 15px;
vertical-align: text-bottom;
}
15 changes: 15 additions & 0 deletions src/themes/BaseV2/assets-src/sass/layouts/_entity-tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,19 @@ $iconUrl: 'https://api.iconify.design/ic/baseline-arrow-drop-down.svg' +#{$iconC
}

}
span.card-info{
position: relative;
top: -125px;
left: 300px;
color: rgb(127, 122, 122);
font-weight: 600;
font-size: 14px;
}

div.card-desc{
text-transform: none;
strong{
margin-top: 5px;
}
}
}
Loading