Skip to content

Commit

Permalink
MINOR added stubs to allow widgets to use treedropdown fields (from r…
Browse files Browse the repository at this point in the history
…91850)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92471 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
chillu committed Nov 21, 2009
1 parent d6eaea0 commit c14e7df
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
8 changes: 6 additions & 2 deletions code/WidgetAreaEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;
}

Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions javascript/WidgetAreaEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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++) {
Expand Down
2 changes: 1 addition & 1 deletion templates/WidgetAreaEditor.ss
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down

0 comments on commit c14e7df

Please sign in to comment.