12
12
use Drupal \ghi_blocks \Traits \GlobalSettingsTrait ;
13
13
use Drupal \ghi_blocks \Traits \PlanFootnoteTrait ;
14
14
use Drupal \ghi_blocks \Traits \TableSoftLimitTrait ;
15
+ use Drupal \ghi_blocks \Traits \TableTrait ;
15
16
use Drupal \ghi_plans \ApiObjects \Mocks \PlanOverviewPlanMock ;
16
17
use Drupal \ghi_plans \Traits \FtsLinkTrait ;
17
18
use Drupal \hpc_common \Helpers \ArrayHelper ;
@@ -44,6 +45,7 @@ class PlanTable extends GHIBlockBase implements HPCDownloadExcelInterface, HPCDo
44
45
use GlobalPlanOverviewBlockTrait;
45
46
use GlobalSettingsTrait;
46
47
use PlanFootnoteTrait;
48
+ use TableTrait;
47
49
use TableSoftLimitTrait;
48
50
use BlockCommentTrait;
49
51
use FtsLinkTrait;
@@ -142,62 +144,22 @@ public function buildTableData($export = FALSE) {
142
144
$ header += [
143
145
'name ' => $ this ->t ('Plans ' ),
144
146
'type ' => $ this ->t ('Plan type ' ),
145
- 'inneed ' => [
146
- 'data ' => $ this ->t ('People in need ' ),
147
- 'data-column-type ' => 'amount ' ,
148
- ],
149
- 'targeted ' => [
150
- 'data ' => $ this ->t ('People targeted ' ),
151
- 'data-column-type ' => 'amount ' ,
152
- ],
153
- 'expected_reach ' => [
154
- 'data ' => $ this ->t ('Estimated Reach ' ),
155
- 'data-column-type ' => 'amount ' ,
156
- ],
157
- 'expected_reached ' => [
158
- 'data ' => $ this ->t ('% Reached ' ),
159
- 'data-column-type ' => 'amount ' ,
160
- ],
161
- 'latest_reach ' => [
162
- 'data ' => $ this ->t ('People reached ' ),
163
- 'data-column-type ' => 'percentage ' ,
164
- ],
165
- 'reached ' => [
166
- 'data ' => $ this ->t ('% Reached ' ),
167
- 'data-column-type ' => 'percentage ' ,
168
- ],
169
- 'requirements ' => [
170
- 'data ' => $ this ->t ('Requirements ' ),
171
- 'data-column-type ' => 'currency ' ,
172
- ],
173
- 'funding ' => [
174
- 'data ' => $ this ->t ('Funding ' ),
175
- 'data-column-type ' => 'currency ' ,
176
- ],
177
- 'coverage ' => [
178
- 'data ' => $ this ->t ('% Funded ' ),
179
- 'data-column-type ' => 'percentage ' ,
180
- ],
181
- 'status ' => [
182
- 'data ' => $ this ->t ('Status ' ),
183
- 'data-column-type ' => 'status ' ,
184
- 'sortable ' => FALSE ,
185
- ],
147
+ 'inneed ' => $ this ->buildHeaderColumn ($ this ->t ('People in need ' ), 'amount ' ),
148
+ 'targeted ' => $ this ->buildHeaderColumn ($ this ->t ('People targeted ' ), 'amount ' ),
149
+ 'expected_reach ' => $ this ->buildHeaderColumn ($ this ->t ('Estimated Reach ' ), 'amount ' ),
150
+ 'expected_reached ' => $ this ->buildHeaderColumn ($ this ->t ('% Reached ' ), 'percentage ' ),
151
+ 'latest_reach ' => $ this ->buildHeaderColumn ($ this ->t ('People reached ' ), 'percentage ' ),
152
+ 'reached ' => $ this ->buildHeaderColumn ($ this ->t ('% Reached ' ), 'percentage ' ),
153
+ 'requirements ' => $ this ->buildHeaderColumn ($ this ->t ('Requirements ' ), 'currency ' ),
154
+ 'funding ' => $ this ->buildHeaderColumn ($ this ->t ('Funding ' ), 'currency ' ),
155
+ 'coverage ' => $ this ->buildHeaderColumn ($ this ->t ('% Funded ' ), 'percentage ' ),
156
+ 'status ' => $ this ->buildHeaderColumn ($ this ->t ('Status ' ), 'status ' ),
186
157
];
187
158
if ($ export ) {
188
159
$ header ['in_gho ' ] = $ this ->t ('In GHO ' );
189
- $ header ['document ' ] = [
190
- 'data ' => $ this ->t ('Document ' ),
191
- 'data-column-type ' => 'document ' ,
192
- ];
193
- $ header ['link_ha ' ] = [
194
- 'data ' => $ this ->t ('Link to HA page ' ),
195
- 'data-column-type ' => 'document ' ,
196
- ];
197
- $ header ['link_fts ' ] = [
198
- 'data ' => $ this ->t ('Link to FTS page ' ),
199
- 'data-column-type ' => 'document ' ,
200
- ];
160
+ $ header ['document ' ] = $ this ->buildHeaderColumn ($ this ->t ('Document ' ), 'document ' );
161
+ $ header ['link_ha ' ] = $ this ->buildHeaderColumn ($ this ->t ('Link to HA page ' ), 'document ' );
162
+ $ header ['link_fts ' ] = $ this ->buildHeaderColumn ($ this ->t ('Link to FTS page ' ), 'document ' );
201
163
}
202
164
203
165
$ cache_tags = [];
@@ -241,19 +203,15 @@ public function buildTableData($export = FALSE) {
241
203
$ document_uri = $ plan ->getPlanDocumentUri ();
242
204
243
205
// Setup the column values.
244
- $ value_in_need = $ in_need ? [
206
+ $ value_in_need = [
245
207
'#theme ' => 'hpc_amount ' ,
246
- '#amount ' => $ in_need ,
208
+ '#amount ' => $ in_need ?: ' - ' ,
247
209
'#decimals ' => $ decimals ,
248
- ] : [
249
- '#markup ' => '- ' ,
250
210
];
251
- $ value_targeted = $ target ? [
211
+ $ value_targeted = [
252
212
'#theme ' => 'hpc_amount ' ,
253
- '#amount ' => $ target ,
213
+ '#amount ' => $ target ?: ' - ' ,
254
214
'#decimals ' => $ decimals ,
255
- ] : [
256
- '#markup ' => '- ' ,
257
215
];
258
216
$ value_expected_reach = [
259
217
'#theme ' => 'hpc_amount ' ,
@@ -264,12 +222,10 @@ public function buildTableData($export = FALSE) {
264
222
'#theme ' => 'hpc_percent ' ,
265
223
'#ratio ' => $ expected_reached / 100 ,
266
224
];
267
- $ value_latest_reached = $ latest_reached !== NULL ? [
225
+ $ value_latest_reached = [
268
226
'#theme ' => 'hpc_amount ' ,
269
- '#amount ' => $ latest_reached ,
227
+ '#amount ' => $ latest_reached ?? $ this -> t ( ' Pending ' ) ,
270
228
'#decimals ' => $ decimals ,
271
- ] : [
272
- '#markup ' => $ this ->t ('Pending ' ),
273
229
];
274
230
$ value_reached = $ reached_percent ? [
275
231
'#theme ' => 'hpc_percent ' ,
0 commit comments