]> _ Git - cubist_cms-back.git/commitdiff
#2843
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 25 Jun 2019 09:47:52 +0000 (11:47 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 25 Jun 2019 09:47:52 +0000 (11:47 +0200)
composer.json
src/app/Magic/Fields/BunchOfFieldsMultiple.php [new file with mode: 0644]
src/app/Magic/Models/CMSPage.php
src/app/Magic/Models/Settings.php [new file with mode: 0644]
src/resources/views/fields/bunch.blade.php
src/resources/views/fields/bunch_multiple.blade.php [new file with mode: 0644]

index ea26ef5c94408646be286bcae3dec9b9b0e01f9e..bc6a4b70070110e7fbb03e9bd25f27b513630424 100644 (file)
         "backpack/menucrud": "^1.0",
         "backpack/newscrud": "^2.1",
         "backpack/permissionmanager": "^4.0",
-        "backpack/settings": "^2.1",
         "backpack/langfilemanager": "^1.0",
         "cubist/cms-front": "dev-master",
-        "barryvdh/laravel-elfinder": "^0.4.1",
         "cubist/util": "dev-master",
         "fideloper/proxy": "^4.0",
         "predis/predis": "^1.1",
-        "webfactor/laravel-backpack-instant-fields": "^2.3.1",
-        "webfactor/laravel-backpack-nestedmodels": "^1.0.1@dev",
         "spatie/laravel-translatable": "^4.1",
         "venturecraft/revisionable": "^1.30",
         "gaspertrix/laravel-backpack-dropzone-field": "^1.0"
diff --git a/src/app/Magic/Fields/BunchOfFieldsMultiple.php b/src/app/Magic/Fields/BunchOfFieldsMultiple.php
new file mode 100644 (file)
index 0000000..fd0c188
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+
+
+namespace Cubist\Backpack\app\Magic\Fields;
+
+use Cubist\Backpack\CubistBackpackServiceProvider;
+
+class BunchOfFieldsMultiple extends BunchOfFields
+{
+    use \Cubist\Backpack\app\Magic\BunchOfFields;
+
+    protected $_adminType = 'bunch_multiple';
+    protected $_cast = 'array';
+    protected $_viewNamespace = CubistBackpackServiceProvider::NAMESPACE . '::fields';
+
+    public function getDefaultAttributes()
+    {
+        return array_merge(parent::getDefaultAttributes(), ['bunch' => []]);
+    }
+
+    public function _postSetAttributes()
+    {
+        parent::_postSetAttributes();
+        $this->_setBunchOfFields();
+    }
+
+    protected function _setBunchOfFields()
+    {
+        $bunch = $this->getAttribute('bunch');
+        if (is_array($bunch)) {
+            foreach ($bunch as $item) {
+                if (is_array($item)) {
+                    $f = Field::getInstance($item);
+                } else if ($item instanceof Field) {
+                    $f = $item;
+                }
+            }
+            $this->_fields[$f->getAttribute('name')] = $f;
+        }
+        if (is_string($bunch)) {
+            if (class_exists($bunch)) {
+                $bunchInstance = new $bunch();
+                if (method_exists($bunchInstance, 'getFields')) {
+                    $this->_fields = $bunchInstance->getFields();
+                }
+            }
+        }
+
+        $crudfields = [];
+        foreach ($this->_fields as $field) {
+            $name = $field->getAttribute('name');
+            $e = explode('[', $name);
+            $main = array_shift($e);
+            $name = $this->getAttribute('name') . '___' . $main;
+            foreach ($e as $item) {
+                $name .= '___' . $item;
+            }
+            $field->setAttribute('name', $name);
+            $crudfields[$name] = $field->getDefinition();
+        }
+        $this->setAttribute('bunchfields', $crudfields);
+    }
+}
index b3ed9eacd8c747819b62de0470f474af4071691b..f93660a59658085038586642b4185073bfd6ad46 100644 (file)
@@ -10,7 +10,7 @@ class CMSPage extends CubistMagicModel
 {
     protected static $_templates = [];
 
-    protected $table = 'cms_pages';
+    protected $table = 'cubist_cms_pages';
 
     protected $_options = ['name' => 'page',
         'singular' => 'page',
diff --git a/src/app/Magic/Models/Settings.php b/src/app/Magic/Models/Settings.php
new file mode 100644 (file)
index 0000000..5ce9d54
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+
+namespace Cubist\Backpack\app\Magic\Models;
+
+
+class Settings
+{
+    protected $table = 'cubist_settings';
+}
index 4bd23aa6b2bf382ad29c370b203af7ce0b16e302..5cb7872d74b74501a045ff959834e92eedad33f9 100644 (file)
@@ -50,7 +50,7 @@ foreach ($value as $k => $v) {
         <style type="text/css">
 
             .bunch__margin {
-                margin: 0;
+                margin: 15px 0;
             }
 
             .bunch__wrapper {
diff --git a/src/resources/views/fields/bunch_multiple.blade.php b/src/resources/views/fields/bunch_multiple.blade.php
new file mode 100644 (file)
index 0000000..3d2d063
--- /dev/null
@@ -0,0 +1,82 @@
+<!-- Bunch -->
+
+<?php
+$empty = [];
+$value = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? $empty;
+if ($value == '') {
+    $value = $empty;
+}
+
+if (!is_string($value)) {
+    $value = json_encode($value);
+}
+
+$unique = 'bunchmultiple_' . rand(1, 100000);
+
+?>
+<div class="bunchmultiple__margin col-xs-12" id="{!! $unique !!}" data-values="{!! $value !!}">
+    <div class="bunchmultiple__wrapper col-xs-12">
+        <div @include('crud::inc.field_wrapper_attributes') >
+            <label>{!! $field['label'] !!}</label>
+            @include('crud::inc.field_translatable_icon')
+            <div class="clearfix"></div>
+
+            <div class="sample">
+                @include('cubist_back::inc.show_bunch_fields', array('bunchfields'=>$field['bunchfields']))
+            </div>
+
+            <div class="clearfix"></div>
+
+            {{-- HINT --}}
+            @if (isset($field['hint']))
+                <p class="help-block">{!! $field['hint'] !!}</p>
+            @endif
+        </div>
+    </div>
+</div>
+
+
+{{-- ########################################## --}}
+{{-- Extra CSS and JS for this particular field --}}
+{{-- If a field type is shown multiple times on a form, the CSS and JS will only be loaded once --}}
+@if ($crud->checkIfFieldIsFirstOfItsType($field))
+
+    {{-- FIELD CSS - will be loaded in the after_styles section --}}
+    @push('crud_fields_styles')
+        <style type="text/css">
+
+            .bunch__margin {
+                margin: 15px 0;
+            }
+
+            .bunch__wrapper {
+                padding: 15px;
+                border: 1px solid #eee;
+                background: #fafafa;
+                margin-bottom: 15px;
+            }
+
+            .bunch__wrapper .form-group {
+                padding: 0;
+            }
+
+            .bunch__wrapper > .form-group > label {
+                font-size: 1.2em;
+                margin-bottom: 24px;
+            }
+        </style>
+    @endpush
+
+    {{-- FIELD JS - will be loaded in the after_scripts section --}}
+    @push('crud_fields_scripts')
+        <script>
+            jQuery(document).ready(function ($) {
+
+
+            });
+        </script>
+    @endpush
+
+@endif
+{{-- End of Extra CSS and JS --}}
+{{-- ########################################## --}}