Skip to content

Commit 98ead34

Browse files
vicmagpaclpirola
authored andcommitted
feat: geração de selo para modelo oficial
1 parent 8b8baf5 commit 98ead34

File tree

4 files changed

+69
-4
lines changed

4 files changed

+69
-4
lines changed

src/core/Traits/EntityManagerModel.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function ALL_generatemodel(){
2020
$this->generatePhases();
2121
$this->generateMetadata();
2222
$this->generateRegistrationFieldsAndFiles();
23+
$this->generateSealsRelations();
2324

2425
$this->entityOpportunityModel->save(true);
2526

@@ -69,6 +70,13 @@ function GET_findOpportunitiesModels()
6970
$phases = $opp->phases;
7071

7172
$lastPhase = array_pop($phases);
73+
74+
$modelIsOfficial = false;
75+
foreach ($opp->getSealRelations() as $sealRelation) {
76+
if ( in_array($sealRelation->seal->id, $app->config['app.verifiedSealsIds'])) {
77+
$modelIsOfficial = true;
78+
}
79+
}
7280

7381
$days = !is_null($opp->registrationFrom) && !is_null($lastPhase->publishTimestamp) ? $lastPhase->publishTimestamp->diff($opp->registrationFrom)->days . " Dia(s)" : 'N/A';
7482
$tipoAgente = $opp->registrationProponentTypes ? implode(', ', $opp->registrationProponentTypes) : 'N/A';
@@ -77,7 +85,8 @@ function GET_findOpportunitiesModels()
7785
'numeroFases' => count($opp->phases),
7886
'descricao' => $opp->shortDescription,
7987
'tempoEstimado' => $days,
80-
'tipoAgente' => $tipoAgente
88+
'tipoAgente' => $tipoAgente,
89+
'modelIsOfficial' => $modelIsOfficial
8190
];
8291
}
8392
}
@@ -286,6 +295,12 @@ private function generateRegistrationFieldsAndFiles() : void
286295
$fileConfiguration->setOwnerId($this->entityOpportunityModel->id);
287296
$fileConfiguration->save(true);
288297
}
298+
}
289299

300+
private function generateSealsRelations() : void
301+
{
302+
foreach ($this->entityOpportunity->getSealRelations() as $sealRelation) {
303+
$this->entityOpportunityModel->createSealRelation($sealRelation->seal, true, true);
304+
}
290305
}
291306
}

src/modules/Panel/components/panel--entity-models-card/script.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,21 @@ app.component('panel--entity-models-card', {
3030

3131
let isModelPublic = this.entity.isModelPublic == 1 ? true : false;
3232

33+
34+
const MODEL_OFFICIAL = 'MODELO OFICIAL';
35+
const MODEL_PRIVATE = 'MODELO PRIVADO';
36+
const MODEL_PUBLIC = 'MODELO PÚBLICO';
37+
38+
const typeModels = {
39+
MODEL_OFFICIAL,
40+
MODEL_PRIVATE,
41+
MODEL_PUBLIC
42+
};
43+
3344
return {
3445
isModelPublic,
35-
models: []
46+
models: [],
47+
typeModels
3648
}
3749
},
3850

@@ -74,5 +86,19 @@ app.component('panel--entity-models-card', {
7486

7587
return showModel;
7688
},
89+
getTypeModel() {
90+
91+
let model_ = this.models.filter((model) => {
92+
return this.entity.id == model.id;
93+
});
94+
95+
if (model_[0] != 'undefined') {
96+
if (model_[0]?.modelIsOfficial) {
97+
return this.typeModels.MODEL_OFFICIAL;
98+
}
99+
}
100+
101+
return this.entity.isModelPublic == 0 ? this.typeModels.MODEL_PRIVATE : this.typeModels.MODEL_PUBLIC;
102+
},
77103
}
78104
})

src/modules/Panel/components/panel--entity-models-card/template.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@
3838
<div class="right">
3939
<div class="panel-entity-models-card__header-actions">
4040
<slot name="header-actions" :entity="entity">
41-
{{ entity.isModelPublic == 0 ? 'MEU MODELO' : 'MODELO PÚBLICO' }}
41+
<li v-if="getTypeModel == typeModels.MODEL_OFFICIAL" class="tag-official mc-tag-list__tag">
42+
{{ typeModels.MODEL_OFFICIAL }}
43+
</li>
44+
<li v-if="getTypeModel == typeModels.MODEL_PUBLIC" class="tag-public mc-tag-list__tag">
45+
{{ typeModels.MODEL_PUBLIC }}
46+
</li>
47+
<li v-if="getTypeModel == typeModels.MODEL_PRIVATE" class="tag-private mc-tag-list__tag">
48+
{{ typeModels.MODEL_PRIVATE }}
49+
</li>
4250
</slot>
4351
</div>
4452
</div>

src/themes/BaseV2/assets-src/sass/2.components/_entity-models-card.scss

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,21 @@
531531
}
532532
}
533533
}
534+
535+
.tag-official {
536+
background-color: #FFB700;
537+
color: #1E1E1E;
538+
}
539+
540+
.tag-public {
541+
background-color: #FFB700;
542+
color: #1E1E1E;
543+
}
544+
545+
.tag-private {
546+
background-color: #fff;
547+
color: #767676;
548+
}
534549
}
535550

536551
&__main {
@@ -767,4 +782,5 @@ input:checked + .slider:before {
767782
.switch-text {
768783
margin-left: 8px;
769784
font-weight: 600;
770-
}
785+
}
786+

0 commit comments

Comments
 (0)