Skip to content

Commit

Permalink
coloquei os dados do back no front de acordo com cada card, estilizaç…
Browse files Browse the repository at this point in the history
…ão final
  • Loading branch information
PaG0Dezaum2005 committed Aug 27, 2024
1 parent 3db06fd commit 26c0d25
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 57 deletions.
44 changes: 37 additions & 7 deletions app/src/Repository/OpportunityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,55 @@ public function softDelete(Opportunity $opportunity): void
$this->save($opportunity);
}

public function findOpportunitiesModels(): array
{
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) AS tempoEstimado',
'o.shortDescription AS descricao'
'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');

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

$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
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
102 changes: 56 additions & 46 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,55 +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 && entity.isModel != null">
<span class="card-info">MEU MODELO</span>
<div class="card-desc">
<mc-icon name="project" class="icon-model"></mc-icon> <strong> <?=i::__('Tipo de Oportunidade: ')?> </strong>{{ entity.type.name }}
<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>{{ entity.type.name }}
<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>{{ entity.type.name }}
<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>{{ entity.type.name }}
</div>
</span>
<span v-if="entity.type && entity.isModel == null">
<?=i::__('Tipo: ')?> <strong>{{ entity.type.name }}</strong>
</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>
<mc-icon name="agent" class="icon-model"></mc-icon>
<strong><?=i::__('Tipo de agente: ')?></strong> {{ model.tipoAgente }}
</span>
</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
11 changes: 11 additions & 0 deletions 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 @@ -669,6 +679,7 @@
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;
Expand Down
4 changes: 2 additions & 2 deletions src/themes/BaseV2/assets-src/sass/layouts/_entity-tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ $iconUrl: 'https://api.iconify.design/ic/baseline-arrow-drop-down.svg' +#{$iconC
position: relative;
top: -125px;
left: 300px;
color: rgb(127, 122, 122); // Sets the font color to grey
font-weight: 600; // Slightly bold (500 is typically medium weight)
color: rgb(127, 122, 122);
font-weight: 600;
font-size: 14px;
}

Expand Down

0 comments on commit 26c0d25

Please sign in to comment.