BladeX::component('components.cart-add')->tag('cart-add'); // <cart-add id="1234"> ... </cart-add>
BladeX::component('components.news-grid'); // <news-grid :items="$news"> ... </news-grid>
BladeX::component('components.news-item'); // <news-item :item="$newsItem"> ... </news-item>
+ BladeX::component('components.news-item-array'); // <news-item-array :item="$newsItem"> ... </news-item-array>
BladeX::component('components.address-form'); // <address-form> ... </address-form>
BladeX::component('components.modal-confirm'); // <modal-confirm> ... </modal-confirm>
BladeX::component('components.btn-delete'); // <btn-delete> ... </btn-delete>
--- /dev/null
+<?php
+
+namespace App\SubForms;
+
+
+use App\Models\Application;
+use App\Models\Page;
+use App\Models\Product;
+use App\Models\News as N;
+use Cubist\Backpack\app\Magic\Menu\Menu;
+use Cubist\Backpack\app\Magic\Models\CMSPage;
+use Cubist\Backpack\app\Magic\SubForm;
+use Cubist\Backpack\Magic\Fields\SelectFromArray;
+use Illuminate\Support\Facades\DB;
+
+class News extends SubForm
+{
+ public function init()
+ {
+ parent::init();
+
+ $this->addField(['name' => 'title',
+ 'label' => 'Titre',
+ 'type' => 'Text']);
+
+ $this->addField(['name' => 'text',
+ 'label' => 'Texte',
+ 'type' => 'Textarea',
+ 'attributes' => [
+ 'rows' => 10,
+ ]]);
+
+ $this->addField(['name' => 'image',
+ 'label' => 'Image',
+ 'type' => 'Images']);
+
+ $this->addField(['name' => 'date',
+ 'label' => 'Date',
+ 'column' => true,
+ 'type' => 'Text']);
+
+ $this->addField(['name' => 'page_product',
+ 'label' => 'Page produit',
+ 'type' => 'SelectFromArray',
+ 'options' => self::products(),
+ 'multiple' => false,
+ 'default' => ''
+ ]);
+
+ $this->addField(['name' => 'page_page',
+ 'label' => 'Page generale',
+ 'type' => 'PageInternal',
+ 'multiple' => false,
+ ]);
+
+ $this->addField(['name' => 'page_news',
+ 'label' => 'Page actualités',
+ 'type' => 'SelectFromArray',
+ 'options' => self::news(),
+ 'multiple' => false,
+ ]);
+ }
+
+ public function news() {
+ return DB::table('cubist_news')->pluck('title->fr AS title','id');
+ }
+
+ public function products() {
+ return DB::table('catalog_products')->pluck('name->fr AS name','id');
+ }
+}
use App\Models\Application;
use App\Models\News;
+use Cubist\Backpack\app\Magic\Menu\Menu;
use Cubist\Backpack\app\Magic\PageData;
class OurSolutions extends Base
'edit_label'=>"%title",
'tab' => 'Nos solutions']);
+ $this->addField(['name' => 'news_title',
+ 'label' => 'Titre',
+ 'type' => 'text',
+ 'tab' => 'Actualités']);
+
+ $this->addField(['name' => 'news_items',
+ 'label' => 'Actualités',
+ 'type' => 'BunchOfFieldsMultiple',
+ 'bunch' => 'App\SubForms\News',
+ 'edit_label'=> "%title",
+ 'tab' => 'Actualités']);
+
$this->addField(['name' => 'faqs',
'label' => 'FAQs',
'type' => 'BunchOfFieldsMultiple',
{
// Latest News posts
$data['news'] = News::getPosts(4);
+
+ $data['prefix'] = '';
}
}
//
//&.half
// flex: 0 1 48%
+
+#product-field-wrapper
+ display: none
@php
+ $array = $array ?? '';
$items = $items ?? [];
$id = $id ?? '';
$extraClass = $extraClass ?? '';
@endphp
<grid cols="4" gap="lg" :class="$class" :id="$id">
+ @dump($items)
@foreach ($items as $newsItem)
- <news-item :item="$newsItem" />
+ @if($array)
+ @dump('ok')
+ <news-item-array :item="$newsItem" />
+ @else
+ @dump('pas ok')
+ <news-item :item="$newsItem" />
+ @endif
@endforeach
</grid>
--- /dev/null
+<article>
+
+ <a href="{{ $item['page'] }}" class="news-index-article-image block bg-grey-100">
+ {{ $page->getImageURLbyCollection($item['image']) }}
+ </a>
+
+ <div class="news-index-article-text">
+ <time datetime="{{ $item['date'] }}"
+ class="block font-display font-medium text-navy mt-6 mb-2">
+ {{ $item['date'] }}
+ </time>
+ <h4 class="text-2xl sm:text-xl">
+ <a class="text-navy" href="{{ $item['page'] }}">
+ {{ $item['title'] }}
+ </a>
+ </h4>
+ <p>{{ $item['text'] }}</p>
+
+ <p><a href="{{ $item['page'] }}">{{ __("En savoir plus") }}</a></p>
+ </div>
+
+</article>
{{ $item['title'] }}
</h3>
<p>{{ $item['text'] }}</p>
- <a href="{{ $nav->getHrefById($item['page']) }}">{{ __('Découvrir') }}</a>
+ <a href="{{ $nav->getHrefById('product/'.$item['page']) }}">{{ __('Découvrir') }}</a>
</div>
</div>
@endisset
</full-width>
{{-- --}}
- @if(count($news) > 0)
+ @php($news = $page->get('news_items'))
+ @php($title = $page->get('news_title'))
+ @if(!empty($news))
{{-- News --}}
<full-width>
<content>
- <text-block :title="__('Actus Monitoring/IOT')"/>
- <news-grid :items="$news" />
+ <text-block :title="$title"/>
+ <grid cols="4" gap="lg" class="md:grid-cols-2 xs:grid-cols-1 xs:grid-gap-20v">
+ @foreach($news as $item)
+
+ @if(!empty($item['page_product']))
+ @php($prefix = 'product')
+ @elseif(!empty($item['page_page']))
+ @php($prefix = 'page')
+ @elseif(!empty($item['page_news']))
+ @php($prefix = 'news')
+ @endif
+ <article>
+
+ <a href="{{ $nav->getHrefById($prefix.'/'.$item['page_news']) }}" class="news-index-article-image block bg-grey-100">
+ <img src="{{ $page->getImageURLbyCollection($item['image']) }}" />
+ </a>
+
+ <div class="news-index-article-text">
+ <time datetime="{{ $item['date'] }}"
+ class="block font-display font-medium text-navy mt-6 mb-2">
+ {{ $item['date'] }}
+ </time>
+ <h4 class="text-2xl sm:text-xl">
+ <a class="text-navy" href="{{ $nav->getHrefById($prefix.'/'.$item['page_news']) }}">
+ {{ $item['title'] }}
+ </a>
+ </h4>
+ <p>{{ $item['text'] }}</p>
+
+ <p><a href="{{ $nav->getHrefById($prefix.'/'.$item['page_news']) }}">{{ __("En savoir plus") }}</a></p>
+ </div>
+
+ </article>
+ @endforeach
+
+ </grid>
</content>
</full-width>
- @endif
+ @endif
<full-width class="bg-grey-100 antialiased">
<content>
--- /dev/null
+<input type="hidden" name="http_referrer" value={{ old('http_referrer') ?? \URL::previous() ?? url($crud->route) }}>
+
+@if ($crud->model->translationEnabled())
+ <input type="hidden" name="locale" value={{ $crud->request->input('locale')?$crud->request->input('locale'):App::getLocale() }}>
+@endif
+
+{{-- See if we're using tabs --}}
+@if ($crud->tabsEnabled() && count($crud->getTabs()))
+ @include('crud::inc.show_tabbed_fields')
+ <input type="hidden" name="current_tab" value="{{ str_slug($crud->getTabs()[0], "") }}" />
+@else
+ <div class="box col-md-12 padding-10 p-t-20">
+ @include('crud::inc.show_fields', ['fields' => $fields])
+ </div>
+@endif
+
+{{-- Define blade stacks so css and js can be pushed from the fields to these sections. --}}
+
+@section('after_styles')
+ <link rel="stylesheet" href="{{ asset('vendor/backpack/crud/css/crud.css') }}">
+ <link rel="stylesheet" href="{{ asset('vendor/backpack/crud/css/form.css') }}">
+ <link rel="stylesheet" href="{{ asset('vendor/backpack/crud/css/'.$action.'.css') }}">
+
+ <!-- CRUD FORM CONTENT - crud_fields_styles stack -->
+ @stack('crud_fields_styles')
+@endsection
+
+@section('after_scripts')
+ <script src="{{ asset('vendor/backpack/crud/js/crud.js') }}"></script>
+ <script src="{{ asset('vendor/backpack/crud/js/form.js') }}"></script>
+ <script src="{{ asset('vendor/backpack/crud/js/'.$action.'.js') }}"></script>
+
+ <!-- CRUD FORM CONTENT - crud_fields_scripts stack -->
+ @stack('crud_fields_scripts')
+
+ <script>
+ jQuery(document).ready(function($){
+
+ // Save button has multiple actions: save and exit, save and edit, save and new
+ var saveActions = $('#saveActions'),
+ crudForm = saveActions.parents('form'),
+ saveActionField = $('[name="save_action"]');
+
+ saveActions.on('click', '.dropdown-menu a', function(){
+ var saveAction = $(this).data('value');
+ saveActionField.val( saveAction );
+ crudForm.submit();
+ });
+
+ // Ctrl+S and Cmd+S trigger Save button click
+ $(document).keydown(function(e) {
+ if ((e.which == '115' || e.which == '83' ) && (e.ctrlKey || e.metaKey))
+ {
+ e.preventDefault();
+ // alert("Ctrl-s pressed");
+ $("button[type=submit]").trigger('click');
+ return false;
+ }
+ return true;
+ });
+
+ // prevent duplicate entries on double-clicking the submit form
+ crudForm.submit(function (event) {
+ $("button[type=submit]").prop('disabled', true);
+ });
+
+ // Place the focus on the first element in the form
+ @if( $crud->autoFocusOnFirstField )
+ @php
+ $focusField = array_first($fields, function($field) {
+ return isset($field['auto_focus']) && $field['auto_focus'] == true;
+ });
+ @endphp
+
+ @if ($focusField)
+ @php
+ $focusFieldName = !is_iterable($focusField['value']) ? $focusField['name'] : ($focusField['name'] . '[]');
+ @endphp
+ window.focusField = $('[name="{{ $focusFieldName }}"]').eq(0),
+ @else
+ var focusField = $('form').find('input, textarea, select').not('[type="hidden"]').eq(0),
+ @endif
+
+ fieldOffset = focusField.offset().top,
+ scrollTolerance = $(window).height() / 2;
+
+ focusField.trigger('focus');
+
+ if( fieldOffset > scrollTolerance ){
+ $('html, body').animate({scrollTop: (fieldOffset - 30)});
+ }
+ @endif
+
+ // Add inline errors to the DOM
+ @if ($crud->inlineErrorsEnabled() && $errors->any())
+
+ window.errors = {!! json_encode($errors->messages()) !!};
+ // console.error(window.errors);
+
+ $.each(errors, function(property, messages){
+
+ var normalizedProperty = property.split('.').map(function(item, index){
+ return index === 0 ? item : '['+item+']';
+ }).join('');
+
+ var field = $('[name="' + normalizedProperty + '[]"]').length ?
+ $('[name="' + normalizedProperty + '[]"]') :
+ $('[name="' + normalizedProperty + '"]'),
+ container = field.parents('.form-group');
+
+ container.addClass('has-error');
+
+ $.each(messages, function(key, msg){
+ // highlight the input that errored
+ var row = $('<div class="help-block">' + msg + '</div>');
+ row.appendTo(container);
+
+ // highlight its parent tab
+ @if ($crud->tabsEnabled())
+ var tab_id = $(container).parent().attr('id');
+ $("#form_tabs [aria-controls="+tab_id+"]").addClass('text-red');
+ @endif
+ });
+ });
+
+ @endif
+
+ $("a[data-toggle='tab']").click(function(){
+ currentTabName = $(this).attr('tab_name');
+ $("input[name='current_tab']").val(currentTabName);
+ });
+
+ if (window.location.hash) {
+ $("input[name='current_tab']").val(window.location.hash.substr(1));
+ }
+
+ });
+ </script>
+@endsection
+
+@push('after_scripts')
+ <script>
+
+ </script>
+@endpush