mirror of
https://github.com/a2nt/silverstripe-webpack.git
synced 2024-10-22 17:05:31 +02:00
IMPR: Move elements to another page
This commit is contained in:
parent
b87adfa1cc
commit
b2691a7112
@ -34,6 +34,6 @@ $config->setOption(
|
||||
FulltextSearchable::enable();
|
||||
|
||||
// replace embed parser
|
||||
$parser = ShortcodeParser::get('default');
|
||||
/*$parser = ShortcodeParser::get('default');
|
||||
$parser->unregister('embed');
|
||||
$parser->register('embed', [EmbedShortcodeProvider::class, 'handle_shortcode']);
|
||||
$parser->register('embed', [EmbedShortcodeProvider::class, 'handle_shortcode']);*/
|
||||
|
@ -41,6 +41,7 @@ DNADesign\Elemental\Models\BaseElement:
|
||||
default_global_elements: true
|
||||
extensions:
|
||||
#- DNADesign\Elemental\TopPage\DataExtension
|
||||
- App\Elements\Extensions\BaseElementEx
|
||||
- App\Elements\Extensions\ElementRows
|
||||
|
||||
SilverStripe\CMS\Model\SiteTree:
|
||||
|
68
app/src/Elements/Extensions/BaseElementEx.php
Normal file
68
app/src/Elements/Extensions/BaseElementEx.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: tony
|
||||
* Date: 6/23/18
|
||||
* Time: 1:23 PM
|
||||
*/
|
||||
|
||||
namespace App\Elements\Extensions;
|
||||
|
||||
use DNADesign\Elemental\Models\BaseElement;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Forms\TreeDropdownField;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\LiteralField;
|
||||
|
||||
class BaseElementEx extends DataExtension
|
||||
{
|
||||
|
||||
|
||||
public function updateCMSFields(FieldList $fields)
|
||||
{
|
||||
$obj = $this->owner;
|
||||
parent::updateCMSFields($fields);
|
||||
$tab = $fields->findOrMakeTab('Root.Settings');
|
||||
|
||||
$tab->push(LiteralField::create(
|
||||
'ClassName',
|
||||
'<div class="form-group field text">'
|
||||
.'<div class="form__field-label">Class</div>'
|
||||
.'<div class="form__field-holder">'.$obj->getField('ClassName').'</div>'
|
||||
.'</div>'
|
||||
));
|
||||
|
||||
if($this->owner->ID) {
|
||||
$tab->push(TreeDropdownField::create(
|
||||
'MoveElementIDToPage',
|
||||
'Move an element to page',
|
||||
SiteTree::class
|
||||
)->setEmptyString('(select an element to move)'));
|
||||
}
|
||||
}
|
||||
|
||||
public static function MoveElementToPage($ID, $moveToID)
|
||||
{
|
||||
$el = BaseElement::get()->byID($ID);
|
||||
$page = SiteTree::get()->byID($moveToID);
|
||||
if (!$page || !$el) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$el->setField('ParentID', $page->ElementalArea()->ID);
|
||||
$el->write();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onBeforeWrite()
|
||||
{
|
||||
parent::onBeforeWrite();
|
||||
|
||||
$moveID = $this->owner->getField('MoveElementIDToPage');
|
||||
if($this->owner->ID && $moveID) {
|
||||
self::MoveElementToPage($this->owner->ID, $moveID);
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,6 @@ use SilverStripe\Forms\CheckboxField;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\LiteralField;
|
||||
use App\Elements\AccordionElement;
|
||||
|
||||
class ElementRows extends DataExtension
|
||||
@ -127,16 +126,6 @@ class ElementRows extends DataExtension
|
||||
)->setEmptyString('(select an element to move)'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$fields->findOrMakeTab('Root.Settings')
|
||||
->push(LiteralField::create(
|
||||
'ClassName',
|
||||
'<div class="form-group field text">'
|
||||
.'<div class="form__field-label">Class</div>'
|
||||
.'<div class="form__field-holder">'.$obj->getField('ClassName').'</div>'
|
||||
.'</div>'
|
||||
));
|
||||
}
|
||||
|
||||
public function getWidthPercetage()
|
||||
|
@ -28,8 +28,8 @@
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: #1c2947;
|
||||
color: #fff;
|
||||
background: #fff;
|
||||
color: #212529;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
@media (min-width: 2000px) {
|
||||
@ -52,8 +52,8 @@
|
||||
justify-content: center;
|
||||
z-index: 2000;
|
||||
will-change: opacity;
|
||||
background: #1c2947;
|
||||
color: #fff;
|
||||
background: #fff;
|
||||
color: #212529;
|
||||
}
|
||||
#PageLoading .logo {
|
||||
width:100px;
|
||||
|
@ -65,10 +65,9 @@ if (filesystem.existsSync(indexPath)) {
|
||||
NODE_ENV: NODE_ENV,
|
||||
GRAPHQL_URL: conf['GRAPHQL_URL'],
|
||||
STATIC_URL: conf['STATIC_URL'],
|
||||
REACT_SCRIPTS:
|
||||
NODE_ENV === 'production'
|
||||
? '<script crossorigin src="https://unpkg.com/react@17/umd/react.production.min.js"></script><script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script>'
|
||||
: '<script crossorigin src="https://unpkg.com/react@17/umd/react.development.js"></script><script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>',
|
||||
REACT_SCRIPTS: NODE_ENV === 'production' ?
|
||||
'<script crossorigin src="https://unpkg.com/react@17/umd/react.production.min.js"></script><script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script>' :
|
||||
'<script crossorigin src="https://unpkg.com/react@17/umd/react.development.js"></script><script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>',
|
||||
},
|
||||
}),
|
||||
);
|
||||
@ -95,8 +94,7 @@ const config = merge(common, {
|
||||
},
|
||||
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
rules: [{
|
||||
test: /\.jsx?$/,
|
||||
//exclude: /node_modules/,
|
||||
use: {
|
||||
@ -123,8 +121,7 @@ const config = merge(common, {
|
||||
},
|
||||
{
|
||||
test: /\.s?css$/,
|
||||
use: [
|
||||
{
|
||||
use: [{
|
||||
loader: MiniCssExtractPlugin.loader,
|
||||
},
|
||||
{
|
||||
@ -146,24 +143,20 @@ const config = merge(common, {
|
||||
},
|
||||
{
|
||||
test: /fontawesome([^.]+).(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
|
||||
use: [
|
||||
{
|
||||
use: [{
|
||||
loader: 'url-loader',
|
||||
},
|
||||
],
|
||||
}, ],
|
||||
},
|
||||
{
|
||||
test: /\.(gif|png|jpg|jpeg|ttf|otf|eot|svg|webp|woff(2)?)$/,
|
||||
use: [
|
||||
{
|
||||
use: [{
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
name(file) {
|
||||
return 'public/[path][name].[ext]';
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}, ],
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -178,10 +171,6 @@ const config = merge(common, {
|
||||
hot: false,
|
||||
injectClient: conf['injectClient'],
|
||||
|
||||
overlay: {
|
||||
warnings: true,
|
||||
errors: true,
|
||||
},
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Referrer-Policy': 'unsafe-url',
|
||||
|
Loading…
Reference in New Issue
Block a user