Skip to content

Commit 904f923

Browse files
committed
Merge branch 'feature/opportunity-AccountabilityAndMonitoring' into dev/v7.7-alpha
2 parents afccb81 + 050e916 commit 904f923

File tree

13 files changed

+152
-82
lines changed

13 files changed

+152
-82
lines changed

src/core/Entities/Opportunity.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ abstract class Opportunity extends \MapasCulturais\Entity
9191

9292
const STATUS_APPEAL_PHASE = -20;
9393
const STATUS_PHASE = -1;
94+
const CONTINUOUS_FLOW_DATE = "2111-01-01 00:00";
9495

9596
protected $__enableMagicGetterHook = true;
9697
protected $__enableMagicSetterHook = true;

src/modules/EvaluationMethodContinuous/components/evaluation-continuous-detail/init.php

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,41 @@
1010

1111
// SOLUÇÃO TEMPORÁRIA
1212
$class = $entity->getClassName();
13-
1413
if($class == Registration::class) {
15-
16-
$opportunity = $entity->opportunity;
17-
18-
if(!$opportunity->isReportingPhase) {
19-
$opportunity = $entity->opportunity->isAppealPhase ? $entity->opportunity : $entity->opportunity->appealPhase;
20-
}
2114

22-
$evaluation_configuration = $opportunity->evaluationMethodConfiguration;
23-
$registration_appeal_phase = $app->repo('Registration')->findOneBy(['number' => $entity->number, 'opportunity' => $opportunity]);
24-
if(!$evaluation_configuration) {
25-
return;
26-
}
15+
$registration = $this->controller->requestedEntity;
16+
$registration_number = $registration->number;
2717

28-
$registration = $entity;
29-
if (!$entity->opportunity->isAppealPhase) {
30-
$registration_appeal_phase = $app->repo('Registration')->findOneBy(['number' => $entity->number, 'opportunity' => $opportunity]);
31-
$registration = $registration_appeal_phase;
18+
$all_registrations = $app->repo('Registration')->findBy(['number' => $registration_number]);
19+
$registrations = [];
20+
21+
foreach($all_registrations as $reg) {
22+
if ($reg->evaluationMethod && $reg->evaluationMethod->slug == 'continuous') {
23+
$registrations[] = $reg;
24+
25+
}
3226
}
33-
34-
if (!$registration) {
35-
return;
36-
}
37-
38-
$data = [];
39-
$em = $evaluation_configuration->evaluationMethod;
40-
$data['consolidatedDetails'] = $em->getConsolidatedDetails($registration);
41-
$data['evaluationsDetails'] = [];
42-
43-
$evaluations = $registration->sentEvaluations;
27+
28+
$result = [];
29+
foreach($registrations as $reg) {
30+
$em = $reg->evaluationMethod;
31+
$data = [
32+
'consolidatedDetails' => $em->getConsolidatedDetails($reg),
33+
'evaluationsDetails' => []
34+
];
35+
36+
$evaluations = $reg->sentEvaluations;
4437

45-
foreach ($evaluations as $eval) {
46-
$detail = $em->getEvaluationDetails($eval);
47-
$detail['valuer'] = $eval->user->profile->simplify('id,name,singleUrl');
48-
$data['evaluationsDetails'][] = $detail;
38+
foreach ($evaluations as $eval) {
39+
$detail = $em->getEvaluationDetails($eval);
40+
$detail['valuer'] = $eval->user->profile->simplify('id,name,singleUrl');
41+
$data['evaluationsDetails'][] = $detail;
42+
}
43+
44+
$result[$reg->id] = $data;
45+
4946
}
50-
$this->jsObject['config']['continuousEvaluationDetail'] = [
51-
'data' => $data,
52-
];
47+
48+
49+
$this->jsObject['config']['continuousEvaluationDetail'] = (object) $result;
5350
}

src/modules/EvaluationMethodContinuous/components/evaluation-continuous-detail/script.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ app.component('evaluation-continuous-detail', {
1515
},
1616

1717
computed: {
18+
evaluationData() {
19+
return $MAPAS.config.continuousEvaluationDetail[this.registration.id];
20+
},
21+
1822
evaluationDetails() {
19-
return this.registration.evaluationsDetails ? this.registration.evaluationsDetails : $MAPAS.config.continuousEvaluationDetail.data?.evaluationsDetails;
23+
return this.registration.evaluationsDetails ? this.registration.evaluationsDetails : this.evaluationData?.evaluationsDetails;
2024
}
2125
},
2226

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
<?php
2-
$this->useOpportunityAPI();
2+
$this->useOpportunityAPI();
3+
$entity = $this->controller->requestedEntity;
4+
5+
$this->jsObject['config']['opportunityBasicInfo'] = [
6+
'date' => $entity::CONTINUOUS_FLOW_DATE,
7+
];
Lines changed: 64 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
app.component('opportunity-basic-info' , {
22
template: $TEMPLATES['opportunity-basic-info'],
33

4+
setup() {
5+
const text = Utils.getTexts('opportunity-basic-info');
6+
return { text }
7+
},
8+
49
data () {
510
return {
11+
continuousFlowDate: $MAPAS.config.opportunityBasicInfo.date,
612
phases: []
713
};
814
},
@@ -23,7 +29,6 @@ app.component('opportunity-basic-info' , {
2329
}
2430
},
2531

26-
2732
computed: {
2833
lastPhase () {
2934
const phase = this.phases.find(item => item.isLastPhase);
@@ -32,39 +37,69 @@ app.component('opportunity-basic-info' , {
3237
},
3338

3439
watch: {
35-
'entity.isContinuousFlow'(newVal) {
36-
if (!newVal) {
37-
this.entity.hasEndDate = false;
38-
this.entity.continuousFlow = null;
39-
this.entity.publishedRegistrations = false;
40-
this.entity.registrationTo = null;
40+
'entity.isContinuousFlow'(newVal, oldValue) {
41+
if(newVal != oldValue){
42+
if (!newVal) {
43+
this.entity.hasEndDate = false;
44+
this.entity.continuousFlow = null;
45+
this.entity.publishedRegistrations = false;
4146

42-
this.lastPhase.name = "Publicação final do resultado";
43-
} else if (this.entity.registrationFrom) {
44-
const myDate = new McDate(new Date(`2111-01-01 00:00`));
45-
46-
this.entity.continuousFlow = myDate.sql('full');
47-
this.entity.publishedRegistrations = true;
48-
49-
this.lastPhase.name = "Resultado";
50-
}
47+
if (this.entity.registrationFrom && this.entity.registrationFrom._date instanceof Date) {
48+
this.incrementRegistrationTo();
49+
}
50+
51+
this.lastPhase.name = this.text("Publicação final do resultado");
52+
53+
} else {
54+
if(this.entity.registrationFrom){
55+
const myDate = new McDate(new Date(this.continuousFlowDate));
56+
57+
this.entity.continuousFlow = myDate.sql('full');
58+
this.entity.registrationTo = myDate.sql('full');
59+
this.entity.publishedRegistrations = true;
60+
61+
} else {
62+
this.entity.registrationTo = null;
63+
}
64+
65+
this.lastPhase.name = this.text("Resultado");
66+
}
5167

52-
this.lastPhase.disableMessages();
53-
this.lastPhase.save();
54-
this.entity.save();
68+
this.lastPhase.disableMessages();
69+
this.lastPhase.save();
70+
this.entity.save();
71+
}
5572
},
5673

57-
'entity.hasEndDate'(newVal) {
58-
if (!newVal) {
59-
const myDate = new McDate(new Date(`2111-01-01 00:00`));
60-
61-
this.entity.continuousFlow = myDate;
62-
this.entity.registrationTo = myDate;
63-
} else {
64-
this.entity.continuousFlow = null;
65-
this.entity.registrationTo = null;
66-
this.entity.publishedRegistrations = false;
74+
'entity.hasEndDate'(newVal, oldValue) {
75+
if(newVal != oldValue){
76+
if (this.entity.isContinuousFlow) {
77+
if(newVal){
78+
this.entity.continuousFlow = null;
79+
this.entity.registrationTo = null;
80+
this.entity.publishedRegistrations = false;
81+
82+
if (this.entity.registrationFrom && this.entity.registrationFrom._date instanceof Date) {
83+
this.incrementRegistrationTo();
84+
}
85+
86+
} else {
87+
const myDate = new McDate(new Date(this.continuousFlowDate));
88+
89+
this.entity.continuousFlow = myDate;
90+
this.entity.registrationTo = myDate;
91+
}
92+
}
6793
}
6894
},
95+
},
96+
97+
methods: {
98+
incrementRegistrationTo (){
99+
let newDate = new Date(this.entity.registrationFrom._date);
100+
newDate.setDate(newDate.getDate() + 2);
101+
102+
this.entity.registrationTo = new McDate(newDate);
103+
}
69104
}
70105
});

src/modules/Opportunities/components/opportunity-basic-info/template.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
<entity-field :entity="entity" type="checkbox" prop="isContinuousFlow" label="<?php i::esc_attr_e('É um edital de fluxo contínuo?')?>" classes="col-12 sm:col-12"></entity-field>
4343
<entity-field v-if="entity?.isContinuousFlow" :entity="entity" type="checkbox" prop="hasEndDate" label="<?php i::esc_attr_e('Definir data final para inscrições')?>" :autosave="3000" classes="col-12 sm:col-12"></entity-field>
4444

45-
<entity-field :entity="entity" prop="registrationFrom" :max="entity.registrationTo?._date" :autosave="3000" classes="col-6 sm:col-12"></entity-field>
46-
<entity-field v-if="!entity?.isContinuousFlow || entity?.hasEndDate" :entity="entity" prop="registrationTo" :min="entity.registrationFrom?._date" :autosave="3000" classes="col-6 sm:col-12"></entity-field>
45+
<entity-field :entity="entity" prop="registrationFrom" :autosave="3000" classes="col-6 sm:col-12"></entity-field>
46+
<entity-field v-if="!entity?.isContinuousFlow || entity?.hasEndDate" :entity="entity" prop="registrationTo" :autosave="3000" classes="col-6 sm:col-12"></entity-field>
4747

4848
<entity-field v-if="lastPhase && (!entity?.isContinuousFlow || entity?.hasEndDate)" :entity="lastPhase" prop="publishTimestamp" :autosave="3000" classes="col-6 sm:col-12">
4949
<label><?= i::__("Publicação final de resultados (data e hora)") ?></label>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
use MapasCulturais\i;
3+
4+
return [
5+
'Resultado' => i::__('Resultado'),
6+
'Publicação final do resultado' => i::__('Resultado'),
7+
];

src/modules/Opportunities/components/opportunity-phases-config/template.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@
9999
<template v-else-if="index === phases.length - 1">
100100
<div class="add-phase grid-12">
101101
<div class="col-12" v-if="!finalReportingPhase">
102-
<mc-alert v-if="!lastPhase?.publishTimestamp" type="warning">
102+
<mc-alert v-if="!firstPhase?.isContinuousFlow && !lastPhase?.publishTimestamp" type="warning">
103103
<p><small class="required"><?= i::__("A data e hora da 'Publicação final' precisa estar preenchida para adicionar novas fases de prestação de informações.") ?></small></p>
104104
</mc-alert>
105105

106-
<opportunity-create-reporting-phase v-if="lastPhase?.publishTimestamp" :opportunity="entity" @create="addReportingPhases"></opportunity-create-reporting-phase>
106+
<opportunity-create-reporting-phase v-if="!firstPhase?.isContinuousFlow && lastPhase?.publishTimestamp" :opportunity="entity" @create="addReportingPhases"></opportunity-create-reporting-phase>
107107
</div>
108108
</div>
109109
</template>

src/modules/Opportunities/components/opportunity-phases-timeline/script.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ app.component('opportunity-phases-timeline', {
107107

108108
const phaseOpportunity = item.__objectType == 'opportunity' ? item : item.opportunity;
109109

110-
return phaseOpportunity.publishedRegistrations && (isRegistrationOnly || isEvaluation);
110+
const allowProponentResponse = phaseOpportunity.allow_proponent_response === '1';
111+
112+
return (phaseOpportunity.publishedRegistrations && (isRegistrationOnly || isEvaluation)) || allowProponentResponse;
111113

112114
},
113115

src/modules/Opportunities/components/registration-results/script.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ app.component('registration-results', {
1010
type: Entity,
1111
required: true
1212
},
13-
14-
hideAppealStatus: {
15-
type: Boolean,
16-
default: false,
17-
},
1813
},
1914

2015
setup(props, { slots }) {
@@ -44,6 +39,10 @@ app.component('registration-results', {
4439
return $MAPAS.registrationPhases[appealPhaseId] || this.entity;
4540
},
4641

42+
hideAppealStatus() {
43+
return this.registration.status != 10;
44+
},
45+
4746
currentEvaluation() {
4847
return $MAPAS.config.appealPhaseEvaluationForm?.currentEvaluation;
4948
},
@@ -54,9 +53,18 @@ app.component('registration-results', {
5453
`${this.phase.name} - ${this.registration.number}`;
5554
},
5655

57-
showAppealPhaseEvaluationDetails() {
58-
return $MAPAS.config.continuousEvaluationDetail?.data.consolidatedDetails?.sentEvaluationCount;
59-
}
56+
evaluationData() {
57+
return $MAPAS.config.continuousEvaluationDetail[this.registration.id];
58+
},
59+
60+
showEvaluationDetails() {
61+
if (this.phase.opportunity?.allow_proponent_response && this.evaluationData?.consolidatedDetails?.sentEvaluationCount) {
62+
return true;
63+
} else {
64+
return this.evaluationData?.consolidatedDetails?.sentEvaluationCount
65+
|| this.registration.consolidatedDetails?.sentEvaluationCount;
66+
}
67+
},
6068
},
6169

6270
methods: {

0 commit comments

Comments
 (0)