From 087354f30b4bb889412d5a2905d94d5bc2b0cb0b Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 15 Mar 2019 16:02:36 +0100 Subject: [PATCH] wip #2628 @2 --- .env | 2 +- .env.production | 2 +- app/PageTemplates.php | 91 -------- app/Templates/Aboutus.php | 36 +++ app/Templates/Base.php | 20 ++ app/Templates/Home.php | 36 +++ app/Templates/Services.php | 28 +++ composer.lock | 86 ++++++- config/backpack/pagemanager.php | 4 +- ...15_09_07_190535_create_languages_table.php | 36 +++ ...015_09_10_124414_alter_languages_table.php | 32 +++ .../{about_us.blade.php => aboutus.blade.php} | 0 .../crud/fields/select2_from_ajax.blade.php | 209 ++++++++++++++++++ .../select2_from_ajax_multiple.blade.php | 131 +++++++++++ 14 files changed, 607 insertions(+), 106 deletions(-) create mode 100644 app/Templates/Aboutus.php create mode 100644 app/Templates/Base.php create mode 100644 app/Templates/Home.php create mode 100644 app/Templates/Services.php create mode 100644 database/migrations/2015_09_07_190535_create_languages_table.php create mode 100644 database/migrations/2015_09_10_124414_alter_languages_table.php rename resources/views/pages/{about_us.blade.php => aboutus.blade.php} (100%) create mode 100644 resources/views/vendor/backpack/crud/fields/select2_from_ajax.blade.php create mode 100644 resources/views/vendor/backpack/crud/fields/select2_from_ajax_multiple.blade.php diff --git a/.env b/.env index b38e991..daa3787 100644 --- a/.env +++ b/.env @@ -2,7 +2,7 @@ APP_NAME=PMI APP_ENV=dev APP_KEY=base64:/Jmlg7TepI/inQ4KJ3VF0YVTqghRGvvBrnDI7NkUk94= APP_DEBUG=true -APP_URL=https://dev.pmi.cubedesigners.com +APP_URL=https://pmi.dev.cubedesigners.com APP_LOG=daily diff --git a/.env.production b/.env.production index 7e23397..bd70f01 100644 --- a/.env.production +++ b/.env.production @@ -2,7 +2,7 @@ APP_NAME=PMI APP_ENV=production APP_KEY=base64:/Jmlg7TepI/inQ4KJ3VF0YVTqghRGvvBrnDI7NkUk94= APP_DEBUG=true -APP_URL=https://dev.pmi.cubedesigners.com +APP_URL=https://pmi.dev.cubedesigners.com LOG_CHANNEL=stack diff --git a/app/PageTemplates.php b/app/PageTemplates.php index 0bf392c..18e96c0 100644 --- a/app/PageTemplates.php +++ b/app/PageTemplates.php @@ -20,96 +20,5 @@ trait PageTemplates | - page slug */ - protected function _common() - { - $this->crud->addField([ - 'name' => 'status', - 'type' => 'select_from_array', - 'default' => '0', - 'label' => __('Status'), - 'options' => ['0' => __('Offline'),'1' => __('Published')], - 'fake' => true, - 'store_in' => 'extras', - ]); - $this->_seo(); - } - - protected function _seo() - { - $this->crud->addField([ // CustomHTML - 'name' => 'metas_separator', - 'type' => 'custom_html', - 'value' => '

' . trans('SEO') . '


', - 'tab' => 'Meta // SEO' - ]); - $this->crud->addField([ - 'name' => 'meta_title', - 'label' => trans('backpack::pagemanager.meta_title'), - 'type' => 'text', - 'fake' => true, - 'hint' => trans('If empty, page title is used.') . ' ' . __('Recommended length: 60 chars'), - 'store_in' => 'extras', - 'tab' => 'Meta // SEO', - ]); - $this->crud->addField([ - 'name' => 'meta_description', - 'label' => trans('backpack::pagemanager.meta_description'), - 'type' => 'textarea', - 'fake' => true, - 'store_in' => 'extras', - 'hint' => __('Recommended length: 160 chars'), - 'tab' => 'Meta // SEO', - ]); - $this->crud->addField([ - 'name' => 'robots', - 'label' => __('Allow page index by search engines'), - 'type' => 'checkbox', - 'default' => true, - 'fake' => true, - 'store_in' => 'extras', - 'tab' => 'Meta // SEO', - ]); - } - - private function home() - { - $this->_common(); - - $this->crud->addField([ - 'name' => 'slideshow', - 'type' => 'list_model', - 'model' => 'slideshow', - 'label' => __('Slideshow'), - 'fake' => true, - 'store_in' => 'extras', - ]); - } - - private function services() - { - $this->_common(); - $this->crud->addField([ // CustomHTML - 'name' => 'content_separator', - 'type' => 'custom_html', - 'value' => '

' . trans('backpack::pagemanager.content') . '


', - ]); - $this->crud->addField([ - 'name' => 'content', - 'label' => trans('backpack::pagemanager.content'), - 'type' => 'simplemde', - 'placeholder' => trans('backpack::pagemanager.content_placeholder'), - ]); - } - - private function about_us() - { - $this->_common(); - $this->crud->addField([ - 'name' => 'content', - 'label' => trans('backpack::pagemanager.content'), - 'type' => 'simplemde', - 'placeholder' => trans('backpack::pagemanager.content_placeholder'), - ]); - } } diff --git a/app/Templates/Aboutus.php b/app/Templates/Aboutus.php new file mode 100644 index 0000000..5406dd5 --- /dev/null +++ b/app/Templates/Aboutus.php @@ -0,0 +1,36 @@ +addField([ + 'name' => 'content', + 'label' => trans('backpack::pagemanager.content'), + 'type' => 'simplemde', + 'placeholder' => trans('backpack::pagemanager.content_placeholder'), + ]); + } + + +} diff --git a/app/Templates/Base.php b/app/Templates/Base.php new file mode 100644 index 0000000..b8332af --- /dev/null +++ b/app/Templates/Base.php @@ -0,0 +1,20 @@ +addField([ + 'name' => 'slideshow', + 'type' => 'list_model', + 'model' => 'slideshow', + 'label' => __('Slideshow'), + ]); + } +} diff --git a/app/Templates/Services.php b/app/Templates/Services.php new file mode 100644 index 0000000..bbaa2b8 --- /dev/null +++ b/app/Templates/Services.php @@ -0,0 +1,28 @@ +=7.1.3", - "predis/predis": "^1.1" + "predis/predis": "^1.1", + "webfactor/laravel-backpack-instant-fields": "^2.1.2" }, "require-dev": { "backpack/generators": "^1.2" @@ -1132,7 +1133,7 @@ } ], "description": "Cubist Backpack extension", - "time": "2019-03-12T17:54:05+00:00" + "time": "2019-03-15T15:00:31+00:00" }, { "name": "cubist/cms-front", @@ -5855,6 +5856,69 @@ ], "time": "2019-03-06T09:39:45+00:00" }, + { + "name": "webfactor/laravel-backpack-instant-fields", + "version": "2.1.2", + "source": { + "type": "git", + "url": "https://github.com/webfactor/laravel-backpack-instant-fields.git", + "reference": "58c12ed666917e21d8a2e7e226eccd70daa3dc1d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webfactor/laravel-backpack-instant-fields/zipball/58c12ed666917e21d8a2e7e226eccd70daa3dc1d", + "reference": "58c12ed666917e21d8a2e7e226eccd70daa3dc1d", + "shasum": "" + }, + "require": { + "illuminate/database": "~5.5.0|~5.6.0|~5.7.0|~5.8.0", + "illuminate/support": "~5.5.0|~5.6.0|~5.7.0|~5.8.0", + "php": "~7.1" + }, + "require-dev": { + "phpunit/phpunit": "~6.0", + "squizlabs/php_codesniffer": "^2.3" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Webfactor\\Laravel\\Backpack\\InstantFields\\InstantFieldsServiceProvider" + ] + }, + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Webfactor\\Laravel\\Backpack\\InstantFields\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Thomas Swonke", + "email": "thomas.swonke@webfactor.de", + "homepage": "http://webfactor.de", + "role": "Developer" + } + ], + "description": "Instant fields to create/edit/delete related entities on the fly in Laravel Backpack", + "homepage": "https://github.com/webfactor/laravel-backpack-instant-fields", + "keywords": [ + "Webfactor", + "backpack", + "instant fields", + "laravel", + "modal", + "on-the-fly" + ], + "time": "2019-03-06T13:42:05+00:00" + }, { "name": "zendframework/zend-filter", "version": "2.9.1", diff --git a/config/backpack/pagemanager.php b/config/backpack/pagemanager.php index 39c7189..96639e2 100644 --- a/config/backpack/pagemanager.php +++ b/config/backpack/pagemanager.php @@ -2,8 +2,8 @@ return [ // Change this class if you wish to extend PageCrudController - 'admin_controller_class' => 'Backpack\PageManager\app\Http\Controllers\Admin\PageCrudController', + 'admin_controller_class' => 'Cubist\Backpack\app\Http\Controllers\CubistPageCrudController', // Change this class if you wish to extend the Page model - 'page_model_class' => 'Backpack\PageManager\app\Models\Page', + 'page_model_class' => 'Backpack\PageManager\app\Models\Page', ]; diff --git a/database/migrations/2015_09_07_190535_create_languages_table.php b/database/migrations/2015_09_07_190535_create_languages_table.php new file mode 100644 index 0000000..afd376c --- /dev/null +++ b/database/migrations/2015_09_07_190535_create_languages_table.php @@ -0,0 +1,36 @@ +increments('id'); + $table->string('name', 100); + $table->string('flag', 100)->nullable(); + $table->string('abbr', 3); + $table->tinyInteger('active')->unsigned()->default('1'); + $table->tinyInteger('default')->unsigned()->default('0'); + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('languages'); + } +} diff --git a/database/migrations/2015_09_10_124414_alter_languages_table.php b/database/migrations/2015_09_10_124414_alter_languages_table.php new file mode 100644 index 0000000..f2980fd --- /dev/null +++ b/database/migrations/2015_09_10_124414_alter_languages_table.php @@ -0,0 +1,32 @@ +string('script', 20)->nullable()->after('abbr'); + $table->string('native', 20)->nullable()->after('script'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('languages', function ($table) { + $table->dropColumn('script'); + $table->dropColumn('native'); + }); + } +} diff --git a/resources/views/pages/about_us.blade.php b/resources/views/pages/aboutus.blade.php similarity index 100% rename from resources/views/pages/about_us.blade.php rename to resources/views/pages/aboutus.blade.php diff --git a/resources/views/vendor/backpack/crud/fields/select2_from_ajax.blade.php b/resources/views/vendor/backpack/crud/fields/select2_from_ajax.blade.php new file mode 100644 index 0000000..5429079 --- /dev/null +++ b/resources/views/vendor/backpack/crud/fields/select2_from_ajax.blade.php @@ -0,0 +1,209 @@ + +@php + $connected_entity = new $field['model']; + $connected_entity_key_name = $connected_entity->getKeyName(); + $old_value = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? false; +@endphp + +
+ + model; ?> + +
+ + + @if ($field['on_the_fly']['create'] ?? true) + @include('webfactor::fields.inc.button-add') + @endif + + @if ($field['on_the_fly']['edit'] ?? true) + @include('webfactor::fields.inc.button-edit') + @endif + + @if ($field['on_the_fly']['delete'] ?? true) + @include('webfactor::fields.inc.button-delete') + @endif +
+ + {{-- HINT --}} + @if (isset($field['hint'])) +

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

+ @endif +
+ + +{{-- ########################################## --}} +{{-- 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') + + + + {{-- allow clear --}} + @if ($entity_model::isColumnNullable($field['name'])) + + @endif + @endpush + + {{-- FIELD JS - will be loaded in the after_scripts section --}} + @push('crud_fields_scripts') + + + @endpush + +@endif + + +@push('crud_fields_scripts') + +@endpush +{{-- End of Extra CSS and JS --}} +{{-- ########################################## --}} diff --git a/resources/views/vendor/backpack/crud/fields/select2_from_ajax_multiple.blade.php b/resources/views/vendor/backpack/crud/fields/select2_from_ajax_multiple.blade.php new file mode 100644 index 0000000..f08984d --- /dev/null +++ b/resources/views/vendor/backpack/crud/fields/select2_from_ajax_multiple.blade.php @@ -0,0 +1,131 @@ + +@php + $connected_entity = new $field['model']; + $connected_entity_key_name = $connected_entity->getKeyName(); + $old_value = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? false; +@endphp + +
+ + +
+ + + @if (isset($field['on_the_fly'])) + @include('webfactor::fields.inc.button-add') + @endif +
+ + {{-- HINT --}} + @if (isset($field['hint'])) +

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

+ @endif +
+ + +{{-- ########################################## --}} +{{-- 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') + + + + @endpush + + {{-- FIELD JS - will be loaded in the after_scripts section --}} + @push('crud_fields_scripts') + + + @endpush + +@endif + + +@push('crud_fields_scripts') + +@endpush +{{-- End of Extra CSS and JS --}} +{{-- ########################################## --}} -- 2.39.5