Unverified Commit 346f9ff4 authored by Johan Cwiklinski's avatar Johan Cwiklinski Committed by GitHub
Browse files

More reliable way to detect sortable/not sortable tab (#8570)

* More reliable way to detect sortable/not sortable tab

* fix also in getCollectionPart
parent c67b625a
......@@ -223,18 +223,14 @@ class RuleCollection extends CommonDBTM {
$iterator = $DB->request($criteria);
$current_tab = str_replace($this->getType().'$', '', Session::getActiveTab($this->getType()));
$tabs = $this->getTabNameForItem($this);
$active_tab = Session::getActiveTab($this->getType());
$can_sort = !(Toolbox::startsWith($this->getType() . '$', $active_tab));
while ($data = $iterator->next()) {
//For each rule, get a Rule object with all the criterias and actions
$tempRule = $this->getRuleClass();
$tempRule->fields = $data;
if (isset($tabs[$current_tab])) {
//in a subtab disable sorting
$tempRule->can_sort = false;
}
$tempRule->can_sort = $can_sort;
$this->RuleList->list[] = $tempRule;
}
......@@ -265,8 +261,8 @@ class RuleCollection extends CommonDBTM {
if (count($iterator)) {
$this->RuleList->list = [];
$current_tab = str_replace($this->getType().'$', '', Session::getActiveTab($this->getType()));
$tabs = $this->getTabNameForItem($this);
$active_tab = Session::getActiveTab($this->getType());
$can_sort = !(Toolbox::startsWith($this->getType() . '$', $active_tab));
while ($rule = $iterator->next()) {
//For each rule, get a Rule object with all the criterias and actions
......@@ -275,9 +271,7 @@ class RuleCollection extends CommonDBTM {
if ($tempRule->getRuleWithCriteriasAndActions($rule["id"], $retrieve_criteria,
$retrieve_action)) {
if (!isset($tabs[$current_tab])) {
$tempRule->can_sort = false;
}
$tempRule->can_sort = $can_sort;
//Add the object to the list of rules
$this->RuleList->list[] = $tempRule;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment