ItemFilter/Fixup 16eabb90b6

* fix lost item grouping
 * fix type selector in filter form
 * fix item upgrade search
This commit is contained in:
Sarjuuk
2025-08-06 13:43:12 +02:00
parent 8d7c95378c
commit 0753bfbcf6
3 changed files with 16 additions and 12 deletions

View File

@@ -292,7 +292,7 @@ abstract class Filter
{
// quirk: in the POST step criteria can be [[''], null, null] if not selected.
$buff = [];
foreach ($val as $v)
foreach ((array)$val as $v) // can be string|int in POST step if only one value present
if ($v !== '' && $this->checkInput($type, $valid, $v))
$buff[] = $v;

View File

@@ -188,11 +188,11 @@ class ItemsPage extends GenericPage
break;
}
if ($singleSlot && empty($this->filter['gb'])) // enforce group by slot
$this->filter['gb'] = 1;
if ($singleSlot && empty($fiForm['gb'])) // enforce group by slot
$fiForm['gb'] = 1;
else if (!$singleSlot) // multiples can only be grouped by slot
{
$this->filter['gb'] = 1;
$fiForm['gb'] = 1;
$maxResults = 25;
$this->sharedLV['customFilter'] = '$fi_filterUpgradeListview';
}
@@ -221,7 +221,7 @@ class ItemsPage extends GenericPage
);
$groups = [];
$nameSource = [];
$grouping = $this->filter['gb'] ?? 0;
$grouping = $fiForm['gb'] ?? 0;
$extraOpts = [];
$maxResults = Cfg::get('SQL_LIMIT_DEFAULT');
@@ -237,10 +237,10 @@ class ItemsPage extends GenericPage
else
$groups = array_merge($availableSlots[ITEM_CLASS_ARMOR], $availableSlots[ITEM_CLASS_WEAPON]);
if (isset($this->filter['sl'])) // skip lookups for unselected slots
$groups = array_intersect($groups, $this->filter['sl']);
if ($fiForm['sl']) // skip lookups for unselected slots
$groups = array_intersect($groups, $fiForm['sl']);
if (!empty($this->filterObj->upgrades)) // skip lookups for slots we dont have items to upgrade for
if (!empty($this->filterObj->upgrades)) // skip lookups for slots we dont have items to upgrade for
$groups = array_intersect($groups, $this->filterObj->upgrades);
if ($groups)
@@ -286,6 +286,10 @@ class ItemsPage extends GenericPage
$groups[0] = null;
}
// write back 'gb' to filter
if ($grouping)
$this->filterObj->values['gb'] = $grouping;
/*****************************/
/* create lv-tabs for groups */
@@ -444,8 +448,8 @@ class ItemsPage extends GenericPage
$tPart = Lang::item('cat', $this->category[0], 1, $this->category[1], 1, $this->category[2]);
else if (isset($this->category[1]) && is_array(Lang::item('cat', $this->category[0])))
$tPart = Lang::item('cat', $this->category[0], 1, $this->category[1]);
else if ($this->category[0] == 0 && isset($this->filter['ty']) && !is_array($this->filter['ty']))
$tPart = Lang::item('cat', 0, 1, $this->filter['ty']);
else if ($this->category[0] == 0 && count($this->filterObj->values['ty']) == 1)
$tPart = Lang::item('cat', 0, 1, $this->filterObj->values['ty'][0]);
else
$tPart = Lang::item('cat', $this->category[0]);

View File

@@ -56,7 +56,7 @@ if ($this->typeList):
<div class="clear"></div>
<select name="ty[]" size="<?=min(count($this->typeList), 7); ?>" multiple="multiple" class="rightselect">
<?php
foreach ($fthis->typeList as $k => $str):
foreach ($this->typeList as $k => $str):
$selected = false;
if (isset($f['ty']) && in_array($k, (array)$f['ty'])):
$selected = true;
@@ -178,7 +178,7 @@ endforeach;
<input type="reset" value="<?=Lang::main('resetForm'); ?>" />
</div>
<input type="hidden" name="upg"<?=(!empty($f['upg']) ? ' value="'.$f['upg'].'"' : null); ?>/>
<input type="hidden" name="upg"<?=($f['upg'] ? ' value="'.implode(':', $f['upg']).'"' : ''); ?>/>
<div class="pad"></div>