Skip to content

Commit

Permalink
GH-139 Build available holding times selections dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed Dec 12, 2020
1 parent 5fb3023 commit 294b1d6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
29 changes: 28 additions & 1 deletion fleet2.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@

$_Lang['SelectResources'] = 'false';
$_Lang['SelectQuantumGate'] = 'false';

$setFormValues = [
'holdingtime' => null,
];

if(!empty($_POST['gobackVars']))
{
$_POST['gobackVars'] = json_decode(base64_decode($_POST['gobackVars']), true);
Expand All @@ -36,7 +41,7 @@
}
if(isset($_POST['gobackVars']['holdingtime']))
{
$_Lang['SelectHolding_'.$_POST['gobackVars']['holdingtime']] = 'selected';
$setFormValues['holdingtime'] = $_POST['gobackVars']['holdingtime'];
}
if(isset($_POST['gobackVars']['expeditiontime']))
{
Expand Down Expand Up @@ -668,6 +673,28 @@
$_Lang['Insert_AllyPact_AttackWarn'] = 'false';
}

$availableHoldTimes = FlightControl\Utils\Helpers\getAvailableHoldTimes([]);

$missionHoldTimeOptions = array_map(
function ($holdTimeValue) use ($setFormValues) {
return buildDOMElementHTML([
'tagName' => 'option',
'contentHTML' => $holdTimeValue,
'attrs' => [
'value' => $holdTimeValue,
'selected' => (
$holdTimeValue == $setFormValues['holdingtime'] ?
'' :
null
),
],
]);
},
$availableHoldTimes
);

$_Lang['P_HTMLBuilder_MissionHold_AvailableTimes'] = implode('', $missionHoldTimeOptions);

display(parsetemplate(gettemplate('fleet2_body'), $_Lang), $_Lang['fl_title']);

?>
7 changes: 1 addition & 6 deletions templates/default_template/fleet2_body.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,7 @@ var AllyPact_AttackWarn = {Insert_AllyPact_AttackWarn};
<tr>
<th colspan="3">
<select name="holdingtime">
<option value="1" {SelectHolding_1}>1</option>
<option value="2" {SelectHolding_2}>2</option>
<option value="4" {SelectHolding_4}>4</option>
<option value="8" {SelectHolding_8}>8</option>
<option value="16" {SelectHolding_16}>16</option>
<option value="32" {SelectHolding_32}>32</option>
{P_HTMLBuilder_MissionHold_AvailableTimes}
</select>
{fl_expe_hours}
</th>
Expand Down

0 comments on commit 294b1d6

Please sign in to comment.