mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Moving Requirements for TableField, TableListField, ComplexTableField, ScaffoldComplexTableField and HasManyComplexTableField from __construct() into FieldHolder() and renderWith(), which means inclusion closer to render time, and less side-effects by a previous Requirements::clear(), e.g. in a CTF popup
ENHANCEMENT Removed constructor overloading in ScaffoldingComplexTableField, was reconstrcuting its own Requirements (with lots of unnecessary jQuery plugins) which should really be done by the individual form fields and the parent popup class git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@74919 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
a869951638
commit
9999f8edd8
@ -197,14 +197,6 @@ class ComplexTableField extends TableListField {
|
||||
$this->detailFormFields = $detailFormFields;
|
||||
$this->controller = $controller;
|
||||
$this->pageSize = 10;
|
||||
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/greybox/AmiJS.js");
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/greybox/greybox.js");
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableListField.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField.js");
|
||||
Requirements::css(THIRDPARTY_DIR . "/greybox/greybox.css");
|
||||
Requirements::css(SAPPHIRE_DIR . "/css/ComplexTableField.css");
|
||||
|
||||
parent::__construct($name, $sourceClass, $fieldList, $sourceFilter, $sourceSort, $sourceJoin);
|
||||
|
||||
@ -243,6 +235,15 @@ class ComplexTableField extends TableListField {
|
||||
* @return String
|
||||
*/
|
||||
function FieldHolder() {
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/greybox/AmiJS.js");
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/greybox/greybox.js");
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableListField.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField.js");
|
||||
Requirements::css(THIRDPARTY_DIR . "/greybox/greybox.css");
|
||||
Requirements::css(SAPPHIRE_DIR . "/css/TableListField.css");
|
||||
Requirements::css(SAPPHIRE_DIR . "/css/ComplexTableField.css");
|
||||
|
||||
// set caption if required
|
||||
if($this->popupCaption) {
|
||||
$id = $this->id();
|
||||
@ -946,12 +947,30 @@ class ComplexTableField_Popup extends Form {
|
||||
|
||||
function __construct($controller, $name, $fields, $validator, $readonly, $dataObject) {
|
||||
$this->dataObject = $dataObject;
|
||||
|
||||
Requirements::clear();
|
||||
|
||||
$actions = new FieldSet();
|
||||
if(!$readonly) {
|
||||
$actions->push(
|
||||
$saveAction = new FormAction(
|
||||
"saveComplexTableField",
|
||||
_t('CMSMain.SAVE')
|
||||
)
|
||||
);
|
||||
$saveAction->addExtraClass('save');
|
||||
}
|
||||
|
||||
parent::__construct($controller, $name, $fields, $actions, $validator);
|
||||
}
|
||||
|
||||
function forTemplate() {
|
||||
$ret = parent::forTemplate();
|
||||
|
||||
/**
|
||||
* WARNING: DO NOT CHANGE THE ORDER OF THESE JS FILES
|
||||
* Some have special requirements.
|
||||
*/
|
||||
Requirements::clear();
|
||||
Requirements::css(SAPPHIRE_DIR . '/css/Form.css');
|
||||
Requirements::css(SAPPHIRE_DIR . '/css/ComplexTableField_popup.css');
|
||||
Requirements::css(CMS_DIR . '/css/typography.css');
|
||||
@ -969,22 +988,7 @@ class ComplexTableField_Popup extends Form {
|
||||
$this->dataObject->getRequirementsForPopup();
|
||||
}
|
||||
|
||||
$actions = new FieldSet();
|
||||
if(!$readonly) {
|
||||
$actions->push(
|
||||
$saveAction = new FormAction(
|
||||
"saveComplexTableField",
|
||||
_t('CMSMain.SAVE')
|
||||
)
|
||||
);
|
||||
$saveAction->addExtraClass('save');
|
||||
}
|
||||
|
||||
parent::__construct($controller, $name, $fields, $actions, $validator);
|
||||
}
|
||||
|
||||
function FieldHolder() {
|
||||
return $this->renderWith('ComplexTableField_Form');
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,11 +22,6 @@ class HasManyComplexTableField extends ComplexTableField {
|
||||
|
||||
function __construct($controller, $name, $sourceClass, $fieldList, $detailFormFields = null, $sourceFilter = "", $sourceSort = "", $sourceJoin = "") {
|
||||
parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
|
||||
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/HasManyFileField.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/RelationComplexTableField.js');
|
||||
Requirements::css(SAPPHIRE_DIR . '/css/HasManyFileField.css');
|
||||
|
||||
$this->Markable = true;
|
||||
|
||||
@ -39,6 +34,17 @@ class HasManyComplexTableField extends ComplexTableField {
|
||||
|
||||
}
|
||||
|
||||
function FieldHolder() {
|
||||
$ret = parent::FieldHolder();
|
||||
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/HasManyFileField.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/RelationComplexTableField.js');
|
||||
Requirements::css(SAPPHIRE_DIR . '/css/HasManyFileField.css');
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to determine the DataObject that this field is built on top of
|
||||
*/
|
||||
|
@ -16,44 +16,6 @@ class ScaffoldingComplexTableField_Popup extends Form {
|
||||
function __construct($controller, $name, $fields, $validator, $readonly, $dataObject) {
|
||||
$this->dataObject = $dataObject;
|
||||
|
||||
/**
|
||||
* WARNING: DO NOT CHANGE THE ORDER OF THESE JS FILES
|
||||
* Some have special requirements.
|
||||
*/
|
||||
//Requirements::css(CMS_DIR . 'css/layout.css');
|
||||
Requirements::css(SAPPHIRE_DIR . '/css/Form.css');
|
||||
Requirements::css(SAPPHIRE_DIR . '/css/ComplexTableField_popup.css');
|
||||
Requirements::css(CMS_DIR . '/css/typography.css');
|
||||
Requirements::css(CMS_DIR . '/css/cms_right.css');
|
||||
Requirements::css(THIRDPARTY_DIR . '/jquery/plugins/autocomplete/jquery.ui.autocomplete.css');
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/prototype.js");
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js");
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/prototype_improvements.js");
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/scriptaculous.js");
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/controls.js");
|
||||
Requirements::javascript(THIRDPARTY_DIR . "/layout_helpers.js");
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain.js");
|
||||
Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain_right.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/TableField.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField.js");
|
||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField_popup.js");
|
||||
// jQuery requirements (how many of these are actually needed?)
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery_improvements.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/livequery/jquery.livequery.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/ui/ui.core.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/ui/ui.tabs.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/form/jquery.form.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/dimensions/jquery.dimensions.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/autocomplete/jquery.ui.autocomplete.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/ScaffoldComplexTableField.js');
|
||||
Requirements::javascript(CMS_DIR . '/javascript/ModelAdmin.js');
|
||||
|
||||
if($this->dataObject->hasMethod('getRequirementsForPopup')) {
|
||||
$this->dataObject->getRequirementsForPopup();
|
||||
}
|
||||
|
||||
$actions = new FieldSet();
|
||||
if(!$readonly) {
|
||||
$actions->push(
|
||||
@ -66,11 +28,6 @@ class ScaffoldingComplexTableField_Popup extends Form {
|
||||
|
||||
parent::__construct($controller, $name, $fields, $actions, $validator);
|
||||
}
|
||||
|
||||
function FieldHolder() {
|
||||
return $this->renderWith('ComplexTableField_Form');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle a generic action passed in by the URL mapping.
|
||||
|
@ -113,9 +113,6 @@ class TableField extends TableListField {
|
||||
$sourceFilter = "`$filterField` = '" . Convert::raw2sql($sourceFilter) . "'";
|
||||
}
|
||||
parent::__construct($name, $sourceClass, $fieldList, $sourceFilter, $sourceSort, $sourceJoin);
|
||||
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableField.js');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -475,6 +472,15 @@ class TableField extends TableListField {
|
||||
* Sets the template to be rendered with
|
||||
*/
|
||||
function FieldHolder() {
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/prototype.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/prototype_improvements.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js');
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableListField.js');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableField.js');
|
||||
Requirements::css(SAPPHIRE_DIR . '/css/TableListField.css');
|
||||
|
||||
return $this->renderWith($this->template);
|
||||
}
|
||||
|
||||
|
@ -242,14 +242,6 @@ class TableListField extends FormField {
|
||||
$this->readOnly = false;
|
||||
|
||||
parent::__construct($name);
|
||||
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/prototype.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/prototype_improvements.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js');
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableListField.js');
|
||||
Requirements::css(SAPPHIRE_DIR . '/css/TableListField.css');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -277,6 +269,13 @@ class TableListField extends FormField {
|
||||
}
|
||||
|
||||
function FieldHolder() {
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/prototype.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/prototype_improvements.js');
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js');
|
||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableListField.js');
|
||||
Requirements::css(SAPPHIRE_DIR . '/css/TableListField.css');
|
||||
|
||||
if($this->clickAction) {
|
||||
$id = $this->id();
|
||||
|
Loading…
Reference in New Issue
Block a user