Skip to content

Commit 0ae056e

Browse files
committed
prevent item from rendering extra empty properties to get even
1 parent a840a97 commit 0ae056e

5 files changed

Lines changed: 18 additions & 27 deletions

File tree

src/UI/Implementation/Component/Item/Renderer.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ protected function renderShy(Shy $component, RendererInterface $default_renderer
188188
$value = htmlentities($value);
189189
}
190190
$tpl->setCurrentBlock("property_row");
191-
$tpl->setVariable("PROP_NAME_A", $name);
192-
$tpl->setVariable("PROP_VAL_A", $value);
191+
$tpl->setVariable("PROP_NAME", $name);
192+
$tpl->setVariable("PROP_VAL", $value);
193193
$tpl->parseCurrentBlock();
194194
}
195195
$tpl->setCurrentBlock("properties");
@@ -338,19 +338,15 @@ protected function renderProperties(Item $component, RendererInterface $default_
338338
//should introduce here htmlentities
339339
$value = $value;
340340
}
341-
$cnt++;
342-
if ($cnt % 2 == 1) {
341+
$tpl->setCurrentBlock("property_cell");
342+
$tpl->setVariable("PROP_NAME", $name);
343+
$tpl->setVariable("PROP_VAL", $value);
344+
$tpl->parseCurrentBlock();
345+
if ($cnt % 2 === 1 || array_key_last($props) === $name) {
343346
$tpl->setCurrentBlock("property_row");
344-
$tpl->setVariable("PROP_NAME_A", $name);
345-
$tpl->setVariable("PROP_VAL_A", $value);
346-
} else {
347-
$tpl->setVariable("PROP_NAME_B", $name);
348-
$tpl->setVariable("PROP_VAL_B", $value);
349347
$tpl->parseCurrentBlock();
350348
}
351-
}
352-
if ($cnt % 2 == 1) {
353-
$tpl->parseCurrentBlock();
349+
$cnt++;
354350
}
355351
$tpl->setCurrentBlock("properties");
356352
$tpl->parseCurrentBlock();

src/UI/templates/default/Item/tpl.item_notification.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ <h4 class="il-item-notification-title">{TITLE}</h4>
2020
<hr class="il-item-divider">
2121
<!-- BEGIN property_row -->
2222
<div class="row il-item-properties">
23+
<!-- BEGIN property_cell -->
2324
<div class="col-sm-12 il-multi-line-cap-3">
24-
<span class="il-item-property-name">{PROP_NAME_A}</span><span class="il-item-property-value">{PROP_VAL_A}</span>
25-
</div>
26-
<div class="col-sm-12 il-multi-line-cap-3">
27-
<span class="il-item-property-name">{PROP_NAME_B}</span><span class="il-item-property-value">{PROP_VAL_B}</span>
25+
<span class="il-item-property-name">{PROP_NAME}</span><span class="il-item-property-value">{PROP_VAL}</span>
2826
</div>
27+
<!-- END property_cell -->
2928
</div>
3029
<!-- END property_row -->
3130
<!-- END properties -->
@@ -37,4 +36,4 @@ <h4 class="il-item-notification-title">{TITLE}</h4>
3736
</div>
3837
</div>
3938
</div>
40-
</div>
39+
</div>

src/UI/templates/default/Item/tpl.item_shy.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<hr class="il-item-divider" />
1010
<!-- BEGIN property_row -->
1111
<div class="il-item-properties">
12-
<div class="il-item-property-name">{PROP_NAME_A}</div>
13-
<div class="il-item-property-value">{PROP_VAL_A}</div>
12+
<div class="il-item-property-name">{PROP_NAME}</div>
13+
<div class="il-item-property-value">{PROP_VAL}</div>
1414
</div>
1515
<!-- END property_row -->
1616
<!-- END properties -->

src/UI/templates/default/Item/tpl.item_standard.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@ <h4 class="il-item-title">{TITLE}</h4>
5050
<hr class="il-item-divider" />
5151
<!-- BEGIN property_row -->
5252
<div class="row">
53+
<!-- BEGIN property_cell -->
5354
<div class="col-md-6 il-multi-line-cap-3">
54-
<span class="il-item-property-name">{PROP_NAME_A}</span><span class="il-item-property-value">{PROP_VAL_A}</span>
55-
</div>
56-
<div class="col-md-6 il-multi-line-cap-3">
57-
<span class="il-item-property-name">{PROP_NAME_B}</span><span class="il-item-property-value">{PROP_VAL_B}</span>
55+
<span class="il-item-property-name">{PROP_NAME}</span><span class="il-item-property-value">{PROP_VAL}</span>
5856
</div>
57+
<!-- END property_cell -->
5958
</div>
6059
<!-- END property_row -->
6160
<!-- END properties -->
@@ -72,4 +71,4 @@ <h4 class="il-item-title">{TITLE}</h4>
7271
<!-- BEGIN lead_end -->
7372
</div>
7473
</div><!-- END lead_end -->
75-
</div>
74+
</div>

tests/UI/Component/Item/ItemTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,6 @@ public function testRenderBase(): void
242242
<div class="col-md-6 il-multi-line-cap-3">
243243
<span class="il-item-property-name">Location</span><span class="il-item-property-value">Room 123, Main Street 44, 3012 Bern</span>
244244
</div>
245-
<div class="col-md-6 il-multi-line-cap-3">
246-
<span class="il-item-property-name"></span><span class="il-item-property-value"></span>
247-
</div>
248245
</div>
249246
</div>
250247
EOT;

0 commit comments

Comments
 (0)