mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR added stubs to allow widgets to use treedropdown fields
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@91850 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
797715ef78
commit
bd7ae8282d
@ -35,6 +35,10 @@ TreeDropdownField.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getName: function() {
|
||||||
|
return this.inputTag.name;
|
||||||
|
},
|
||||||
|
|
||||||
refresh: function() {
|
refresh: function() {
|
||||||
this.createTreeNode();
|
this.createTreeNode();
|
||||||
|
|
||||||
@ -45,7 +49,7 @@ TreeDropdownField.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
helperURLBase: function() {
|
helperURLBase: function() {
|
||||||
return this.ownerForm().action + '/field/' + this.inputTag.name + '/';
|
return this.ownerForm().action + '/field/' + this.getName() + '/';
|
||||||
},
|
},
|
||||||
ownerForm: function() {
|
ownerForm: function() {
|
||||||
var f =this.parentNode;
|
var f =this.parentNode;
|
||||||
@ -166,7 +170,7 @@ TreeDropdownField.prototype = {
|
|||||||
getIdx: function() {
|
getIdx: function() {
|
||||||
return this.getElementsByTagName('a')[0].getAttribute('rel');
|
return this.getElementsByTagName('a')[0].getAttribute('rel');
|
||||||
},
|
},
|
||||||
idxBase : 'selector-' + this.inputTag.name + '-',
|
idxBase : 'selector-' + this.getName() + '-',
|
||||||
dropdownField : this,
|
dropdownField : this,
|
||||||
onselect : this.tree_click
|
onselect : this.tree_click
|
||||||
});
|
});
|
||||||
@ -200,12 +204,14 @@ TreeDropdownField.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setValue: function(val) {
|
setValue: function(val) {
|
||||||
|
this.inputTag = this.getElementsByTagName('input')[0];
|
||||||
|
|
||||||
if(this.inputTag.value != val) {
|
if(this.inputTag.value != val) {
|
||||||
this.inputTag.value = val;
|
this.inputTag.value = val;
|
||||||
this.notify('Change', val);
|
this.notify('Change', val);
|
||||||
|
|
||||||
// If the tree item is already downloaded, just update the label
|
// If the tree item is already downloaded, just update the label
|
||||||
if($('selector-' + this.inputTag.name + '-' + this.inputTag.value)) {
|
if($('selector-' + this.getName() + '-' + this.inputTag.value)) {
|
||||||
this.updateTreeLabel();
|
this.updateTreeLabel();
|
||||||
|
|
||||||
// Otherwise, update the tree with ajax
|
// Otherwise, update the tree with ajax
|
||||||
@ -220,7 +226,7 @@ TreeDropdownField.prototype = {
|
|||||||
},
|
},
|
||||||
updateTreeLabel: function() {
|
updateTreeLabel: function() {
|
||||||
var treeNode;
|
var treeNode;
|
||||||
if(treeNode = $('selector-' + this.inputTag.name + '-' + this.inputTag.value)) {
|
if(treeNode = $('selector-' + this.getName() + '-' + this.inputTag.value)) {
|
||||||
this.humanItems.innerHTML = treeNode.getTitle();
|
this.humanItems.innerHTML = treeNode.getTitle();
|
||||||
|
|
||||||
if(treeNode.tree.selected && treeNode.tree.selected.removeNodeClass) treeNode.tree.selected.removeNodeClass('current');
|
if(treeNode.tree.selected && treeNode.tree.selected.removeNodeClass) treeNode.tree.selected.removeNodeClass('current');
|
||||||
@ -233,7 +239,7 @@ TreeDropdownField.prototype = {
|
|||||||
},
|
},
|
||||||
setValueFromTree: function(treeID, title) {
|
setValueFromTree: function(treeID, title) {
|
||||||
this.humanItems.innerHTML = title;
|
this.humanItems.innerHTML = title;
|
||||||
this.inputTag.value = treeID.replace('selector-' + this.inputTag.name + '-','');
|
this.inputTag.value = treeID.replace('selector-' + this.getName() + '-','');
|
||||||
this.notify('Change', this.inputTag.value);
|
this.notify('Change', this.inputTag.value);
|
||||||
|
|
||||||
this.hideTree();
|
this.hideTree();
|
||||||
@ -306,7 +312,7 @@ TreeMultiselectField.prototype = {
|
|||||||
var innerHTML = '';
|
var innerHTML = '';
|
||||||
var selectedItems = this.inputTag.value.split(/ *, */);
|
var selectedItems = this.inputTag.value.split(/ *, */);
|
||||||
for(i=0;i<selectedItems.length;i++) {
|
for(i=0;i<selectedItems.length;i++) {
|
||||||
if(treeNode = $('selector-' + this.inputTag.name + '-' + selectedItems[i])) {
|
if(treeNode = $('selector-' + this.getName() + '-' + selectedItems[i])) {
|
||||||
innerHTML += (innerHTML?', ':'') + treeNode.getTitle();
|
innerHTML += (innerHTML?', ':'') + treeNode.getTitle();
|
||||||
} else {
|
} else {
|
||||||
innerHTML += selectedItems[i];
|
innerHTML += selectedItems[i];
|
||||||
|
@ -205,6 +205,11 @@ class Widget_Controller extends Controller {
|
|||||||
return "Bad widget class name given";
|
return "Bad widget class name given";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Widget_TreeDropdownField extends TreeDropdownField {
|
||||||
|
function FieldHolder() {}
|
||||||
|
function Field() {}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@ -28,7 +28,8 @@ class WidgetArea extends DataObject {
|
|||||||
*/
|
*/
|
||||||
function WidgetControllers() {
|
function WidgetControllers() {
|
||||||
$controllers = new DataObjectSet();
|
$controllers = new DataObjectSet();
|
||||||
foreach($this->Widgets() as $widget) {
|
// var_dump($this->Items());
|
||||||
|
foreach($this->ItemsToRender() as $widget) {
|
||||||
// find controller
|
// find controller
|
||||||
$controllerClass = '';
|
$controllerClass = '';
|
||||||
foreach(array_reverse(ClassInfo::ancestry($widget->class)) as $widgetClass) {
|
foreach(array_reverse(ClassInfo::ancestry($widget->class)) as $widgetClass) {
|
||||||
@ -43,6 +44,14 @@ class WidgetArea extends DataObject {
|
|||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Items() {
|
||||||
|
return $this->Widgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
function ItemsToRender() {
|
||||||
|
return $this->Items();
|
||||||
|
}
|
||||||
|
|
||||||
function forTemplate() {
|
function forTemplate() {
|
||||||
return $this->renderWith($this->class);
|
return $this->renderWith($this->class);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user