Skip to content

Commit

Permalink
Fix state sql 2 (#45)
Browse files Browse the repository at this point in the history
* Fix broken State SQL

* Change qn => quoteName

* No need for an extra variable

* Fix status filter (again)
  • Loading branch information
bembelimen authored and Janek committed Jul 21, 2017
1 parent 994d169 commit d9761af
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
23 changes: 23 additions & 0 deletions administrator/components/com_workflow/Model/Transitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,27 @@ public function getListQuery()

return $query;
}

/**
* Get the filter form
*
* @param array $data data
* @param boolean $loadData load current data
*
* @return \JForm|boolean The \JForm object or false on error
*
* @since 3.2
*/
public function getFilterForm($data = array(), $loadData = true)
{
$form = parent::getFilterForm($data, $loadData);

if ($form)
{
$form->setFieldAttribute('from_state', 'sql_where', $this->getDbo()->quoteName('workflow_id') . ' = ' . (int) $this->getState('filter.workflow_id'), 'filter');
$form->setFieldAttribute('to_state', 'sql_where', $this->getDbo()->quoteName('workflow_id') . ' = ' . (int) $this->getState('filter.workflow_id'), 'filter');
}

return $form;
}
}
10 changes: 2 additions & 8 deletions administrator/components/com_workflow/View/Transitions/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,8 @@ public function display($tpl = null)
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');

$this->workflowID = $this->state->get("filter.workflow_id");
$this->extension = $this->state->get("filter.extension");

// Set the form selects sql
$sqlStatesFrom = WorkflowHelper::getStatesSQL('from_state', $this->workflowID);
$sqlStatesTo = WorkflowHelper::getStatesSQL('to_state', $this->workflowID);
$this->filterForm->setFieldAttribute('from_state', 'query', $sqlStatesFrom);
$this->filterForm->setFieldAttribute('to_state', 'query', $sqlStatesTo);
$this->workflowID = $this->state->get('filter.workflow_id');
$this->extension = $this->state->get('filter.extension');

WorkflowHelper::addSubmenu(
implode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
label="COM_WORKFLOW_FROM_STATE"
description="COM_WORKFLOW_FROM_STATE_DESC"
onchange="this.form.submit();"
query="SELECT id as value, title as from_state FROM #__workflow_states"
sql_select="id, title"
sql_from="#__workflow_states"
key_field="id"
value_field="title"
>
<option value="">COM_WORKFLOW_SELECT_FROM_STATE</option>
</field>
Expand All @@ -38,7 +41,10 @@
label="COM_WORKFLOW_FROM_STATE"
description="COM_WORKFLOW_FROM_STATE_DESC"
onchange="this.form.submit();"
query="SELECT id as value, title as to_state FROM #__workflow_states"
sql_select="id, title"
sql_from="#__workflow_states"
key_field="id"
value_field="title"
>
<option value="">COM_WORKFLOW_SELECT_TO_STATE</option>
</field>
Expand Down

0 comments on commit d9761af

Please sign in to comment.