MINOR added stubs to allow widgets to use treedropdown fields (from r91850)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92471 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-11-21 02:00:58 +00:00
parent d6eaea02b1
commit c14e7df9e8
3 changed files with 20 additions and 3 deletions

View File

@ -5,6 +5,10 @@
* @subpackage content * @subpackage content
*/ */
class WidgetAreaEditor extends FormField { class WidgetAreaEditor extends FormField {
function __construct($name) {
parent::__construct($name);
}
function FieldHolder() { function FieldHolder() {
Requirements::css(CMS_DIR . '/css/WidgetAreaEditor.css'); Requirements::css(CMS_DIR . '/css/WidgetAreaEditor.css');
Requirements::javascript(CMS_DIR . '/javascript/WidgetAreaEditor.js'); Requirements::javascript(CMS_DIR . '/javascript/WidgetAreaEditor.js');
@ -26,7 +30,7 @@ class WidgetAreaEditor extends FormField {
function UsedWidgets() { function UsedWidgets() {
$relationName = $this->name; $relationName = $this->name;
$widgets = $this->form->getRecord()->getComponent($relationName)->Widgets(); $widgets = $this->form->getRecord()->getComponent($relationName)->Items();
return $widgets; return $widgets;
} }
@ -48,7 +52,7 @@ class WidgetAreaEditor extends FormField {
$record->$idName = $widgetarea->ID; $record->$idName = $widgetarea->ID;
$widgets = $widgetarea->Widgets(); $widgets = $widgetarea->Items();
// store the field IDs and delete the missing fields // store the field IDs and delete the missing fields
// alternatively, we could delete all the fields and re add them // alternatively, we could delete all the fields and re add them

View File

@ -160,6 +160,10 @@ WidgetAreaEditorClass.prototype = {
$('usedWidgets-'+this.name).parentNode.parentNode.rewriteWidgetAreaAttributes(); $('usedWidgets-'+this.name).parentNode.parentNode.rewriteWidgetAreaAttributes();
UsedWidget.applyToChildren($('usedWidgets-'+this.name), 'div.Widget'); UsedWidget.applyToChildren($('usedWidgets-'+this.name), 'div.Widget');
// Repply some common form controls
WidgetTreeDropdownField.applyTo('div.usedWidgets .TreeDropdownField');
Sortable.create('usedWidgets-SideBar', { Sortable.create('usedWidgets-SideBar', {
tag: 'div', tag: 'div',
handle: 'handle', handle: 'handle',
@ -231,6 +235,15 @@ UsedWidget.prototype = {
} }
} }
WidgetTreeDropdownField = Class.extend('TreeDropdownField');
WidgetTreeDropdownField.prototype = {
getName: function() {
return 'Widget_TDF_Endpoint';
}
}
WidgetTreeDropdownField.applyTo('div.usedWidgets .TreeDropdownField');
// Loop over all WidgetAreas and fire 'em up // Loop over all WidgetAreas and fire 'em up
var wAs = $$('.WidgetAreaEditor'); var wAs = $$('.WidgetAreaEditor');
for(var i = 0; i < wAs.length; i++) { for(var i = 0; i < wAs.length; i++) {

View File

@ -17,7 +17,7 @@
</div> </div>
<div class="usedWidgetsHolder"> <div class="usedWidgetsHolder">
<h2><% _t('INUSE', 'Widgets currently used') %></h2> <h2><% _t('INUSE', 'Widgets currently used') %></h2>
<p><% _t('TOADD', 'To add widgets, drag them from the left area to here.') %></p> <p><% _t('TOADD', 'To add widgets, click on the purple header on the left') %></p>
<div class="usedWidgets" id="usedWidgets-$Name"> <div class="usedWidgets" id="usedWidgets-$Name">
<% if UsedWidgets %> <% if UsedWidgets %>