Compare commits

..

No commits in common. "4a3410de812b58cafb7e5068aecbbf20da44eb90" and "1a9d95bb0475f3557eafe7313d262462f0002307" have entirely different histories.

2 changed files with 2 additions and 74 deletions

View file

@ -6,15 +6,8 @@
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.
@ -82,37 +75,8 @@ 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);
}
}

View file

@ -1,36 +0,0 @@
<?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>