Add the ability to select Customers Groups when starting a new Conversation

This is only a cosmetic addition for now, the selected groups are ignored when the form is submitted.
This commit is contained in:
Antoine Le Gonidec 2024-07-18 16:18:10 +02:00
parent 1a9d95bb04
commit 48c129c812
Signed by: vv221
GPG key ID: 636B78F91CEB80D8
2 changed files with 57 additions and 2 deletions

View file

@ -6,8 +6,13 @@
namespace Modules\MMFCustomersGroups\Providers;
use Eventy;
use View;
use Illuminate\Support\ServiceProvider;
use Modules\MMFCustomersGroups\Entities\Mailbox;
class MMFCustomersGroupsServiceProvider extends ServiceProvider {
/**
* Indicates if loading of the provider is deferred.
@ -75,8 +80,22 @@ 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);
}
}

View file

@ -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>