From 5a0e1ee7007f79703c8ec92764cf2930a5d890bd Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 10 Dec 2020 20:36:09 +0100 Subject: [PATCH] wip #3753 @4 --- .../ConfirmAssignmentOperation.php | 3 +- app/Models/FluidbookQuote.php | 22 +- app/Models/Quiz.php | 2 +- app/Widgets.php | 4 +- config/backpack/crud.php | 2 +- .../packages/fluidbook/toolbox/css/style.less | 53 +++ .../crud/inc/datatables_logic.blade.php | 331 ++++++++++++++++++ .../views/vendor/backpack/crud/list.blade.php | 173 +++++++++ 8 files changed, 579 insertions(+), 11 deletions(-) create mode 100644 resources/views/vendor/backpack/crud/inc/datatables_logic.blade.php create mode 100644 resources/views/vendor/backpack/crud/list.blade.php diff --git a/app/Http/Controllers/Admin/Operations/FluidbookQuote/ConfirmAssignmentOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookQuote/ConfirmAssignmentOperation.php index 0375ca45e..cd4bed056 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookQuote/ConfirmAssignmentOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookQuote/ConfirmAssignmentOperation.php @@ -33,6 +33,7 @@ trait ConfirmAssignmentOperation } else { Alert::add('error', __('Une erreur s\'est produite.'))->flash(); } - return Redirect::to('/fluidbook-quote'); + + return Redirect::to(session('_previous', ['url' => backpack_url('fluidbook-quote')])['url']); } } diff --git a/app/Models/FluidbookQuote.php b/app/Models/FluidbookQuote.php index 0af3b07c6..0c5289598 100644 --- a/app/Models/FluidbookQuote.php +++ b/app/Models/FluidbookQuote.php @@ -43,7 +43,13 @@ class FluidbookQuote extends CubistMagicAbstractModel $this->addField('links', 'Hidden'); $this->addField('langs', 'Hidden'); - $this->addField('user', 'SelectFromModel', __('Utilisateur'), ['optionsmodel' => User::class, 'attribute' => 'companyWithName', 'column' => true,]); + $this->addField('user', 'SelectFromModel', __('Utilisateur'), + ['optionsmodel' => User::class, + 'attribute' => 'companyWithName', + 'column_attribute' => 'CompanyWithNameOnTwoLines', + 'column' => true, + 'can_write' => 'fluidbook-quote:admin', + ]); $this->addField(['name' => 'created_at', 'label' => __('Date'), @@ -51,7 +57,8 @@ class FluidbookQuote extends CubistMagicAbstractModel 'filter' => true, 'column' => true, 'column_type' => 'date', - 'column_format' => null]); + 'column_format' => null, + 'can_write' => 'fluidbook-quote:admin']); $this->addField('contact_type', 'SelectFromArray', __('Type de client'), ['options' => [ 'agency' => __('Agence de communication'), @@ -60,7 +67,10 @@ class FluidbookQuote extends CubistMagicAbstractModel 'other' => __('Autre'), ]]); - $this->addField('message', 'Textarea', __('Message')); + $this->addField('message', 'Textarea', __('Message'), [ + 'can_write' => 'fluidbook-quote:admin' + ] + ); $this->addField('gclid', 'Text', 'Google Adwords ID (gclid)', ['can' => 'fluidbook-quote:admin',]); @@ -75,9 +85,9 @@ class FluidbookQuote extends CubistMagicAbstractModel $this->addField('status', 'SelectFromArray', __('Status'), ['options' => [ 0 => __('Non traitée'), - 1 => __('En attente de traitement'), + 1 => __('En attente'), 2 => __('Traitée'), - ], 'column' => true, 'filter' => true]); + ], 'column' => true, 'filter' => true, 'can_write' => 'fluidbook-quote:admin']); $this->addField('conversion', 'SelectFromArray', __('Conversion'), ['options' => [ 0 => __('Pas de réponse'), @@ -85,7 +95,7 @@ class FluidbookQuote extends CubistMagicAbstractModel 2 => __('Devis refusé'), 3 => __('Projet validé'), 4 => __('Déjà client'), - ], 'column' => true, 'can' => 'fluidbook-quote:admin', 'filter' => true]); + ], 'column' => true, 'filter' => true]); $this->addField('origin_column', FluidbookQuoteOrigin::class, __('Origine'), ['column' => true, 'filter' => true]); $this->addField('fluidbooks', 'ModelAttribute', __('Fluidbooks'), ['column' => true, 'column_label' => '', 'attribute' => 'user.e1_ws_count']); diff --git a/app/Models/Quiz.php b/app/Models/Quiz.php index 95e428d59..5afed8393 100644 --- a/app/Models/Quiz.php +++ b/app/Models/Quiz.php @@ -97,7 +97,7 @@ class Quiz extends CubistMagicAbstractModel 'type' => User::class, 'column' => true, 'can' => 'toolbox:quiz:edit_ownership', - 'attribute' => 'companyWithName', + 'attribute' => 'companyWithNameOnTwoLines', 'tab' => __('Projet')]); $this->addField(['name' => 'title', diff --git a/app/Widgets.php b/app/Widgets.php index 7be335941..7ae3158ac 100644 --- a/app/Widgets.php +++ b/app/Widgets.php @@ -19,7 +19,7 @@ class Widgets 'class' => 'alert alert-dark mb-2', 'heading' => __('Des demandes de devis n\'ont pas été traitées'), 'content' => __(':awaiting demandes de devis doivent être traitées', ['awaiting' => $nottreated]) . '.

' . __('Voir toutes les demandes en attente') . '

', - 'close_button' => true, // show close button or not + 'close_button' => false, // show close button or not ]); } } @@ -31,7 +31,7 @@ class Widgets 'class' => 'alert alert-danger mb-2', 'heading' => __('Des demandes de devis sont en attente'), 'content' => __(':awaiting demandes de devis sont actuellement en attente', ['awaiting' => $awaiting]) . '.

' . __('Voir toutes les demandes en attente') . '

', - 'close_button' => true, // show close button or not + 'close_button' => false, // show close button or not ]); } } diff --git a/config/backpack/crud.php b/config/backpack/crud.php index bcccd1c5b..bedb94af8 100644 --- a/config/backpack/crud.php +++ b/config/backpack/crud.php @@ -39,7 +39,7 @@ return [ // How many items should be shown by default by the Datatable? // This value can be overwritten on a specific CRUD by calling // $this->crud->setDefaultPageLength(50); - 'defaultPageLength' => 10, + 'defaultPageLength' => 100, // A 1D array of options which will be used for both the displayed option and the value, or // A 2D array in which the first array is used to define the value options and the second array the displayed options diff --git a/public/packages/fluidbook/toolbox/css/style.less b/public/packages/fluidbook/toolbox/css/style.less index 0621c8d39..cd4f73ca0 100644 --- a/public/packages/fluidbook/toolbox/css/style.less +++ b/public/packages/fluidbook/toolbox/css/style.less @@ -245,3 +245,56 @@ a, a.btn-link { [data-fluidbook-quote-status="1"] { color: #a00; } + +.btn-link { + .la { + position: relative; + top: 4px; + left: -4px; + font-size: 180%; + } +} + +.app-body { + overflow-x: visible; +} + +#crudTable { + box-shadow: none; + position: relative; + + thead { + tr { + background-color: #fafafa; + } + } + + &.has-hidden-columns { + .btn-link { + max-width: 35px; + overflow: hidden; + } + } + + &.test-hidden-columns { + .btn-link { + max-width: none !important; + } + } + + td { + padding: 0.4em 0.5em 0.4em 0.3em; + } + + th { + padding-left: 0.3em; + + } + + th, td { + &:first-child, &:nth-child(2), &:nth-child(3), &:last-child { + width: 1px; + } + } + +} diff --git a/resources/views/vendor/backpack/crud/inc/datatables_logic.blade.php b/resources/views/vendor/backpack/crud/inc/datatables_logic.blade.php new file mode 100644 index 000000000..7906ebd5c --- /dev/null +++ b/resources/views/vendor/backpack/crud/inc/datatables_logic.blade.php @@ -0,0 +1,331 @@ + + + + + + + + + + +@include('crud::inc.export_buttons') + + + +@include('crud::inc.details_row_logic') diff --git a/resources/views/vendor/backpack/crud/list.blade.php b/resources/views/vendor/backpack/crud/list.blade.php new file mode 100644 index 000000000..3662fd902 --- /dev/null +++ b/resources/views/vendor/backpack/crud/list.blade.php @@ -0,0 +1,173 @@ +@extends(backpack_view('blank')) + +@php + $defaultBreadcrumbs = [ + trans('backpack::crud.admin') => url(config('backpack.base.route_prefix'), 'dashboard'), + $crud->entity_name_plural => url($crud->route), + trans('backpack::crud.list') => false, + ]; + + // if breadcrumbs aren't defined in the CrudController, use the default breadcrumbs + $breadcrumbs = $breadcrumbs ?? $defaultBreadcrumbs; +@endphp + +@section('header') +
+

+ {!! $crud->getHeading() ?? $crud->entity_name_plural !!} + {!! $crud->getSubheading() ?? '' !!} +

+
+@endsection + +@section('content') + +
+ + +
+ +
+
+ @if ( $crud->buttons()->where('stack', 'top')->count() || $crud->exportButtons()) +
+ + @include('crud::inc.button_stack', ['stack' => 'top']) + +
+ @endif +
+
+
+
+
+ + {{-- Backpack List Filters --}} + @if ($crud->filtersEnabled()) + @include('crud::inc.filters_navbar') + @endif + + + + + {{-- Table columns --}} + @foreach ($crud->columns() as $column) + + @endforeach + + @if ( $crud->buttons()->where('stack', 'line')->count() ) + + @endif + + + + + + + {{-- Table columns --}} + @foreach ($crud->columns() as $column) + + @endforeach + + @if ( $crud->buttons()->where('stack', 'line')->count() ) + + @endif + + +
if developer forced field in table with 'visibleInTable => true' + data-visible => regular visibility of the field + data-can-be-visible-in-table => prevents the column to be loaded into the table (export-only) + data-visible-in-modal => if column apears on responsive modal + data-visible-in-export => if this field is exportable + data-force-export => force export even if field are hidden + + --}} + + {{-- If it is an export field only, we are done. --}} + @if(isset($column['exportOnlyField']) && $column['exportOnlyField'] === true) + data-visible="false" + data-visible-in-table="false" + data-can-be-visible-in-table="false" + data-visible-in-modal="false" + data-visible-in-export="true" + data-force-export="true" + @else + data-visible-in-table="{{var_export($column['visibleInTable'] ?? false)}}" + data-visible="{{var_export($column['visibleInTable'] ?? true)}}" + data-can-be-visible-in-table="true" + data-visible-in-modal="{{var_export($column['visibleInModal'] ?? true)}}" + @if(isset($column['visibleInExport'])) + @if($column['visibleInExport'] === false) + data-visible-in-export="false" + data-force-export="false" + @else + data-visible-in-export="true" + data-force-export="true" + @endif + @else + data-visible-in-export="true" + data-force-export="false" + @endif + @endif + > + {!! $column['label'] !!} + {{ trans('backpack::crud.actions') }}
{!! $column['label'] !!}{{ trans('backpack::crud.actions') }}
+ + @if ( $crud->buttons()->where('stack', 'bottom')->count() ) +
+ @include('crud::inc.button_stack', ['stack' => 'bottom']) + + +
+ @endif + +
+ +
+ +@endsection + +@section('after_styles') + + + + + + + + + + + @stack('crud_list_styles') +@endsection + +@section('after_scripts') + @include('crud::inc.datatables_logic') + + + + + + @stack('crud_list_scripts') +@endsection -- 2.39.5