11
11
*/
12
12
class Plugin extends \MapasCulturais \Plugin
13
13
{
14
-
15
14
public function _init (): void
16
15
{
17
16
$ app = (new App )->i ();
18
-
19
- $ app ->hook ('template(<<registration|opportunity>>.<<single|view>>.head):begin ' , function () use ($ app ) {
17
+ // Load assets in head
18
+ $ app ->hook ('template(<<registration|opportunity|panel >>.<<single|view|registrations|index >>.head):begin ' , function () use ($ app ) {
20
19
$ app ->view ->enqueueScript (
21
20
'app ' ,
22
21
'swal2 ' ,
@@ -32,39 +31,29 @@ public function _init(): void
32
31
'opinionManagement ' ,
33
32
'OpinionManagement/css/opinionManagement.css '
34
33
);
35
-
36
34
$ app ->view ->enqueueScript (
37
35
'app ' ,
38
36
'opinion-management ' ,
39
37
'OpinionManagement/js/opinionManagement.js '
40
38
);
41
39
});
42
- $ app ->hook ('template(panel.<<registrations|index>>.head):begin ' , function () use ($ app ) {
43
- $ app ->view ->enqueueScript (
44
- 'app ' ,
45
- 'swal2 ' ,
46
- 'js/sweetalert2.all.min.js '
47
- );
48
- $ app ->view ->enqueueStyle (
49
- 'app ' ,
50
- 'swal2-theme-secultce ' ,
51
- 'css/swal2-secultce.min.css '
52
- );
53
- $ app ->view ->enqueueStyle (
54
- 'app ' ,
55
- 'opinionManagement ' ,
56
- 'OpinionManagement/css/opinionManagement.css '
57
- );
58
40
59
- $ app ->view ->enqueueScript (
60
- 'app ' ,
61
- 'opinion-management ' ,
62
- 'OpinionManagement/js/opinionManagement.js '
63
- );
41
+ $ app ->hook ('template(opportunity.edit.registration-config):after ' , function () use ($ app ) {
42
+ $ opportunity = $ this ->controller ->requestedEntity ;
43
+ /**
44
+ * @todo: Refatorar quando for mudar para publicar pareceres técnicos
45
+ */
46
+ if ($ opportunity ->evaluationMethodConfiguration ->type != 'documentary ' ) {
47
+ return ;
48
+ }
49
+ $ this ->part ('OpinionManagement/selection-autopublish ' , ['opportunity ' => $ opportunity ]);
64
50
});
65
51
66
52
$ app ->hook ('template(opportunity.single.registration-list-header):end ' , function () use ($ app ) {
67
53
$ opportunity = $ this ->controller ->requestedEntity ;
54
+ /**
55
+ * @todo: Refatorar quando for mudar para publicar pareceres técnicos
56
+ */
68
57
if ($ opportunity ->evaluationMethodConfiguration ->type != 'documentary ' ) {
69
58
return ;
70
59
}
@@ -82,8 +71,12 @@ public function _init(): void
82
71
});
83
72
}
84
73
});
74
+
85
75
$ app ->hook ('template(opportunity.single.user-registration-table--registration--status):end ' , function ($ registration , $ opportunity ) use ($ app ) {
86
- if ($ opportunity ->evaluationMethodConfiguration ->type != 'documentary ' || !$ opportunity ->publishedRegistrations ) {
76
+ /**
77
+ * @todo: Refatorar quando for mudar para publicar pareceres técnicos
78
+ */
79
+ if ($ opportunity ->publishedOpinions != 'true ' ) {
87
80
return ;
88
81
}
89
82
@@ -92,12 +85,28 @@ public function _init(): void
92
85
}
93
86
});
94
87
88
+ $ app ->hook ('template(opportunity.single.opportunity-registrations--tables):begin ' , function () use ($ app ) {
89
+ $ opportunity = $ this ->controller ->requestedEntity ;
90
+ /**
91
+ * @todo: Refatorar quando for mudar para publicar pareceres técnicos
92
+ */
93
+ if ($ opportunity ->evaluationMethodConfiguration ->type != 'documentary '
94
+ || $ opportunity ->autopublishOpinions !== 'Não '
95
+ || $ opportunity ->publishedOpinions == 'true '
96
+ ) {
97
+ return ;
98
+ }
99
+
100
+ $ this ->part ('OpinionManagement/admin-btn-publish-opinions.php ' , ['opportunity ' => $ opportunity ]);
101
+ });
102
+
95
103
$ app ->hook ('template(registration.view.header-fieldset):after ' , function () use ($ app ) {
96
104
$ registration = $ this ->controller ->requestedEntity ;
97
105
$ opportunity = $ registration ->opportunity ;
98
106
99
- // http://localhost:8080/inscricao/612180872/
100
-
107
+ /**
108
+ * @todo: Refatorar quando for mudar para publicar pareceres técnicos
109
+ */
101
110
if ($ opportunity ->evaluationMethodConfiguration ->type != 'documentary ' || (!$ opportunity ->publishedRegistrations && !$ opportunity ->canUser ('@control ' ))) {
102
111
return ;
103
112
}
@@ -107,8 +116,10 @@ public function _init(): void
107
116
}
108
117
});
109
118
110
-
111
119
$ app ->hook ('template(panel.<<registrations|index>>.panel-registration):end ' , function ($ registration ) use ($ app ) {
120
+ /**
121
+ * @todo: Refatorar quando for mudar para publicar pareceres técnicos
122
+ */
112
123
if (!$ registration ->opportunity ->publishedRegistrations
113
124
|| $ registration ->opportunity ->evaluationMethodConfiguration ->type != 'documentary '
114
125
) return ;
@@ -119,6 +130,11 @@ public function _init(): void
119
130
'OpinionManagement/js/opinionManagement.js '
120
131
);
121
132
});
133
+
134
+ $ app ->hook ('entity(Opportunity).publishRegistrations:before ' , function () {
135
+ if ($ this ->autopublishOpinions == 'Sim ' )
136
+ $ this ->setMetadata ('publishedOpinions ' , 'true ' );
137
+ });
122
138
}
123
139
124
140
/**
@@ -130,5 +146,20 @@ public function register(): void
130
146
131
147
$ app ->registerController ('opinionManagement ' , OpinionManagement::class);
132
148
149
+ $ this ->registerOpportunityMetadata ('autopublishOpinions ' , [
150
+ 'type ' => 'select ' ,
151
+ 'default_value ' => 'Não ' ,
152
+ 'label ' => \MapasCulturais \i::__ ('Publicar pareceres automaticamente ' ),
153
+ 'description ' => \MapasCulturais \i::__ ('Indica se os pareceres devem ser publicados automaticamente ' ),
154
+ 'options ' => ['Sim ' , 'Não ' ],
155
+ 'required ' => true ,
156
+ ]);
157
+ $ this ->registerOpportunityMetadata ('publishedOpinions ' , [
158
+ 'type ' => 'select ' ,
159
+ 'label ' => \MapasCulturais \i::__ ('Pareceres publicados ' ),
160
+ 'default_value ' => 'false ' ,
161
+ 'options ' => ['true ' , 'false ' ],
162
+ 'required ' => true ,
163
+ ]);
133
164
}
134
165
}
0 commit comments