Skip to content

Commit

Permalink
#211 - fixed the Back to List button on the edit screen, and updated …
Browse files Browse the repository at this point in the history
…it to use the new ViewState::selectedStart integer to remember the start position on the list we are returning to
  • Loading branch information
alphadevx committed Sep 7, 2015
1 parent 0a8fb27 commit 9d62250
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Alpha/Controller/ActiveRecordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Alpha\Util\Http\Response;
use Alpha\Util\Helper\Validator;
use Alpha\View\View;
use Alpha\View\ViewState;
use Alpha\Exception\IllegalArguementException;
use Alpha\Exception\ResourceNotFoundException;
use Alpha\Exception\ResourceNotAllowedException;
Expand Down Expand Up @@ -611,6 +612,9 @@ public function after_displayPageHead_callback()
if ($this->request->getParam('start') != null) {
$this->start = $this->request->getParam('start');

$viewState = ViewState::getInstance();
$viewState->set('selectedStart', $this->start);

if ($this->request->getParam('limit') != null) {
$this->limit = $this->request->getParam('limit');
} else {
Expand Down
4 changes: 3 additions & 1 deletion Alpha/View/Renderer/Html/RendererProviderHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ public function editView($fields = array())
$button = new Button($js, 'Delete', 'deleteBut');
$fields['deleteButton'] = $button->render();

$button = new Button("document.location = '".FrontController::generateSecureURL('act=Alpha\Controller\ActiveRecordController&ActiveRecordType='.get_class($this->BO))."'", 'Back to List', 'cancelBut');
$viewState = ViewState::getInstance();
$start = $viewState->get('selectedStart');
$button = new Button("document.location = '".FrontController::generateSecureURL('act=Alpha\Controller\ActiveRecordController&ActiveRecordType='.get_class($this->BO).'&start='.$start.'&limit='.$config->get('app.list.page.amount'))."'", 'Back to List', 'cancelBut');
$fields['cancelButton'] = $button->render();

// buffer security fields to $formSecurityFields variable
Expand Down
9 changes: 9 additions & 0 deletions Alpha/View/ViewState.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ class ViewState
*/
protected $renderAdminMenu = false;

/**
* The start position of the last pagination page by the user.
*
* @var int
*
* @since 2.0
*/
protected $selectedStart = 0;

/**
* The view state object singleton.
*
Expand Down

0 comments on commit 9d62250

Please sign in to comment.