From: Vincent Vanwaelscappel Date: Fri, 2 Feb 2024 16:21:24 +0000 (+0100) Subject: wip #6693 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=4291bba8d0781ee1f04f3e21d48671273be2b81d;p=cubist_cms-back.git wip #6693 @2 --- diff --git a/src/app/Magic/Fields/Datetime.php b/src/app/Magic/Fields/Datetime.php index 4278193..4d14b5a 100644 --- a/src/app/Magic/Fields/Datetime.php +++ b/src/app/Magic/Fields/Datetime.php @@ -18,6 +18,8 @@ class Datetime extends Field protected $_columnFormat = 'YYYY-MM-DD HH:mm'; protected $_filterType = 'date_range'; + protected $_translatable=false; + public function _mutator($value) { return \Date::parse($value); diff --git a/src/app/Magic/Fields/GrapePageBuilder.php b/src/app/Magic/Fields/GrapePageBuilder.php new file mode 100644 index 0000000..bb391d9 --- /dev/null +++ b/src/app/Magic/Fields/GrapePageBuilder.php @@ -0,0 +1,11 @@ + 'page', 'plural' => 'pages']; - protected $defaultFieldAttributes = ['translatable' => true]; + //protected $defaultFieldAttributes = ['translatable' => true]; public function setFields() { @@ -83,7 +83,7 @@ class CMSPage extends CubistMagicNestedModel public function onCreating(): bool { $this->useTemplateIfNotSet(request('template')); - return $this->onCreating(); + return parent::onCreating(); } // public function onBeforeEdit($controller, $id) @@ -102,13 +102,13 @@ class CMSPage extends CubistMagicNestedModel public function onSaving(): bool { $this->useTemplateIfNotSet(request('template')); - return $this->onSaving(); + return parent::onSaving(); } public function onUpdating(): bool { $this->useTemplateIfNotSet(request('template')); - return $this->onUpdating(); + return parent::onUpdating(); } @@ -201,7 +201,7 @@ class CMSPage extends CubistMagicNestedModel public function create(array $attributes = []) { if (!isset($attributes['template']) || !$attributes['template']) { - $attributes['template']='unset'; + $attributes['template'] = 'unset'; } $this->useTemplate($attributes['template']); return parent::create($attributes); @@ -210,7 +210,7 @@ class CMSPage extends CubistMagicNestedModel public function update(array $attributes = [], array $options = []) { if (!isset($attributes['template']) || !$attributes['template']) { - $attributes['template']='unset'; + $attributes['template'] = 'unset'; } $this->useTemplate($attributes['template']); return parent::update($attributes, $options); @@ -266,4 +266,5 @@ class CMSPage extends CubistMagicNestedModel } parent::copyTranslations($from, $to, $overwrite); } + } diff --git a/src/app/Magic/Models/CubistMagicAbstractModel.php b/src/app/Magic/Models/CubistMagicAbstractModel.php index d99f613..c1ffece 100644 --- a/src/app/Magic/Models/CubistMagicAbstractModel.php +++ b/src/app/Magic/Models/CubistMagicAbstractModel.php @@ -1143,49 +1143,6 @@ class CubistMagicAbstractModel extends Model implements HasMedia return null; } - public function save(array $options = []) - { - $this->mergeAttributesFromCachedCasts(); - - $query = $this->newModelQuery(); - - // If the "saving" event returns false we'll bail out of the save and return - // false, indicating that the save failed. This provides a chance for any - // listeners to cancel save operations if validations fail or whatever. - if ($this->fireModelEvent('saving') === false) { - return false; - } - - // If the model already exists in the database we can just update our record - // that is already in this database using the current IDs in this "where" - // clause to only update this model. Otherwise, we'll just insert them. - if ($this->exists) { - $saved = $this->isDirty() ? - $this->performUpdate($query) : true; - } - - // If the model is brand new, we'll insert it into our database and set the - // ID attribute on the model to the value of the newly inserted row's ID - // which is typically an auto-increment value managed by the database. - else { - $saved = $this->performInsert($query); - - if (!$this->getConnectionName() && - $connection = $query->getConnection()) { - $this->setConnection($connection->getName()); - } - } - - // If the model is successfully saved, we need to do a few more things once - // that is done. We will call the "saved" method here to run any actions - // we need to happen after a model gets successfully saved right here. - if ($saved) { - $this->finishSave($options); - } - - return $saved; - } - /** * @param $uploadedFile UploadedFile|\SplFileInfo * @param $attribute string diff --git a/src/resources/views/fields/pagebuilder-grapejs.blade.php b/src/resources/views/fields/pagebuilder-grapejs.blade.php new file mode 100644 index 0000000..ae7f809 --- /dev/null +++ b/src/resources/views/fields/pagebuilder-grapejs.blade.php @@ -0,0 +1,55 @@ +@php + + @endphp + + +@include('crud::fields.inc.wrapper_start') + +@include('crud::fields.inc.translatable_icon') + +@push('crud_fields_styles') + @basset('https://unpkg.com/grapesjs/dist/css/grapes.min.css') +@endpush + +@push('crud_fields_scripts') + @basset('https://unpkg.com/grapesjs') +@endpush + +
+ +@bassetBlock('cubist/grapejs-field.js') + +@endBassetBlock + + +{{-- HINT --}} +@if (isset($field['hint'])) +

{!! $field['hint'] !!}

+@endif +@include('crud::fields.inc.wrapper_end') diff --git a/src/resources/views/fields/text.blade.php b/src/resources/views/fields/text.blade.php index cbc1334..1dda42b 100644 --- a/src/resources/views/fields/text.blade.php +++ b/src/resources/views/fields/text.blade.php @@ -18,4 +18,4 @@ @if (isset($field['hint']))

{!! $field['hint'] !!}

@endif - +@include('crud::fields.inc.wrapper_end')