mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
BUGFIX Page location radio buttons update ParentID accordingly
This commit is contained in:
parent
8f25c8ee93
commit
a519411629
@ -1902,13 +1902,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$this->fieldLabel('ClassName'),
|
$this->fieldLabel('ClassName'),
|
||||||
$this->getClassDropdown()
|
$this->getClassDropdown()
|
||||||
),
|
),
|
||||||
|
$parentTypeSelector = new CompositeField(
|
||||||
new OptionsetField("ParentType", _t("SiteTree.PAGELOCATION", "Page location"), array(
|
new OptionsetField("ParentType", _t("SiteTree.PAGELOCATION", "Page location"), array(
|
||||||
"root" => _t("SiteTree.PARENTTYPE_ROOT", "Top-level page"),
|
"root" => _t("SiteTree.PARENTTYPE_ROOT", "Top-level page"),
|
||||||
"subpage" => _t("SiteTree.PARENTTYPE_SUBPAGE", "Sub-page underneath a parent page (choose below)"),
|
"subpage" => _t("SiteTree.PARENTTYPE_SUBPAGE", "Sub-page underneath a parent page (choose below)"),
|
||||||
)),
|
)),
|
||||||
$parentIDField = new TreeDropdownField("ParentID", $this->fieldLabel('ParentID'), 'SiteTree', 'ID', 'MenuTitle'),
|
$parentIDField = new TreeDropdownField("ParentID", $this->fieldLabel('ParentID'), 'SiteTree', 'ID', 'MenuTitle')
|
||||||
|
),
|
||||||
new CheckboxField("ShowInMenus", $this->fieldLabel('ShowInMenus')),
|
new CheckboxField("ShowInMenus", $this->fieldLabel('ShowInMenus')),
|
||||||
new CheckboxField("ShowInSearch", $this->fieldLabel('ShowInSearch')),
|
new CheckboxField("ShowInSearch", $this->fieldLabel('ShowInSearch')),
|
||||||
new LiteralField(
|
new LiteralField(
|
||||||
@ -1944,6 +1944,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* or its descendents, as this causes vanishing bugs.
|
* or its descendents, as this causes vanishing bugs.
|
||||||
*/
|
*/
|
||||||
$parentIDField->setFilterFunction(create_function('$node', "return \$node->ID != {$this->ID};"));
|
$parentIDField->setFilterFunction(create_function('$node', "return \$node->ID != {$this->ID};"));
|
||||||
|
$parentTypeSelector->addExtraClass('parentTypeSelector');
|
||||||
|
|
||||||
$tabBehaviour->setTitle(_t('SiteTree.TABBEHAVIOUR', "Behavior"));
|
$tabBehaviour->setTitle(_t('SiteTree.TABBEHAVIOUR', "Behavior"));
|
||||||
$tabAccess->setTitle(_t('SiteTree.TABACCESS', "Access"));
|
$tabAccess->setTitle(_t('SiteTree.TABACCESS', "Access"));
|
||||||
@ -2717,5 +2718,3 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -136,6 +136,9 @@
|
|||||||
onmatch : function() {
|
onmatch : function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.find(':input[name=ParentType]').bind('click', function(e) {self._toggleSelection(e);});
|
this.find(':input[name=ParentType]').bind('click', function(e) {self._toggleSelection(e);});
|
||||||
|
this.find('.TreeDropdownField').bind('change', function(e) {self._changeParentId(e);});
|
||||||
|
|
||||||
|
this._changeParentId();
|
||||||
this._toggleSelection();
|
this._toggleSelection();
|
||||||
|
|
||||||
this._super();
|
this._super();
|
||||||
@ -151,8 +154,22 @@
|
|||||||
var selected = this.find(':input[name=ParentType]:checked').val();
|
var selected = this.find(':input[name=ParentType]:checked').val();
|
||||||
// reset parent id if 'root' radiobutton is selected
|
// reset parent id if 'root' radiobutton is selected
|
||||||
if(selected == 'root') this.find(':input[name=ParentID]').val(0);
|
if(selected == 'root') this.find(':input[name=ParentID]').val(0);
|
||||||
|
// otherwise use the old value
|
||||||
|
else this.find(':input[name=ParentID]').val(this.find('#Form_EditForm_ParentType_subpage').data('parentIdValue'));
|
||||||
// toggle tree dropdown based on selection
|
// toggle tree dropdown based on selection
|
||||||
this.find('#ParentID').toggle(selected != 'root');
|
this.find('#ParentID').toggle(selected != 'root');
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function: _changeParentId
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* (Event) e
|
||||||
|
*/
|
||||||
|
_changeParentId: function(e) {
|
||||||
|
var value = this.find(':input[name=ParentID]').val();
|
||||||
|
// set a data attribute so we know what to use in _toggleSelection
|
||||||
|
this.find('#Form_EditForm_ParentType_subpage').data('parentIdValue', value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user