Skip to content

Commit 4177fba

Browse files
committed
Refactor packet edit form design
1 parent 33c0e2e commit 4177fba

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

src/templates/Packet/Edit.phtml

+25-22
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,25 @@ require('./header.inc.phtml'); ?>
3535
<? } ?>
3636
<? if ($error != 'NOT_FOUND') { ?>
3737
<form method="POST" action="?id=<?=$packet_id?>">
38-
<div class="form-group">
39-
<label class="font-weight-bold">Flags:</label>
40-
<div class="custom-control custom-switch"><input class="custom-control-input" type="checkbox" id="deprecated" name="deprecated" value="1"<?=($this->getContext()->deprecated?' checked="checked"':'')?> tabindex="6"/><label class="custom-control-label" for="deprecated">Deprecated</label></div>
41-
<div class="custom-control custom-switch"><input class="custom-control-input" type="checkbox" id="research" name="research" value="1"<?=($this->getContext()->research?' checked="checked"':'')?> tabindex="7"/> <label class="custom-control-label" for="research">In Research</label></div>
42-
<div class="custom-control custom-switch"><input class="custom-control-input" type="checkbox" id="published" name="published" value="1"<?=($this->getContext()->published?' checked="checked"':'')?> tabindex="8"/> <label class="custom-control-label" for="published">Published</label></div>
43-
</div>
44-
<div class="form-group">
45-
<label class="font-weight-bold" for="id">Id:</label>
46-
<input class="bg-dark border border-primary form-control text-light" type="text" name="id" id="id" placeholder="Enter the decimal (base-10) formatted id here" tabindex="1" required autofocus="autofocus" value="<?=$id?>"/>
47-
</div>
48-
<div class="form-group">
49-
<label class="font-weight-bold" for="name">Name:</label>
50-
<input class="bg-dark border border-primary form-control text-light" type="text" name="name" id="name" tabindex="2" required value="<?=$packet_name?>"/>
38+
<div class="row">
39+
<div class="col-md-3">
40+
<div class="form-group">
41+
<label class="font-weight-bold" for="id">Id:</label>
42+
<input class="bg-dark border border-primary form-control text-light" type="text" name="id" id="id" placeholder="Enter the message id here" tabindex="1" required autofocus="autofocus" value="<?=$id?>"/>
43+
</div>
44+
</div><div class="col-md-6">
45+
<div class="form-group">
46+
<label class="font-weight-bold" for="name">Name:</label>
47+
<input class="bg-dark border border-primary form-control text-light" type="text" name="name" id="name" placeholder="Enter the message name here" tabindex="2" required value="<?=$packet_name?>"/>
48+
</div>
49+
</div><div class="col-md-3">
50+
<div class="form-group">
51+
<label class="font-weight-bold">Options:</label>
52+
<div class="custom-control custom-switch"><input class="custom-control-input" type="checkbox" id="deprecated" name="deprecated" value="1"<?=($this->getContext()->deprecated?' checked="checked"':'')?> tabindex="6"/><label class="custom-control-label text-danger" for="deprecated">Deprecated</label></div>
53+
<div class="custom-control custom-switch"><input class="custom-control-input" type="checkbox" id="research" name="research" value="1"<?=($this->getContext()->research?' checked="checked"':'')?> tabindex="7"/> <label class="custom-control-label text-warning" for="research">In Research</label></div>
54+
<div class="custom-control custom-switch"><input class="custom-control-input" type="checkbox" id="published" name="published" value="1"<?=($this->getContext()->published?' checked="checked"':'')?> tabindex="8"/> <label class="custom-control-label text-success" for="published">Published</label></div>
55+
</div>
56+
</div>
5157
</div>
5258
<div class="form-group">
5359
<label class="font-weight-bold" for="format">Format:</label>
@@ -59,20 +65,17 @@ require('./header.inc.phtml'); ?>
5965
<thead></thead><tbody>
6066
<? function add_product_checkbox($id, $name, $checked)
6167
{
62-
printf('<td><div class="custom-control custom-switch"><input class="custom-control-input" type="checkbox" id="used_by_%s" name="used_by[]" value="%s"%s/><label class="custom-control-label" for="used_by_%s">%s</label></td>', $id, $id, ($checked ? ' checked="checked"' : ''), $id, $name);
68+
;
6369
}
6470
$product_ubound = count($products);
6571
for ($product_i = 0; $product_i < $product_ubound; ++$product_i)
6672
{
67-
echo '<tr>';
73+
if ($product_i % 2 === 0) echo '<tr>';
6874
$p = $products[$product_i];
69-
add_product_checkbox($p->getBnetProductId(), $p->getLabel(), in_array($p, $packet_used_by));
70-
if ($product_i + 1 < $product_ubound)
71-
{
72-
$p = $products[++$product_i];
73-
add_product_checkbox($p->getBnetProductId(), $p->getLabel(), in_array($p, $packet_used_by));
74-
}
75-
echo '</tr>';
75+
$p_id = $p->getBnetProductId();
76+
$p_label = $p->getLabel();
77+
printf('<td><div class="custom-control custom-switch"><input class="custom-control-input" type="checkbox" id="used_by_%s" name="used_by[]" value="%s"%s/><label class="custom-control-label" for="used_by_%s">%s</label></div></td>', $p_id, $p_id, (in_array($p, $packet_used_by) ? ' checked="checked"' : ''), $p_id, $p_label);
78+
if ($product_i % 2 === 1) echo '</tr>';
7679
} ?>
7780
</tbody>
7881
</table>

0 commit comments

Comments
 (0)