Merge pull request #7250 from phptek/issue/7181

FIX: Fixes #7181 Use config system for userland config of node_threshold_total
This commit is contained in:
Damian Mooyman 2017-08-09 14:18:50 +12:00 committed by GitHub
commit 9ea09376eb
2 changed files with 13 additions and 3 deletions

View File

@ -50,6 +50,13 @@ class TreeDropdownField extends FormField {
'tree'
);
/**
* @config
* @var int
* @see {@link Hierarchy::$node_threshold_total}.
*/
private static $node_threshold_total = 30;
/**
* @ignore
*/
@ -303,7 +310,8 @@ class TreeDropdownField extends FormField {
if ($this->filterCallback || $this->search != "" )
$obj->setMarkingFilterFunction(array($this, "filterMarking"));
$obj->markPartialTree($nodeCountThreshold = 30, $context = null,
$nodeCountThreshold = Config::inst()->get('TreeDropdownField', 'node_threshold_total');
$obj->markPartialTree($nodeCountThreshold, $context = null,
$this->childrenMethod, $this->numChildrenMethod);
// allow to pass values to be selected within the ajax request

View File

@ -218,10 +218,12 @@ class Hierarchy extends DataExtension {
* @param int $nodeCountThreshold See {@link getChildrenAsUL()}
* @return int The actual number of nodes marked.
*/
public function markPartialTree($nodeCountThreshold = 30, $context = null,
public function markPartialTree($nodeCountThreshold = null, $context = null,
$childrenMethod = "AllChildrenIncludingDeleted", $numChildrenMethod = "numChildren") {
if(!is_numeric($nodeCountThreshold)) $nodeCountThreshold = 30;
if(!is_numeric($nodeCountThreshold)) {
$nodeCountThreshold = Config::inst()->get('Hierarchy', 'node_threshold_total');
}
$this->markedNodes = array($this->owner->ID => $this->owner);
$this->owner->markUnexpanded();