FIX: Fixes #7181 to config system for userland config of node display limits.

This commit is contained in:
Russell Michell 2017-08-07 10:55:38 +12:00
parent fc35eff13f
commit 59b28f7d5b
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();