Add general config type rsm

Add show rsm on products
Add title on general config
This commit is contained in:
Jérémy Munsch 2021-09-23 10:20:35 +02:00
parent cb4861f80d
commit d1672e50fc
No known key found for this signature in database
GPG key ID: 55196BEE445F6049
16 changed files with 272 additions and 17 deletions

View file

@ -6,20 +6,23 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
/**
* @method static self actu()
* @method static self rsm()
*/
final class GeneralConfigType extends BaseEnumRoutable
{
protected static function values(): array
{
return [
'actu' => 1
'actu' => 1,
'rsm' => 2
];
}
protected static function labels(): array
{
return [
'actu' => __('Actualité')
'actu' => __('Actualité'),
'rsm' => __('RSM Block')
];
}
}

View file

@ -466,6 +466,13 @@ class ProductsController extends Controller
return redirect()->route('bo.products.index');
}
public function showRsm(Products $product)
{
$product->show_rsm = !$product->show_rsm;
$product->saveOrFail();
return redirect()->back();
}
public function setXmlInco(SetProductXmlInco $request, Products $product)
{
$xmlInco = XmlInco::where('id', $request->xml_inco)->firstOrFail();

View file

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Enums\GeneralConfigType;
use App\Models\BalancedMenus;
use App\Models\ConsumptionTimes;
use App\Models\ProductSliderPictures;
@ -112,9 +113,11 @@ class ProductsController extends Controller
$ids[] = $r->id;
}
$ids = array_unique($ids);
$generalConfig = app()->view->getShared()['GeneralConfigGlobal'] ?? null;
$generalConfig = $generalConfig ? $generalConfig->where('type', GeneralConfigType::rsm())->first() : null;
$recipes = Recipes::whereIn('id', $ids)->where('status', true)->get();
return view('front.products.product', compact('product', 'recipes', 'recipeVideo'));
return view('front.products.product', compact('product', 'recipes', 'recipeVideo', 'generalConfig'));
}
public function indexMenusAjax(Request $request)

View file

@ -102,6 +102,9 @@ return [
],
'actuWebp' => [
'format' => 'webp'
]
],
'productRSMWEBP' => [
'format' => 'webp'
],
]
];

View file

@ -0,0 +1,39 @@
<?php
use App\Enums\GeneralConfigType;
use App\Models\GeneralConfig;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddTitleColumnGeneralConfig extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('general_configs', function (Blueprint $table) {
$table->string('title')->before('type')->default('Titre');
});
$config = GeneralConfig::where('type', GeneralConfigType::actu())->first();
if ($config) {
$config->title = 'Configuration actualités';
$config->saveOrFail();
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('general_configs', function (Blueprint $table) {
$table->dropColumn('title');
});
}
}

View file

@ -0,0 +1,66 @@
<?php
use App\Enums\GeneralConfigType;
use App\Enums\InputType;
use App\Models\GeneralConfig;
use Illuminate\Database\Migrations\Migration;
class CreateGeneralConfigRsmBlock extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$config = new GeneralConfig();
$config->title = 'Configuration RSM';
$config->type = GeneralConfigType::rsm();
$config->data = [
'img_rsm_header' => [
'dimensions' => 'largeur 200,hauteur 184',
'label' => 'Image d\'entête RSM',
'inputType' => InputType::image(),
'alt' => 'Image d\'entête RSM',
'value' => '/assets/images/onsengage/logo-onsengage.png'
],
'img_rsm_title' => [
'label' => 'Titre (h6)',
'inputType' => InputType::string(),
'value' => '100 %'
],
'img_rsm_sub_title' => [
'label' => 'Sous-Titre (h6)',
'inputType' => InputType::string(),
'value' => 'Français'
],
'img_rsm_sub_text' => [
'label' => 'Sous-Titre (h6)',
'inputType' => InputType::text(),
// phpcs:ignore Generic.Files.LineLength.TooLong
'value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ante ipsum, consectetur a lectus.',
'validate' => 'string|min:10|max:100'
],
'img_rsm_sub_link' => [
'text' => 'En savoir +',
'label' => 'Lien du bouton en savoir +',
'inputType' => InputType::url(),
'status' => true,
'newtab' => false,
'value' => ''
]
];
$config->saveOrFail();
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
GeneralConfig::where('type', GeneralConfigType::rsm())->delete();
}
}

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddShowRsmOnProducts extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('products', function (Blueprint $table) {
$table->boolean('show_rsm')->after('star')->default(false);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('show_rsm');
});
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

View file

@ -25,11 +25,14 @@ if (document.querySelector('.content.product')) {
}
};
// Listen for new scroll events, here we debounce our `storeScroll` function
document.addEventListener('scroll', __Gaul.debounce(storeScroll), { passive: true });
// handle rsm
if (!document.getElementsByClassName('rsm').length) {
// Listen for new scroll events, here we debounce our `storeScroll` function
document.addEventListener('scroll', __Gaul.debounce(storeScroll), { passive: true });
// Update scroll position for first time
storeScroll();
// Update scroll position for first time
storeScroll();
}
let buttons = document.getElementsByClassName('product_block_active');
for (let i = 0; i < buttons.length; i++) {

View file

@ -1,4 +1,5 @@
.content.product {
position: relative;
background-color: #fbf8f5;
margin-right: 0 !important;
max-width: inherit !important;
@ -40,6 +41,66 @@
padding-right: 0;
}
& .rsm {
background-image: url('~@/images/produit/produit_fond_bois.jpg');
background-size: cover;
padding: 2.133rem 2.666rem;
position: absolute;
display: flex;
flex-direction: column;
// compenser avec -23.93rem, gutter avec - 10.06rem
margin-left: -23.93rem - 10.06rem;
width: 23.93rem;
min-height: 38.329rem;
& picture {
text-align: center;
}
& .header {
margin-top: 2.666rem;
font-family: 'Veneer';
color: $engagementDarkGreen;
text-align: center;
& .title {
font-size: 8rem;
line-height: 6.5rem;
}
& .subtitle {
font-size: 3.333rem;
}
}
& .content {
margin-top: 1.066rem;
font-size: 'Catamaran-Regular';
color: $engagementDarkerGreen;
font-size: 1.199rem;
text-align: center;
}
& .link {
margin-top: 2.666rem;
text-align: center;
& a {
background-color: #006633;
color: #FFF;
display: inline-block;
min-height: 2.867rem;
font-family: "Catamaran-Bold";
font-size: 1.066rem;
font-weight: bold;
padding: 0.6rem 1rem;
border-radius: 2rem;
text-transform: uppercase;
line-height: 1.733rem;
&:hover {
background-color: #082014 !important;
text-decoration: underline !important;
cursor: pointer;
}
}
}
}
& .general {
& p {
font-family: 'CreamyScriptRegular';

View file

@ -3,7 +3,7 @@
@section('content')
<div class="card">
<div class="card-header">
{{ __('Modification d\'une configuration') }}
{{ __('Modification d\'une configuration') }}@if($config->title)&nbsp;-&nbsp;<b>{{ $config->title }}</b>@endif
<a href="{{route('bo.general-configs.index')}}" class="btn btn-sm btn-primary float-right ml-2">{{ __('Retour') }}</a>
</div>
<div class="card-body">

View file

@ -300,6 +300,16 @@
<img src="{{ asset($p->picture_video) }}" style="max-height: 200px;">
@endif
</div>
<div class="form-group">
<label>
@if ((old('show_rsm') ?? $p->show_rsm ?? '') === 1)
<input type="checkbox" name="status" checked>
@else
<input type="checkbox" name="status">
@endif
{{ __('Montrer RSM sur la page du produit ?') }}
</label>
</div>
<div class="form-group">
<label>
@if ((old('status') ?? $p->status ?? '') === 1)

View file

@ -45,6 +45,7 @@
'range_id' => 'Gamme',
'star' => 'Produit star ?',
'status' => 'Publié ?',
'show_rsm' => 'RSM ?',
'order' => 'Ordre',
]
])
@ -72,6 +73,15 @@
@endif
</a>
</td>
<td>
<a href="{{route('bo.products.show-rsm', $product)}}" class="btn-link">
@if ($product->show_rsm)
<i class="fas fa-check check-green"></i>
@else
<i class="fas fa-times cross-red"></i>
@endif
</a>
</td>
@if(!request()->sort_col and !request()->sort_way)
<td>
@if ($loop->first)

View file

@ -56,7 +56,23 @@ $vegetal = ($vegetal || isset($gamme) && $gamme && $gamme->slug === "le-vegetal"
@section('content')
<div class="content product @if($product->range->slug === "le-vegetal")vegetal @endif" style="min-height: 500px">
<div class="wrapper">
<article class="wrapper">
@if($product->show_rsm and $generalConfig)
<aside class="rsm">
<picture>
<source srcset="{{ url(resizePublic($generalConfig->data['img_rsm_header']['value'], 'productRSMWEBP')) }}" type="image/webp">
<img src="{{ url($generalConfig->data['img_rsm_header']['value']) }}" alt="{{ __('Le Gaulois - :label', ['label' => $generalConfig->data['img_rsm_header']['label']]) }}" width="200" height="180">
</picture>
<div class="header">
<div class="title">{{ $generalConfig->data['img_rsm_title']['value'] }}</div>
<div class="subtitle">{{ $generalConfig->data['img_rsm_sub_title']['value'] }}</div>
</div>
<div class="content">{{ $generalConfig->data['img_rsm_sub_text']['value'] }}</div>
<div class="link">
<a href="{{ $generalConfig->data['img_rsm_sub_link']['value'] }}" @if($generalConfig->data['img_rsm_sub_link']['newtab']) target="_blank" @endif>{{ $generalConfig->data['img_rsm_sub_link']['text'] ?? __('En Savoir +') }}</a>
</div>
</aside>
@endif
<div class="general">
@if ($product->number_portion)
<p>{{ $product->number_portion }}x {{ $product->name }}</p>
@ -85,7 +101,7 @@ $vegetal = ($vegetal || isset($gamme) && $gamme && $gamme->slug === "le-vegetal"
</div>
@endif
@if(count($recipes))
<div class="block">
<aside class="block">
<h3>Recettes associées</h3>
@foreach ($recipes as $recipe)
<div class="block-recipe">
@ -98,10 +114,10 @@ $vegetal = ($vegetal || isset($gamme) && $gamme && $gamme->slug === "le-vegetal"
</div>
</div>
@endforeach
</div>
</aside>
@endif
@if ($product->video_link and strlen($product->video_link))
<div class="block">
<aside class="block">
<h3>Vidéo produit</h3>
@php
$type = strpos(parse_url($product->video_link, PHP_URL_HOST), 'vimeo.com') !== false ? 'vimeo' : null;
@ -121,7 +137,7 @@ $vegetal = ($vegetal || isset($gamme) && $gamme && $gamme->slug === "le-vegetal"
@else
<video controls src="{{ $product->video_link }}"></video>
@endif
</div>
</aside>
@endif
@if ($product->ingredients and strlen($product->ingredients))
<div class="block hassub">
@ -222,7 +238,7 @@ $vegetal = ($vegetal || isset($gamme) && $gamme && $gamme->slug === "le-vegetal"
</div>
@endforeach
@endif
<div class="social-network">
<aside class="social-network">
<a id="twitterShare" class="mediaShare" href="https://twitter.com/share?url={{ request()->fullurl() }}" title="{{ __('Partager sur Twitter' )}}"><i class="fab fa-twitter"></i></a>
<a href="https://www.instagram.com/legaulois_officiel/" target="_blank"><i class="fab fa-instagram"></i></a>
<a id="facebookShare" class="mediaShare" href="https://www.facebook.com/sharer/sharer.php?u={{ request()->fullurl() }}&title={{ $product->title }}" title="{{ __('Partager sur Facebook' )}}"><i class="fab fa-facebook-f"></i></a>
@ -238,7 +254,7 @@ $vegetal = ($vegetal || isset($gamme) && $gamme && $gamme->slug === "le-vegetal"
@endauth
{{-- TODO print product CSS --}}
{{-- <span id="printProduct" title="{{ __('Imprimer la page') }}"><i class="icon-print"></i></span> --}}
</div>
</aside>
{{-- TODO HANDLE RECIPE VIDEO BEFORE --}}
{{-- @if($recipeVideo)
<div class="block">
@ -254,7 +270,7 @@ $vegetal = ($vegetal || isset($gamme) && $gamme && $gamme->slug === "le-vegetal"
</div>
</div>
@endif --}}
</div>
</article>
@if($vegetal)
@include('front.products.product-vegetal')
@endif

View file

@ -161,6 +161,7 @@
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">{{ __('Les produits') }}</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="{{route('bo.products.index')}}">{{ __('Tous les produits') }}</a>
<a class="dropdown-item" href="{{route('bo.general-configs.edit', GeneralConfigType::rsm()->value)}}">{{ __('Configuration RSM') }}</a>
<a class="dropdown-item" href="{{route('bo.products.create')}}">{{ __('Ajouter') }}</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{{route('bo.ranges.index')}}">{{ __('Toutes les gammes') }}</a>

View file

@ -170,6 +170,7 @@ Route::prefix('bo')
Route::get('/products/{product}/copyinco', [BoProductsController::class, 'copyXmlIncoValues'])->name('products.copyXmlIncoValues');
Route::get('/products/{product}/copyincopicture', [BoProductsController::class, 'copyXmlIncoPicture'])->name('products.copyXmlIncoPicture');
Route::get('/products/{product}/copyincopicture', [BoProductsController::class, 'copyXmlIncoPicture'])->name('products.copyXmlIncoPicture');
Route::get('/products/{product}/show-rsm', [BoProductsController::class, 'showRsm'])->name('products.show-rsm');
Route::post('/ajax/reductions/save', [BoReductionsController::class, 'saveDatas']);
Route::post('/products/{product}/setinco', [BoProductsController::class, 'setXmlInco'])->name('products.setXmlInco');
Route::put('/actus/highlights/store', [BoActuController::class, 'storeHighlights'])->name('actus.store-highlights');