Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tarea #1918 - mantener filtros entre paginas #1681

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Core/Lib/ExtendedController/ListView.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
namespace FacturaScripts\Core\Lib\ExtendedController;

use FacturaScripts\Core\Base\DataBase\DataBaseWhere;
use FacturaScripts\Core\Cache;
use FacturaScripts\Core\Model\Base\BusinessDocument;
use FacturaScripts\Core\Model\Base\ModelClass;
use FacturaScripts\Core\Request;
Expand Down Expand Up @@ -358,13 +359,30 @@ private function processFormDataLoad(Request $request)
return;
}

// si el metodo de la request es GET, obtenemos los filtros desde la cache
$cacheKeyFiltros = 'filtros-' . $request->cookie('fsNick') . '-' . trim(str_replace('/', '', $request->header('PATH_INFO')));
if($request->isMethod('GET')){
$filtrosCache = Cache::get($cacheKeyFiltros);
if ($filtrosCache){
// creamos valores de filtros en la request para aprovechar los metodos ya existentes
foreach ($filtrosCache as $filtro){
$request->request->set('filter' . $filtro->key, $filtro->getValue());
}
}
}

// filters
foreach ($this->filters as $filter) {
$filter->setValueFromRequest($request);
if ($filter->getDataBaseWhere($this->where)) {
$this->showFilters = true;
}
}

if($request->isMethod('POST')) {
// guardamos los filtros en cache
Cache::set($cacheKeyFiltros, $this->filters);
}
}

/**
Expand Down