Skip to content

Commit

Permalink
Rename draft status to unsent
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Sep 16, 2024
1 parent f791305 commit 4c97eb0
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Improved the status colours of element types.
- Improved the French translation ([#484](https://github.com/putyourlightson/craft-campaign/issues/484)).
- Improved the German translation.
- Renamed the “draft” sendout status to “unsent”.

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "putyourlightson/craft-campaign",
"description": "Send and manage email campaigns, contacts and mailing lists.",
"version": "3.4.4",
"version": "3.5.0",
"type": "craft-plugin",
"homepage": "https://putyourlightson.com/plugins/campaign",
"license": "proprietary",
Expand Down
2 changes: 1 addition & 1 deletion src/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public static function editions(): array
/**
* @inheritdoc
*/
public string $schemaVersion = '3.1.2';
public string $schemaVersion = '3.5.0';

/**
* @inheritdoc
Expand Down
23 changes: 17 additions & 6 deletions src/elements/SendoutElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,34 +68,41 @@ class SendoutElement extends Element
* @const string
*/
public const STATUS_SENT = 'sent';

/**
* @const string
*/
public const STATUS_SENDING = 'sending';

/**
* @const string
*/
public const STATUS_QUEUED = 'queued';

/**
* @const string
*/
public const STATUS_PENDING = 'pending';

/**
* @const string
*/
public const STATUS_PAUSED = 'paused';

/**
* @const string
*/
public const STATUS_CANCELLED = 'cancelled';

/**
* @const string
*/
public const STATUS_FAILED = 'failed';

/**
* @const string
*/
public const STATUS_DRAFT = 'draft';
public const STATUS_UNSENT = 'unsent';

/**
* Returns the sendout types.
Expand Down Expand Up @@ -221,6 +228,10 @@ public static function statuses(): array
'label' => Craft::t('campaign', 'Failed'),
'color' => Color::Black,
],
self::STATUS_UNSENT => [
'label' => Craft::t('campaign', 'Unsent'),
'color' => Color::Gray,
],
];
}

Expand Down Expand Up @@ -410,7 +421,7 @@ protected static function defineSearchableAttributes(): array
/**
* @var string Send status
*/
public string $sendStatus = self::STATUS_DRAFT;
public string $sendStatus = self::STATUS_UNSENT;

/**
* @var string|null Send from name/email/reply combo, used for posted params
Expand Down Expand Up @@ -809,7 +820,7 @@ public function getProgressFraction(): float
*/
public function getProgress(): string
{
if ($this->sendStatus == self::STATUS_DRAFT || $this->sendoutType == 'automated' || $this->sendoutType == 'recurring') {
if ($this->sendStatus == self::STATUS_UNSENT || $this->sendoutType == 'automated' || $this->sendoutType == 'recurring') {
return '';
}

Expand Down Expand Up @@ -1078,7 +1089,7 @@ public function getStatus(): ?string
*/
public function getIsModifiable(): bool
{
return ($this->getStatus() == self::STATUS_DRAFT || $this->getStatus() == self::STATUS_PAUSED);
return ($this->getStatus() == self::STATUS_UNSENT || $this->getStatus() == self::STATUS_PAUSED);
}

/**
Expand Down Expand Up @@ -1122,7 +1133,7 @@ public function getIsResumable(): bool
*/
public function getIsCancellable(): bool
{
return ($this->getStatus() != self::STATUS_DRAFT && $this->getStatus() != self::STATUS_CANCELLED && $this->getStatus() != self::STATUS_SENT);
return ($this->getStatus() != self::STATUS_UNSENT && $this->getStatus() != self::STATUS_CANCELLED && $this->getStatus() != self::STATUS_SENT);
}

/**
Expand Down Expand Up @@ -1217,7 +1228,7 @@ public function beforeSave(bool $isNew): bool
// Reset stats if this is a duplicate of a non-draft sendout.
if ($this->firstSave && $this->duplicateOf !== null) {
$this->senderId = null;
$this->sendStatus = self::STATUS_DRAFT;
$this->sendStatus = self::STATUS_UNSENT;
$this->recipients = 0;
$this->failures = 0;
$this->failedContactIds = null;
Expand Down
29 changes: 29 additions & 0 deletions src/migrations/m240915_120000_convert_draft_status.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace putyourlightson\campaign\migrations;

use craft\db\Migration;
use putyourlightson\campaign\records\SendoutRecord;

class m240915_120000_convert_draft_status extends Migration
{
/**
* @inheritdoc
*/
public function safeUp(): bool
{
$this->update(SendoutRecord::tableName(), ['sendStatus' => 'unsent'], ['sendStatus' => 'draft']);

return true;
}

/**
* @inheritdoc
*/
public function safeDown(): bool
{
echo self::class . " cannot be reverted.\n";

return false;
}
}
2 changes: 1 addition & 1 deletion src/templates/sendouts/_preview.twig
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
</div>
</div>

{% if sendout.status == 'draft' and sendout.sendoutType != 'automated' %}
{% if sendout.status == 'unsent' and sendout.sendoutType != 'automated' %}

<div class="data">
<h5 class="heading">{{ "Expected Recipients"|t('campaign') }}</h5>
Expand Down
2 changes: 1 addition & 1 deletion src/translations/de/campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@
'does not end with' => 'ended nicht mit',
'does not equal' => 'entspricht nicht',
'does not start with' => 'beginnt nicht mit',
'Draft' => 'Entwurf',
'Edit campaign' => 'Kampagne bearbeiten',
'Edit contact' => 'Kontakt bearbeiten',
'Edit mailing list' => 'Mailing-Liste bearbeiten',
Expand Down Expand Up @@ -662,6 +661,7 @@
'Unmark contact as blocked' => 'Kontakt nicht mehr als `blockiert` markieren',
'Unmark contact as bounced' => 'Kontakt nicht mehr als `bounced` markieren',
'Unmark contact as complained' => 'Kontakt nicht mehr als `complained` markieren',
'Unsent' => 'Ungesendet',
'Unsubscribe' => 'Abmelden',
'Unsubscribe Form Allowed' => 'Abmeldeformular erlauben',
'Unsubscribe from “{mailingList}”' => 'Mailing-Liste “{mailingList}” abmelden',
Expand Down
2 changes: 1 addition & 1 deletion src/translations/en/campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@
'does not end with' => '',
'does not equal' => '',
'does not start with' => '',
'Draft' => '',
'Edit campaign' => '',
'Edit contact' => '',
'Edit mailing list' => '',
Expand Down Expand Up @@ -661,6 +660,7 @@
'Unmark contact as blocked' => '',
'Unmark contact as bounced' => '',
'Unmark contact as complained' => '',
'Unsent' => '',
'Unsubscribe' => '',
'Unsubscribe Form Allowed' => '',
'Unsubscribe from “{mailingList}”' => '',
Expand Down
2 changes: 1 addition & 1 deletion src/translations/fr/campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@
'does not end with' => 'ne se terminant pas avec',
'does not equal' => 'n’est pas égale à',
'does not start with' => 'ne commençant pas par',
'Draft' => 'Brouillon',
'Edit campaign' => 'Éditer newsletter',
'Edit contact' => 'Éditer contact',
'Edit mailing list' => 'Éditer liste de diffusion',
Expand Down Expand Up @@ -662,6 +661,7 @@
'Unmark contact as blocked' => 'Ne plus marquer le contact comme bloqué',
'Unmark contact as bounced' => 'Ne plus marquer le contact comme rejeté',
'Unmark contact as complained' => 'Ne plus marquer le contact comme plaignant',
'Unsent' => 'Non envoyé',
'Unsubscribe' => 'Désabonné',
'Unsubscribe Form Allowed' => 'Formulaire de désabonnement autorisé',
'Unsubscribe from “{mailingList}”' => 'Désabonné de “{mailingList}”',
Expand Down

0 comments on commit 4c97eb0

Please sign in to comment.