Compare commits
2 commits
1a9d95bb04
...
4a3410de81
Author | SHA1 | Date | |
---|---|---|---|
4a3410de81 | |||
48c129c812 |
2 changed files with 74 additions and 2 deletions
|
@ -6,8 +6,15 @@
|
|||
|
||||
namespace Modules\MMFCustomersGroups\Providers;
|
||||
|
||||
use Eventy;
|
||||
use View;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
use Modules\MMFCustomersGroups\Entities\CustomersGroup;
|
||||
use Modules\MMFCustomersGroups\Entities\Mailbox;
|
||||
|
||||
class MMFCustomersGroupsServiceProvider extends ServiceProvider {
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
|
@ -75,8 +82,37 @@ class MMFCustomersGroupsServiceProvider extends ServiceProvider {
|
|||
*/
|
||||
public function hooks() {
|
||||
// Add a menu entry to manage the customer groups.
|
||||
\Eventy::addAction('menu.manage.after_mailboxes', function() {
|
||||
echo \View::make('mmfcustomersgroups::partials/menu', [])->render();
|
||||
Eventy::addAction('menu.manage.after_mailboxes', function() {
|
||||
echo View::make('mmfcustomersgroups::partials/menu', [])->render();
|
||||
});
|
||||
|
||||
// Add a list of customer groups to select from when writing a new conversation.
|
||||
Eventy::addAction('conversation.create_form.before_subject', function($conversation, $mailbox, $thread) {
|
||||
// We must fetch a fresh Mailbox instance,
|
||||
// as the one that has been passed does not have a "groups" relationship.
|
||||
$mailbox = Mailbox::find($mailbox->id);
|
||||
$groups = $mailbox->groups;
|
||||
echo View::make(
|
||||
'mmfcustomersgroups::conversations/partials/groups-selection',
|
||||
[
|
||||
'groups' => $groups,
|
||||
],
|
||||
)->render();
|
||||
}, 20, 3);
|
||||
|
||||
// Update the list of recipients if some groups have been selected.
|
||||
Eventy::addAction('conversation.send_reply_save', function($conversation, $request) {
|
||||
$groups = $request->groups;
|
||||
// Return early if no group has been selected.
|
||||
if ( empty($groups) ) return;
|
||||
// Get the list of e-mails included in the selected groups.
|
||||
$emails = new Collection;
|
||||
foreach ( $groups as $group_id ) {
|
||||
$group = CustomersGroup::find($group_id);
|
||||
$emails->concat($group->emails());
|
||||
}
|
||||
$emails = $emails->unique();
|
||||
// TODO: Update $conversation to include this list of e-mails.
|
||||
}, 20, 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/*
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
SPDX-FileCopyrightText: © 2024 Millions Missing FRANCE <info@millionsmissing.fr>
|
||||
*/
|
||||
?>
|
||||
|
||||
@include('partials/flash_messages')
|
||||
|
||||
<!-- List of Customers Groups that should be included in this Conversation -->
|
||||
<div class="form-group{{ $errors->has('groups') ? ' has-error' : '' }}">
|
||||
<label for="groups" class="col-sm-2 control-label">{{ __('Groups selection') }}</label>
|
||||
<div class="col-sm-9">
|
||||
<div class="multi-container">
|
||||
@foreach ( $groups as $group )
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label
|
||||
class="control-label checkbox"
|
||||
for="group-{{ $group->id }}"
|
||||
style="text-align: left;"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="groups[]"
|
||||
id="group-{{ $group->id }}"
|
||||
value="{{ $group->id }}"
|
||||
>
|
||||
{{ $group->name }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in a new issue