IMPR: Move elements to another page

This commit is contained in:
Tony Air 2021-03-29 14:55:04 +07:00
parent b87adfa1cc
commit b2691a7112
6 changed files with 200 additions and 153 deletions

View File

@ -34,6 +34,6 @@ $config->setOption(
FulltextSearchable::enable(); FulltextSearchable::enable();
// replace embed parser // replace embed parser
$parser = ShortcodeParser::get('default'); /*$parser = ShortcodeParser::get('default');
$parser->unregister('embed'); $parser->unregister('embed');
$parser->register('embed', [EmbedShortcodeProvider::class, 'handle_shortcode']); $parser->register('embed', [EmbedShortcodeProvider::class, 'handle_shortcode']);*/

View File

@ -41,6 +41,7 @@ DNADesign\Elemental\Models\BaseElement:
default_global_elements: true default_global_elements: true
extensions: extensions:
#- DNADesign\Elemental\TopPage\DataExtension #- DNADesign\Elemental\TopPage\DataExtension
- App\Elements\Extensions\BaseElementEx
- App\Elements\Extensions\ElementRows - App\Elements\Extensions\ElementRows
SilverStripe\CMS\Model\SiteTree: SilverStripe\CMS\Model\SiteTree:

View 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);
}
}
}

View File

@ -15,7 +15,6 @@ use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\DropdownField;
use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\DataExtension;
use SilverStripe\Forms\FieldList; use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\LiteralField;
use App\Elements\AccordionElement; use App\Elements\AccordionElement;
class ElementRows extends DataExtension class ElementRows extends DataExtension
@ -127,16 +126,6 @@ class ElementRows extends DataExtension
)->setEmptyString('(select an element to move)')); )->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() public function getWidthPercetage()

View File

@ -28,8 +28,8 @@
font-size: 14px; font-size: 14px;
margin: 0; margin: 0;
padding: 0; padding: 0;
background: #1c2947; background: #fff;
color: #fff; color: #212529;
overflow-x: hidden; overflow-x: hidden;
} }
@media (min-width: 2000px) { @media (min-width: 2000px) {
@ -52,8 +52,8 @@
justify-content: center; justify-content: center;
z-index: 2000; z-index: 2000;
will-change: opacity; will-change: opacity;
background: #1c2947; background: #fff;
color: #fff; color: #212529;
} }
#PageLoading .logo { #PageLoading .logo {
width:100px; width:100px;

View File

@ -65,10 +65,9 @@ if (filesystem.existsSync(indexPath)) {
NODE_ENV: NODE_ENV, NODE_ENV: NODE_ENV,
GRAPHQL_URL: conf['GRAPHQL_URL'], GRAPHQL_URL: conf['GRAPHQL_URL'],
STATIC_URL: conf['STATIC_URL'], STATIC_URL: conf['STATIC_URL'],
REACT_SCRIPTS: REACT_SCRIPTS: NODE_ENV === 'production' ?
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.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>',
: '<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: { module: {
rules: [ rules: [{
{
test: /\.jsx?$/, test: /\.jsx?$/,
//exclude: /node_modules/, //exclude: /node_modules/,
use: { use: {
@ -123,8 +121,7 @@ const config = merge(common, {
}, },
{ {
test: /\.s?css$/, test: /\.s?css$/,
use: [ use: [{
{
loader: MiniCssExtractPlugin.loader, loader: MiniCssExtractPlugin.loader,
}, },
{ {
@ -146,24 +143,20 @@ const config = merge(common, {
}, },
{ {
test: /fontawesome([^.]+).(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/, test: /fontawesome([^.]+).(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
use: [ use: [{
{
loader: 'url-loader', loader: 'url-loader',
}, }, ],
],
}, },
{ {
test: /\.(gif|png|jpg|jpeg|ttf|otf|eot|svg|webp|woff(2)?)$/, test: /\.(gif|png|jpg|jpeg|ttf|otf|eot|svg|webp|woff(2)?)$/,
use: [ use: [{
{
loader: 'file-loader', loader: 'file-loader',
options: { options: {
name(file) { name(file) {
return 'public/[path][name].[ext]'; return 'public/[path][name].[ext]';
}, },
}, },
}, }, ],
],
}, },
], ],
}, },
@ -178,10 +171,6 @@ const config = merge(common, {
hot: false, hot: false,
injectClient: conf['injectClient'], injectClient: conf['injectClient'],
overlay: {
warnings: true,
errors: true,
},
headers: { headers: {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
'Referrer-Policy': 'unsafe-url', 'Referrer-Policy': 'unsafe-url',