From 1b64c6ba1a6fded4dd28d34af3fc2ba654a4a17c Mon Sep 17 00:00:00 2001 From: Olivier Legat Date: Thu, 15 Apr 2021 13:07:46 +0200 Subject: [PATCH] correction ellipse sur titre produit --- app/Http/Controllers/CustomerController.php | 48 +++++++++++-------- phpcs.xml | 4 +- public/canard/css/app.css | 40 +++++++++++++++- .../canard/partials/products-list.blade.php | 6 ++- resources/views/front/canard/sass/main.scss | 43 ++++++++++++++++- 5 files changed, 116 insertions(+), 25 deletions(-) diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index a421bf68..10590358 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -37,6 +37,7 @@ class CustomerController extends Controller { /** @var \App\Lib\LDCCRM\ApiV1 */ $crm = app('crmApi'); + $crmCustomer = $crm->createCustomer( $request->email, $request->password, @@ -53,8 +54,8 @@ class CustomerController extends Controller ); if ($crmCustomer->status === "OK") { - $customer = new Customers($request->all()); - $customer->crm_id = $crmCustomer->user->crm_id; + $customer = new Customers($request->all()); + $customer->crm_id = $crmCustomer->user->crm_id; $customer->hashcode = $crmCustomer->user->hashcode; $customer->save(); @@ -104,7 +105,7 @@ class CustomerController extends Controller 'password' => 'required', ]); - $email = filter_var($request->email, FILTER_SANITIZE_EMAIL); + $email = filter_var($request->email, FILTER_SANITIZE_EMAIL); $password = $request->password; $remember = $request->remember !== null ? true : false; @@ -113,6 +114,7 @@ class CustomerController extends Controller if ($customer) { /** @var \App\Lib\LDCCRM\ApiV1 */ $crm = app('crmApi'); + $result = $crm->loginCustomer($email, $password); if ($result->status === "OK") { /** @var \Illuminate\Auth\SessionGuard */ @@ -121,16 +123,18 @@ class CustomerController extends Controller $url = Session::pull('url.intended'); Session::forget('url.intended'); Session::save(); - if(empty($url)) { + if (empty($url)) { return redirect()->route('account.dashboard'); } return redirect()->to($url); } else { switch ($result->code) { case 115: + // @phpcs:ignore Generic.Files.LineLength return back()->withErrors("Veuillez vérifier que vous avez correctement rempli les champs obligatoires."); case 116: Mail::to($email)->send(new RegisterConfirmMail($customer, null)); + // @phpcs:ignore Generic.Files.LineLength return back()->withErrors("Votre compte n'est pas activé, vérifier dans vos emails pour y trouver le mail de confirmation. Un lien d'activation vous a été renvoyer."); case 117 || 118 || 119: return back()->withErrors("Email ou mot de passe incorrect."); @@ -152,9 +156,10 @@ class CustomerController extends Controller $customer = Customers::select('crm_id')->where('hashcode', $hashcode)->first(); if ($customer) { /** @var \App\Lib\LDCCRM\ApiV1 */ - $crm = app('crmApi'); + $crm = app('crmApi'); $result = $crm->activateCustomer($customer->crm_id); if ($result->status === "OK") { + // @phpcs:ignore Generic.Files.LineLength return view('auth.activate')->with('message', 'Votre compte a bien été activé, vous pouvez désormais vous connecter.'); } else { return view('auth.activate')->with('message', "Ce lien d'activation n'est pas valide."); @@ -202,13 +207,14 @@ class CustomerController extends Controller $token = Str::random(80); - $passwordReset = new PasswordReset(); - $passwordReset->email = $email; - $passwordReset->token = $token; + $passwordReset = new PasswordReset(); + $passwordReset->email = $email; + $passwordReset->token = $token; $passwordReset->created_at = now(); $passwordReset->save(); Mail::to($email)->send(new PasswordResetMail($token)); + // @phpcs:ignore Generic.Files.LineLength return back()->with('success', __("La procédure pour changer votre mot de passe a été envoyé sur votre email.")); } else { return back()->withErrors(__("Cette adresse email n'est pas enregistrée dans nos services.")); @@ -247,13 +253,14 @@ class CustomerController extends Controller try { $passwordReset = PasswordReset::where('token', $token)->first(); - $customer = Customers::where('email', $passwordReset->email)->first(); - $crmId = $customer->crm_id; + $customer = Customers::where('email', $passwordReset->email)->first(); + $crmId = $customer->crm_id; } catch (Exception $e) { return back()->withErrors("Changement du mot de passe impossible, les données envoyés sont incorrectes."); } /** @var \App\Lib\LDCCRM\ApiV1 */ $crm = app('crmApi'); + $result = $crm->changePwdCustomer($crmId, $password); if ($result->status === "OK") { $passwordReset->delete(); @@ -284,12 +291,12 @@ class CustomerController extends Controller } /** @var \App\Lib\LDCCRM\ApiV1 */ - $crm = app('crmApi'); + $crm = app('crmApi'); $crmCustomer = $crm->getCustomer($customer->crm_id); if ($crmCustomer->status === "KO") { abort(503); } - $crmInfos = $crmCustomer->user; + $crmInfos = $crmCustomer->user; $birthDate = explode('-', $crmInfos->birth_date); return view('customer.dashboard', compact('customer', 'crmInfos', 'birthDate')); @@ -298,14 +305,14 @@ class CustomerController extends Controller /** * Send a request to the CRM to change the given customer's informations - * @param Request $request + * @param UpdateInfosRequest $request + * */ public function updateInfos(UpdateInfosRequest $request) { // TODO : Activer le changement d'email quand ce sera possible dans la CRM /** @var \App\Lib\LDCCRM\ApiV1 */ - $crm = app('crmApi'); - + $crm = app('crmApi'); $crmCustomer = $crm->updateCustomer( Auth::guard('customer')->user()->crm_id, $request->firstname, @@ -337,7 +344,7 @@ class CustomerController extends Controller 'password' => 'required|min:8|confirmed|max:255' ]); - $crm = app('crmApi'); + $crm = app('crmApi'); $customer = $crm->changePwdCustomer(Auth::guard('customer')->user()->crm_id, $request->password); if ($customer->status === "OK") { @@ -350,12 +357,14 @@ class CustomerController extends Controller /** * affichage des commandes du customer connecté */ - public function myOrders(Request $request) { + public function myOrders(Request $request) + { $orders = Order::where('customer_id', Auth::guard('customer')->user()->id)->orderBy('date', 'DESC')->get(); return view('customer.my-orders', compact('orders')); } - public function orderDetail($reference) { + public function orderDetail($reference) + { $order = Order::where('reference', '=', $reference) ->where('customer_id', Auth::guard('customer')->user()->id) ->firstOrFail(); @@ -375,8 +384,9 @@ class CustomerController extends Controller // TODO : Suppression via la CRM - if (Auth::guard('customer')->user()->id === $customer->id) + if (Auth::guard('customer')->user()->id === $customer->id) { Auth::guard('customer')->logout(); + } $customer->delete(); return redirect()->route('home'); diff --git a/phpcs.xml b/phpcs.xml index 54b0e2fc..f657d0ff 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -26,7 +26,9 @@ - + + 0 + diff --git a/public/canard/css/app.css b/public/canard/css/app.css index 931ad106..99afdb9c 100644 --- a/public/canard/css/app.css +++ b/public/canard/css/app.css @@ -2875,15 +2875,51 @@ input.product__qty-input { } .pl-item__title { - display: flex; align-items: center; justify-content: center; text-align: center; padding: 0 10px; height: 50px; - overflow: hidden; margin-bottom: 15px; } +.pl-item__title > span.ellipse { + display: block; + /* hide text if it more than N lines */ + overflow: hidden; + /* for set '...' in absolute position */ + position: relative; + /* use this value to count block height */ + /* max-height = line-height (1.2) * lines max number (3) */ + max-height: 50px; + /* fix problem when last visible word doesn't adjoin right side */ + text-align: justify; + /* place for '...' */ + margin-right: -1em; + padding-right: 1em; +} +.pl-item__title > span.ellipse:before { + /* points in the end */ + content: "..."; + /* absolute position */ + position: absolute; + /* set position to right bottom corner of block */ + right: 0; + bottom: 0; +} +.pl-item__title > span.ellipse:after { + /* points in the end */ + content: ""; + /* absolute position */ + position: absolute; + /* set position to right bottom corner of text */ + right: 0; + /* set width and height */ + width: 1em; + height: 1em; + margin-top: 0.2em; + /* bg color = bg color under block */ + background: white; +} .pl-item__title:hover { text-decoration: underline; diff --git a/resources/views/front/canard/partials/products-list.blade.php b/resources/views/front/canard/partials/products-list.blade.php index 45a3e01d..beb7d7e2 100644 --- a/resources/views/front/canard/partials/products-list.blade.php +++ b/resources/views/front/canard/partials/products-list.blade.php @@ -48,7 +48,11 @@ @foreach ($products as $product)
- {{ $product->name }} + + {{ $product->name }} + @if($product->promotions->count())
Offre spéciale
diff --git a/resources/views/front/canard/sass/main.scss b/resources/views/front/canard/sass/main.scss index 72f596b2..97a13da2 100644 --- a/resources/views/front/canard/sass/main.scss +++ b/resources/views/front/canard/sass/main.scss @@ -1700,14 +1700,53 @@ input.product__qty-input { } .pl-item__title { - display: flex; + //display: flex; align-items: center; justify-content: center; text-align: center; padding: 0 10px; height: 50px; - overflow: hidden; + //overflow: hidden; margin-bottom: 15px; + & > span.ellipse { + display: block; + /* hide text if it more than N lines */ + overflow: hidden; + /* for set '...' in absolute position */ + position: relative; + /* use this value to count block height */ + //line-height: 1.2em; + /* max-height = line-height (1.2) * lines max number (3) */ + max-height: 50px; + /* fix problem when last visible word doesn't adjoin right side */ + text-align: justify; + /* place for '...' */ + margin-right: -1em; + padding-right: 1em; + &:before { + /* points in the end */ + content: '...'; + /* absolute position */ + position: absolute; + /* set position to right bottom corner of block */ + right: 0; + bottom: 0; + } + &:after { + /* points in the end */ + content: ''; + /* absolute position */ + position: absolute; + /* set position to right bottom corner of text */ + right: 0; + /* set width and height */ + width: 1em; + height: 1em; + margin-top: 0.2em; + /* bg color = bg color under block */ + background: white; + } + } } .pl-item__title:hover {