Refonte design V1
This commit is contained in:
@@ -1,100 +1,117 @@
|
||||
@extends('layouts.app')
|
||||
@section('title', 'Campagnes — Signatures CABM')
|
||||
@section('title', 'Campagnes — Signatures')
|
||||
@section('content')
|
||||
@php
|
||||
$isAdmin = auth()->user()->hasRole('admin');
|
||||
$tz = config('signature.timezone');
|
||||
$badge = ['running' => 'ok', 'scheduled' => '', 'inactive' => 'warn', 'ended' => ''];
|
||||
$badge = ['running' => 'ok', 'scheduled' => '', 'inactive' => 'warn', 'ended' => 'off'];
|
||||
$variable = '{'.'{'.'{banniere}'.'}'.'}';
|
||||
$period = fn ($d) => $d->timezone($tz)->format('d/m/Y H:i');
|
||||
@endphp
|
||||
<div class="row" style="margin-bottom:8px">
|
||||
<h1 style="margin:0">Campagnes</h1>
|
||||
<span class="spacer"></span>
|
||||
<a class="btn" href="{{ route('admin.campaigns.create') }}">Nouvelle campagne</a>
|
||||
</div>
|
||||
<p class="muted">
|
||||
Une campagne ajoute une bannière sous la signature pendant une période, pour tous les agents ou pour certains groupes AD.
|
||||
<strong>Une seule bannière par signature</strong> : si plusieurs campagnes en cours concernent un agent, celle dont la priorité
|
||||
est la plus haute l'emporte (à égalité : la plus ancienne). La bannière n'apparaît que dans la signature complète,
|
||||
pas dans la signature courte des réponses, et seulement si le template contient <code>{{ $variable }}</code>.
|
||||
@unless ($isAdmin) Vous préparez les campagnes ; un administrateur les active. @endunless
|
||||
</p>
|
||||
<header class="page-head">
|
||||
<div>
|
||||
<h1>Campagnes</h1>
|
||||
<p class="lead">
|
||||
Une campagne ajoute une bannière sous la signature pendant une période, pour tous les agents ou pour certains groupes AD.
|
||||
<strong>Une seule bannière par signature</strong> : si plusieurs campagnes en cours concernent un agent, celle dont la priorité
|
||||
est la plus haute l'emporte (à égalité : la plus ancienne). La bannière n'apparaît que dans la signature complète,
|
||||
pas dans la signature courte des réponses.
|
||||
@unless ($isAdmin) Vous préparez les campagnes ; un administrateur les active. @endunless
|
||||
</p>
|
||||
</div>
|
||||
<div class="page-actions">
|
||||
<a class="btn" href="{{ route('admin.campaigns.create') }}"><x-icon name="plus" />Nouvelle campagne</a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@if ($withoutBanner->isNotEmpty())
|
||||
<div class="notice" role="note">
|
||||
Ces templates publiés ne contiennent pas <code>{{ $variable }}</code> : leurs agents ne verront aucune bannière —
|
||||
{{ $withoutBanner->join(', ') }}.
|
||||
<div class="alert notice" role="note">
|
||||
<x-icon name="triangle-alert" />
|
||||
<div>Ces templates publiés ne contiennent pas <code>{{ $variable }}</code> : leurs agents ne verront aucune bannière.
|
||||
<strong>{{ $withoutBanner->join(', ') }}</strong></div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="card" style="overflow-x:auto">
|
||||
<table class="list">
|
||||
<thead><tr><th style="width:130px">Bannière</th><th>Campagne</th><th>Période</th><th>Destinataires</th><th>Priorité</th><th>État</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
@forelse ($campaigns as $c)
|
||||
@php
|
||||
$status = $c->status();
|
||||
$locked = $c->active && ! $isAdmin;
|
||||
@endphp
|
||||
<tr>
|
||||
<td>
|
||||
@if (in_array($c->id, $missing, true))
|
||||
<span class="badge warn">image manquante</span>
|
||||
<div class="muted">{{ $c->image_path }}</div>
|
||||
@else
|
||||
<img src="{{ asset('img/'.$c->image_path) }}" alt="{{ $c->alt_text }}" style="max-width:120px;max-height:60px;border:1px solid var(--line);background:#fff">
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ route('admin.campaigns.edit', $c) }}"><strong>{{ $c->name }}</strong></a>
|
||||
<div class="muted">
|
||||
@if ($c->link_url)
|
||||
Lien : <a href="{{ $c->link_url }}" target="_blank" rel="noopener">{{ \Illuminate\Support\Str::limit($c->link_url, 50) }}</a>
|
||||
<div class="card card--flush">
|
||||
<div class="table-wrap">
|
||||
<table class="list">
|
||||
<thead><tr><th>Bannière</th><th>Campagne</th><th>Période</th><th>Destinataires</th><th>Priorité</th><th>État</th><th class="right">{{ $isAdmin ? 'Active' : '' }}</th></tr></thead>
|
||||
<tbody>
|
||||
@forelse ($campaigns as $c)
|
||||
@php
|
||||
$status = $c->status();
|
||||
$locked = $c->active && ! $isAdmin;
|
||||
@endphp
|
||||
<tr>
|
||||
<td>
|
||||
@if (in_array($c->id, $missing, true))
|
||||
<span class="badge warn">image manquante</span>
|
||||
<div class="muted">{{ $c->image_path }}</div>
|
||||
@else
|
||||
Sans lien
|
||||
<img class="thumb" src="{{ asset('img/'.$c->image_path) }}" alt="{{ $c->alt_text }}" loading="lazy">
|
||||
@endif
|
||||
</div>
|
||||
</td>
|
||||
<td style="white-space:nowrap">{{ $period($c->starts_at) }}<br>→ {{ $period($c->ends_at) }}</td>
|
||||
<td style="overflow-wrap:anywhere">{{ $c->groups->isEmpty() ? 'Tous les agents' : $c->groups->pluck('display_name')->join(', ') }}</td>
|
||||
<td>{{ $c->priority }}</td>
|
||||
<td>
|
||||
<span class="badge {{ $badge[$status] }}">{{ \App\Models\Campaign::STATUSES[$status] }}</span>
|
||||
@if ($status === 'running')
|
||||
</td>
|
||||
<td>
|
||||
<a class="cell-title" href="{{ route('admin.campaigns.edit', $c) }}">{{ $c->name }}</a>
|
||||
<div class="muted">
|
||||
@if (($reach[$c->id] ?? 0) > 0)
|
||||
vue par {{ $reach[$c->id] }} agent{{ $reach[$c->id] > 1 ? 's' : '' }}
|
||||
@if ($c->link_url)
|
||||
<a href="{{ $c->link_url }}" target="_blank" rel="noopener" title="{{ $c->link_url }}">{{ \Illuminate\Support\Str::limit(preg_replace('#^https?://(www\.)?#', '', $c->link_url), 38) }}</a>
|
||||
@else
|
||||
aucun agent : masquée par une campagne plus prioritaire, ou groupes vides
|
||||
Sans lien
|
||||
@endif
|
||||
</div>
|
||||
@elseif ($status === 'inactive')
|
||||
<div class="muted">{{ $isAdmin ? 'à activer' : 'en attente d\'un administrateur' }}</div>
|
||||
@endif
|
||||
</td>
|
||||
<td style="text-align:right">
|
||||
<a class="btn secondary small" style="margin:2px 0" href="{{ route('admin.campaigns.edit', $c) }}">{{ $locked ? 'Voir' : 'Modifier' }}</a>
|
||||
@if ($isAdmin)
|
||||
@if ($status !== 'ended')
|
||||
<form class="inline" method="post" action="{{ route('admin.campaigns.toggle', $c) }}">
|
||||
@csrf
|
||||
<button class="btn secondary small" style="margin:2px 0" type="submit">{{ $c->active ? 'Désactiver' : 'Activer' }}</button>
|
||||
</td>
|
||||
<td class="nowrap">{{ $period($c->starts_at) }}<br><span class="muted">au</span> {{ $period($c->ends_at) }}</td>
|
||||
<td style="min-width:130px;overflow-wrap:anywhere">{{ $c->groups->isEmpty() ? 'Tous les agents' : $c->groups->pluck('display_name')->join(', ') }}</td>
|
||||
<td class="num">{{ $c->priority }}</td>
|
||||
<td>
|
||||
<span class="badge {{ $badge[$status] }}">{{ \App\Models\Campaign::STATUSES[$status] }}</span>
|
||||
@if ($status === 'running')
|
||||
<div class="muted">
|
||||
@if (($reach[$c->id] ?? 0) > 0)
|
||||
vue par {{ $reach[$c->id] }} agent{{ $reach[$c->id] > 1 ? 's' : '' }}
|
||||
@else
|
||||
aucun agent : masquée par une campagne plus prioritaire, ou groupes vides
|
||||
@endif
|
||||
</div>
|
||||
@elseif ($status === 'inactive')
|
||||
<div class="muted">{{ $isAdmin ? 'à activer' : 'en attente d\'un administrateur' }}</div>
|
||||
@endif
|
||||
</td>
|
||||
<td class="cell-actions">
|
||||
<a class="btn secondary small icon-only" href="{{ route('admin.campaigns.edit', $c) }}"
|
||||
title="{{ $locked ? 'Voir' : 'Modifier' }}" aria-label="{{ $locked ? 'Voir' : 'Modifier' }} {{ $c->name }}">
|
||||
<x-icon :name="$locked ? 'eye' : 'pencil'" :size="15" />
|
||||
</a>
|
||||
@if ($isAdmin)
|
||||
@if ($status !== 'ended')
|
||||
<form class="inline" method="post" action="{{ route('admin.campaigns.toggle', $c) }}">
|
||||
@csrf
|
||||
<button class="switch-btn" type="submit" role="switch" aria-checked="{{ $c->active ? 'true' : 'false' }}"
|
||||
title="{{ $c->active ? 'Désactiver' : 'Activer' }}" aria-label="Campagne {{ $c->name }} active"></button>
|
||||
</form>
|
||||
@endif
|
||||
<form class="inline" method="post" action="{{ route('admin.campaigns.destroy', $c) }}"
|
||||
data-confirm="Supprimer la campagne « {{ $c->name }} » ? Les messages déjà envoyés conservent la bannière."
|
||||
data-confirm-label="Supprimer" data-confirm-danger>
|
||||
@csrf @method('DELETE')
|
||||
<button class="btn danger small icon-only" type="submit" title="Supprimer" aria-label="Supprimer {{ $c->name }}"><x-icon name="trash-2" :size="15" /></button>
|
||||
</form>
|
||||
@endif
|
||||
<form class="inline" method="post" action="{{ route('admin.campaigns.destroy', $c) }}"
|
||||
onsubmit="return confirm('Supprimer cette campagne ? Les messages déjà envoyés conservent la bannière.')">
|
||||
@csrf @method('DELETE')
|
||||
<button class="btn danger small" style="margin:2px 0" type="submit">Supprimer</button>
|
||||
</form>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="7" class="muted">Aucune campagne. Les signatures sont envoyées sans bannière.</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="muted">Vérifiez la bannière reçue par un agent précis dans l'onglet <a href="{{ route('admin.agents.index') }}">Agents</a>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="7">
|
||||
<div class="empty">
|
||||
<x-icon name="megaphone" :size="32" />
|
||||
<p><strong>Aucune campagne</strong>Les signatures partent sans bannière. Créez une campagne pour en afficher une pendant une période donnée.</p>
|
||||
<p><a class="btn" href="{{ route('admin.campaigns.create') }}"><x-icon name="plus" />Nouvelle campagne</a></p>
|
||||
</div>
|
||||
</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-foot muted">Vérifiez la bannière reçue par un agent précis dans l'écran <a href="{{ route('admin.agents.index') }}">Agents</a>.</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user