Webgui code improvements and fixes

This commit is contained in:
thooge committed 2026-10-30 11:40:59 +01:00
1 parent dacf32b401
commit 5fe9a52f15
14 files changed
+205 -311

No files matched your search

+13 -54
View File
@@ -194,26 +194,13 @@ echo '<h2>', _('Add Cable'), "</h2>\n";
?>
<form method="post" action="<?=$g_scriptname?>">
<div class="mb-3">
<label for="tagname" class="form-label"><?=_('Name')?></label>
<input type="text" class="form-control" id="cablename" name="cablename" required autofocus>
</div>
<div class="mb-3">
<label for="note" class="form-label"><?=_('Length, m')?></label>
<input type="text" class="form-control" id="length" name="length">
</div>
<?php
form_create_text('cablename', _('Name'), 80, NULL, TRUE, TRUE);
form_create_numeric('length', _('Length, m'), step: 0.01);
form_create_select('cabletype', _('Type'), $g_opt_none + $opt_cabletype);
?>
<div class="mb-3">
<label for="note" class="form-label"><?=_('Number of conductors')?></label>
<input type="number" class="form-control" id="conductors" name="conductors">
</div>
<div class="mb-3">
<label for="note" class="form-label"><?=_('Cross section, mm²')?></label>
<input type="text" class="form-control" id="xsection" name="xsection">
</div>
<?php
form_create_numeric('number', _('Number of conductors'), NULL, 1, 99, 1);
form_create_numeric('xsection', _('Cross section, mm²'), NULL, 0, 999, 0.1);
form_new_buttons($g_scriptname);
echo "</form>\n";
@@ -261,46 +248,18 @@ echo '<h2>', _('Edit cable'), "</h2>\n";
?>
<form method="post" action="<?=$g_scriptname?>">
<input type="hidden" name="id" value="<?=$id?>">
<div class="mb-3">
<label for="mname" class="form-label"><?=_('Name')?></label>
<input type="text" class="form-control" id="cablename" name="cablename" value="<?=h($cable->cablename)?>">
</div>
<?php
form_create_text('cablename', _('Name'), 80, $cable->cablename, TRUE, TRUE);
form_create_select('cabletype', _('Type'), $g_opt_none + $opt_cabletype, $cable->cabletype);
form_create_select('techname', _('Techname'), $g_opt_none + $opt_techname, $cable->techname);
?>
<div class="mb-3">
<label for="note" class="form-label"><?=_('Length, m')?></label>
<input type="text" class="form-control" id="length" name="length" value="<?=format_float($cable->length, 1);?>">
</div>
<div class="mb-3">
<label for="note" class="form-label"><?=_('Number of conductors')?></label>
<input type="number" class="form-control" id="conductors" name="conductors" value="<?=$cable->conductors;?>">
</div>
<div class="mb-3">
<label for="note" class="form-label"><?=_('Diameter, mm')?></label>
<input type="text" class="form-control" id="diameter" name="diameter" value="<?=format_float($cable->diameter, 1);?>">
</div>
<div class="mb-3">
<label for="note" class="form-label"><?=_('Cross section, mm²')?></label>
<input type="text" class="form-control" id="xsection" name="xsection" value="<?=format_float($cable->xsection, 1);?>">
</div>
<div class="mb-3">
<label for="note" class="form-label"><?=_('Weight, kg/m')?></label>
<input type="text" class="form-control" id="weight" name="weight" value="<?=$cable->weight;?>">
</div>
<div class="mb-3">
<label for="color" class="form-label"><?=_('Color')?></label>
<input type="color" name="color" id="color" class="form-control" value="#<?=$cable->color;?>">
</div>
<?php
form_create_numeric('length', _('Length, m'), format_float($cable->length, 1), 0, 9999, 0.01);
form_create_numeric('number', _('Number of conductors'), $cable->conductors, 1, 99, 1);
form_create_numeric('diameter', ('Diameter, mm'), format_float($cable->diameter, 1), 0, 999, 0.1);
form_create_numeric('xsection', _('Cross section, mm²'), format_float($cable->xsection, 1), 0, 999, 0.1);
form_create_numeric('weight', _('Weight, kg/m'), format_float($cable->weight, 2), 0, 9999, 0.01);
form_create_color('color', _('Color'), $cable->color);
form_create_select('cablecond', _('Condition'), $opt_cablecond, $cable->cablecond);
?>
<div class="mb-3">
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=h($cable->remarks)?></textarea>
</div>
<?php
form_create_textarea('remarks', _('Remarks'), 3, 150, $cable->remarks);
form_edit_buttons($g_scriptname, $id);
echo "</form>\n";