|
|
@@ -90,7 +90,10 @@ class EmailComunications extends Component
|
|
|
|
|
|
protected function validateDraft(): void
|
|
|
{
|
|
|
- $this->validate($this->baseRules());
|
|
|
+ $rules = [];
|
|
|
+ // $rules = $this->baseRules();
|
|
|
+ $rules['subject'] = 'required|string|max:255';
|
|
|
+ $this->validate($rules);
|
|
|
}
|
|
|
|
|
|
protected function validateSend(): void
|
|
|
@@ -137,6 +140,13 @@ class EmailComunications extends Component
|
|
|
'first_name' => optional($r->member)->first_name,
|
|
|
'last_name' => optional($r->member)->last_name,
|
|
|
])->toArray();
|
|
|
+ usort($this->recipients, function($a, $b) {
|
|
|
+ $last_name = strcmp($a['last_name'], $b['last_name']);
|
|
|
+ $first_name = strcmp($a['first_name'], $b['first_name']);
|
|
|
+
|
|
|
+ return $last_name == 0 ? $first_name : $last_name;
|
|
|
+ });
|
|
|
+
|
|
|
$this->mode = $msg->status === 'scheduled' ? 'schedule' : 'now';
|
|
|
$this->schedule_at = optional($msg->schedule_at)?->setTimezone($this->timezone)?->format('Y-m-d\TH:i');
|
|
|
$this->existingAttachments = $msg->attachments->map(fn($a) => [
|
|
|
@@ -190,6 +200,7 @@ class EmailComunications extends Component
|
|
|
|
|
|
$this->success = 'Bozza salvata';
|
|
|
|
|
|
+ $this->dispatchBrowserEvent('scroll-top');
|
|
|
$this->dispatchBrowserEvent('load-editor', [
|
|
|
'html' => $this->content_html ?? '',
|
|
|
'locked' => $this->locked,
|
|
|
@@ -221,6 +232,7 @@ class EmailComunications extends Component
|
|
|
dispatch(new \App\Jobs\SendEmailMessage($this->messageId));
|
|
|
$this->success = 'Invio avviato';
|
|
|
|
|
|
+ $this->dispatchBrowserEvent('scroll-top');
|
|
|
$this->dispatchBrowserEvent('load-editor', [
|
|
|
'html' => $this->content_html ?? '',
|
|
|
'locked' => $this->locked,
|
|
|
@@ -253,6 +265,7 @@ class EmailComunications extends Component
|
|
|
|
|
|
$this->success = 'Email programmata';
|
|
|
|
|
|
+ $this->dispatchBrowserEvent('scroll-top');
|
|
|
$this->dispatchBrowserEvent('load-editor', [
|
|
|
'html' => $this->content_html ?? '',
|
|
|
'locked' => $this->locked,
|
|
|
@@ -357,6 +370,13 @@ class EmailComunications extends Component
|
|
|
'first_name' => $m->first_name,
|
|
|
'last_name' => $m->last_name,
|
|
|
];
|
|
|
+
|
|
|
+ usort($this->recipients, function($a, $b) {
|
|
|
+ $last_name = strcmp($a['last_name'], $b['last_name']);
|
|
|
+ $first_name = strcmp($a['first_name'], $b['first_name']);
|
|
|
+
|
|
|
+ return $last_name == 0 ? $first_name : $last_name;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
public function removeNewAttachment(int $index): void
|