Browse files

MINOR added stubs to allow widgets to use treedropdown fields (from r…

…91850)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92471 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent d6eaea0 commit c14e7df9e82b1c0261faf302013a438c68048553 @chillu chillu committed Nov 21, 2009
Showing with 20 additions and 3 deletions.
  1. +6 −2 code/WidgetAreaEditor.php
  2. +13 −0 javascript/WidgetAreaEditor.js
  3. +1 −1 templates/WidgetAreaEditor.ss
View
8 code/WidgetAreaEditor.php
@@ -5,6 +5,10 @@
* @subpackage content
*/
class WidgetAreaEditor extends FormField {
+ function __construct($name) {
+ parent::__construct($name);
+ }
+
function FieldHolder() {
Requirements::css(CMS_DIR . '/css/WidgetAreaEditor.css');
Requirements::javascript(CMS_DIR . '/javascript/WidgetAreaEditor.js');
@@ -26,7 +30,7 @@ function AvailableWidgets() {
function UsedWidgets() {
$relationName = $this->name;
- $widgets = $this->form->getRecord()->getComponent($relationName)->Widgets();
+ $widgets = $this->form->getRecord()->getComponent($relationName)->Items();
return $widgets;
}
@@ -48,7 +52,7 @@ function saveInto(DataObject $record) {
$record->$idName = $widgetarea->ID;
- $widgets = $widgetarea->Widgets();
+ $widgets = $widgetarea->Items();
// store the field IDs and delete the missing fields
// alternatively, we could delete all the fields and re add them
View
13 javascript/WidgetAreaEditor.js
@@ -160,6 +160,10 @@ WidgetAreaEditorClass.prototype = {
$('usedWidgets-'+this.name).parentNode.parentNode.rewriteWidgetAreaAttributes();
UsedWidget.applyToChildren($('usedWidgets-'+this.name), 'div.Widget');
+ // Repply some common form controls
+ WidgetTreeDropdownField.applyTo('div.usedWidgets .TreeDropdownField');
+
+
Sortable.create('usedWidgets-SideBar', {
tag: 'div',
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
var wAs = $$('.WidgetAreaEditor');
for(var i = 0; i < wAs.length; i++) {
View
2 templates/WidgetAreaEditor.ss
@@ -17,7 +17,7 @@
</div>
<div class="usedWidgetsHolder">
<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">
<% if UsedWidgets %>

0 comments on commit c14e7df

Please sign in to comment.