Group e-mails by first character in the group creation/edition form
This commit is contained in:
parent
a7010dad53
commit
53cb37897a
2 changed files with 36 additions and 21 deletions
|
@ -53,6 +53,12 @@ class CustomersGroupsController extends Controller {
|
|||
->pluck('emails')
|
||||
->flatten()
|
||||
->sortBy('email');
|
||||
// Group Emails by their first character.
|
||||
// This is used to display them in collapsible groups.
|
||||
$emails = $emails->mapToGroups(function ($email) {
|
||||
$first_character = substr($email->email, $offset = 0, $length = 1);
|
||||
return [ $first_character => $email ];
|
||||
});
|
||||
|
||||
return view('mmfcustomersgroups::groups/edit', [
|
||||
'mailboxes' => $mailboxes,
|
||||
|
|
|
@ -84,27 +84,36 @@
|
|||
</label>
|
||||
<div class="col-sm-6">
|
||||
<div class="multi-container">
|
||||
@foreach ( $emails as $email )
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label
|
||||
class="control-label checkbox"
|
||||
for="email-{{ $email->id }}"
|
||||
style="text-align: left;"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="emails[]"
|
||||
id="email-{{ $email->id }}"
|
||||
value="{{ $email->id }}"
|
||||
@if ( $group->emails()->contains($email) )
|
||||
checked="checked"
|
||||
@endif
|
||||
>
|
||||
{{ $email->email }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@foreach ( $emails as $first_character => $emails_group )
|
||||
<details>
|
||||
<summary
|
||||
style="display: list-item; counter-increment: list-item 0; list-style: disclosure-closed inside; cursor: pointer;"
|
||||
>
|
||||
{{ $first_character }}…
|
||||
</summary>
|
||||
@foreach ( $emails_group as $email )
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label
|
||||
class="control-label checkbox"
|
||||
for="email-{{ $email->id }}"
|
||||
style="text-align: left;"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="emails[]"
|
||||
id="email-{{ $email->id }}"
|
||||
value="{{ $email->id }}"
|
||||
@if ( $group->emails()->contains($email) )
|
||||
checked="checked"
|
||||
@endif
|
||||
>
|
||||
{{ $email->email }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</details>
|
||||
@endforeach
|
||||
</div>
|
||||
{{-- @include('partials/field_error', ['field'=>'emails.*']) --}}
|
||||
|
|
Loading…
Reference in a new issue