Warn of unsaved changes on the campaign editor on navigation. Closes #551.

This commit is contained in:
Kailash Nadh 2022-01-15 17:20:22 +05:30
parent 4c09cc1fc3
commit c6d5d862e2
18 changed files with 41 additions and 18 deletions

View file

@ -172,8 +172,8 @@ export default {
isReady: false,
isRichtextReady: false,
isRichtextSourceVisible: false,
richtextConf: {},
isTrackLink: false,
richtextConf: {},
richTextSourceBody: '',
form: {
body: '',

View file

@ -47,7 +47,7 @@
<b-loading :active="loading.campaigns"></b-loading>
<b-tabs type="is-boxed" :animated="false" v-model="activeTab">
<b-tabs type="is-boxed" :animated="false" v-model="activeTab" @input="onTab">
<b-tab-item :label="$tc('globals.terms.campaign')" label-position="on-border"
icon="rocket-launch-outline">
<section class="wrap">
@ -267,6 +267,19 @@ export default Vue.extend({
this.isHeadersVisible = !this.isHeadersVisible;
},
isUnsaved() {
return this.data.body !== this.form.content.body
|| this.data.contentType !== this.form.content.contentType;
},
onTab(t) {
if (t === 1 && window.tinymce && window.tinymce.editors.length > 0) {
this.$nextTick(() => {
window.tinymce.editors[0].focus();
});
}
},
onSubmit(typ) {
if (this.form.headersStr && this.form.headersStr !== '[]') {
try {
@ -444,6 +457,14 @@ export default Vue.extend({
},
},
beforeRouteLeave(to, from, next) {
if (this.isUnsaved()) {
this.$utils.confirm(this.$t('globals.messages.confirmDiscard'), () => next(true));
return;
}
next(true);
},
watch: {
selectedLists() {
this.form.lists = this.selectedLists;
@ -451,6 +472,8 @@ export default Vue.extend({
},
mounted() {
window.onbeforeunload = () => this.isUnsaved() || null;
this.form.fromEmail = this.settings['app.from_email'];
const { id } = this.$route.params;

View file

@ -230,7 +230,7 @@ export default Vue.extend({
beforeRouteLeave(to, from, next) {
if (this.hasFormChanged) {
this.$utils.confirm(this.$t('settings.messengers.messageDiscard'), () => next(true));
this.$utils.confirm(this.$t('globals.messages.confirmDiscard'), () => next(true));
return;
}
next(true);

View file

@ -144,6 +144,7 @@
"globals.fields.updatedAt": "Aktualizováno",
"globals.fields.uuid": "UUID",
"globals.messages.confirm": "Jste si jisti?",
"globals.messages.confirmDiscard": "Zrušit změny?",
"globals.messages.created": "\"{name}\" vytvořen",
"globals.messages.deleted": "\"{name}\" odstraněn",
"globals.messages.deletedCount": "{name} ({num}) odstraněn",
@ -388,7 +389,6 @@
"settings.media.upload.uriHelp": "URI odeslání viditelný vnějšímu světu. Média odeslaná do cesty_k_odeslání budou veřejně přístupná pod adresou {root_url}, např. https://listmonk.yoursite.com/uploads.",
"settings.messengers.maxConns": "Maximální počet připojení",
"settings.messengers.maxConnsHelp": "Maximální počet souběžných připojení k serveru.",
"settings.messengers.messageDiscard": "Zrušit změny?",
"settings.messengers.messageSaved": "Nastavení uloženo. Znovu se načítá aplikace...",
"settings.messengers.name": "Kurýři",
"settings.messengers.nameHelp": "např.: my-sms. Alfanumerika / pomlčka.",

View file

@ -144,6 +144,7 @@
"globals.fields.updatedAt": "Aktualisiert",
"globals.fields.uuid": "UUID",
"globals.messages.confirm": "Bist du sicher?",
"globals.messages.confirmDiscard": "Änderungen verwerfen?",
"globals.messages.created": "\"{name}\" erstellt",
"globals.messages.deleted": "\"{name}\" gelöscht",
"globals.messages.deletedCount": "{name} ({num}) gelöscht",
@ -388,7 +389,6 @@
"settings.media.upload.uriHelp": "Upload URI, welche öffentlich sichtbar ist. Die hochgeladenen Medien sind öffentlich erreich unter {root_url}, z.B. https://listmonk.yoursite.com/uploads.",
"settings.messengers.maxConns": "Max. Verbindungen",
"settings.messengers.maxConnsHelp": "Maximale gleichzeitige Verbindungen zum SMTP Server.",
"settings.messengers.messageDiscard": "Änderungen verwerfen?",
"settings.messengers.messageSaved": "Einstellungen gespeichert. Lade neu...",
"settings.messengers.name": "Messenger",
"settings.messengers.nameHelp": "z.B.: my-sms. Alphanumerisch / Bindestrich.",

View file

@ -144,6 +144,7 @@
"globals.fields.updatedAt": "Updated",
"globals.fields.uuid": "UUID",
"globals.messages.confirm": "Are you sure?",
"globals.messages.confirmDiscard": "Discard changes?",
"globals.messages.created": "\"{name}\" created",
"globals.messages.deleted": "\"{name}\" deleted",
"globals.messages.deletedCount": "{name} ({num}) deleted",
@ -388,7 +389,6 @@
"settings.media.upload.uriHelp": "Upload URI that is visible to the outside world. The media uploaded to upload_path will be publicly accessible under {root_url}, for instance, https://listmonk.yoursite.com/uploads.",
"settings.messengers.maxConns": "Max. connections",
"settings.messengers.maxConnsHelp": "Maximum concurrent connections to the server.",
"settings.messengers.messageDiscard": "Discard changes?",
"settings.messengers.messageSaved": "Settings saved. Reloading app ...",
"settings.messengers.name": "Messengers",
"settings.messengers.nameHelp": "eg: my-sms. Alphanumeric / dash.",

View file

@ -144,6 +144,7 @@
"globals.fields.updatedAt": "Actualizado",
"globals.fields.uuid": "UUID",
"globals.messages.confirm": "¿Está seguro?",
"globals.messages.confirmDiscard": "¿Descartar cambios?",
"globals.messages.created": "\"{name}\" creado",
"globals.messages.deleted": "\"{name}\" borrado",
"globals.messages.deletedCount": "{name} ({num}) borrado",
@ -388,7 +389,6 @@
"settings.media.upload.uriHelp": "La URI de carga es visible hacia afuera. La media cargada en el directorio de carga será accesible públicamente bajo {root_url}, por ejemplo, https://listmonk.susitio.com/uploads",
"settings.messengers.maxConns": "Conexiones máximas",
"settings.messengers.maxConnsHelp": "Número máximo de conexiones al servidor",
"settings.messengers.messageDiscard": "¿Descartar cambios?",
"settings.messengers.messageSaved": "Configuracion guardada. Recargando la aplicación.",
"settings.messengers.name": "Mensajeros",
"settings.messengers.nameHelp": "Ejemplo: my-sms. Alfanumérico / guión",

View file

@ -144,6 +144,7 @@
"globals.fields.updatedAt": "Mis à jour le",
"globals.fields.uuid": "UUID",
"globals.messages.confirm": "Confirmer ?",
"globals.messages.confirmDiscard": "Annuler les modifications ?",
"globals.messages.created": "Création de \"{name}\"",
"globals.messages.deleted": "Suppression de \"{name}\"",
"globals.messages.deletedCount": "{name} ({num}) effacé(s)",
@ -388,7 +389,6 @@
"settings.media.upload.uriHelp": "URI d'envoi des fichiers (qui sera visible du monde extérieur). Les médias stockés à cet emplacement seront accessible publiquement sous {root_url}, par exemple à l'adresse : https://listmonk.votresite.com/uploads",
"settings.messengers.maxConns": "Nombre de connexions max.",
"settings.messengers.maxConnsHelp": "Nombre maximum de connexions simultanées au serveur",
"settings.messengers.messageDiscard": "Annuler les modifications ?",
"settings.messengers.messageSaved": "Paramètres sauvegardés. Redémarrage de l'application...",
"settings.messengers.name": "Nom du service d'envoi de messages",
"settings.messengers.nameHelp": "Par exemple : my-sms. Utilisez uniquement des caractères alphanumériques et des tirets.",

View file

@ -144,6 +144,7 @@
"globals.fields.updatedAt": "Frissítve",
"globals.fields.uuid": "UUID",
"globals.messages.confirm": "biztos vagy ebben?",
"globals.messages.confirmDiscard": "Módosítások elvetése?",
"globals.messages.created": "\"{name}\" készítette",
"globals.messages.deleted": "\"{name}\" törölte",
"globals.messages.deletedCount": "{name} ({num}) törölve",
@ -388,7 +389,6 @@
"settings.media.upload.uriHelp": "Töltse fel a külvilág számára látható URI-t. Az upload_path címre feltöltött média nyilvánosan elérhető lesz például a {root_url} alatt , https://listmonk.yoursite.com/uploads.",
"settings.messengers.maxConns": "Max. kapcsolatokat ",
"settings.messengers.maxConnsHelp": "Maximális egyidejű kapcsolat a szerverrel .",
"settings.messengers.messageDiscard": "Módosítások elvetése?",
"settings.messengers.messageSaved": "Beállítások elmentve. Alkalmazás újratöltése.",
"settings.messengers.name": "Messengers",
"settings.messengers.nameHelp": "eg: my-sms. Alphanumeric / dash.",

View file

@ -144,6 +144,7 @@
"globals.fields.updatedAt": "Aggiornato il",
"globals.fields.uuid": "UUID",
"globals.messages.confirm": "Sei sicuro?",
"globals.messages.confirmDiscard": "Annullare le modifiche?",
"globals.messages.created": "\"{name}\" creato",
"globals.messages.deleted": "\"{name}\" cancellato",
"globals.messages.deletedCount": "{name} ({num}) deleted",
@ -388,7 +389,6 @@
"settings.media.upload.uriHelp": "URI del caricamento che sarà visibile dal mondo esterno. Il media caricato nel percorso del caricamento sarà accessibile pubblicamente sotto {root_url}, per esempio: https://listmonk.tuosito.com/uploads.",
"settings.messengers.maxConns": "Nb. connessioni max.",
"settings.messengers.maxConnsHelp": "Numero massimo di connessioni simultanee al server.",
"settings.messengers.messageDiscard": "Annullare le modifiche?",
"settings.messengers.messageSaved": "Parametri salvati. Ricarica dell'applicazione...",
"settings.messengers.name": "Strumento di messaggeria",
"settings.messengers.nameHelp": "Per esempio: my-sms. Alfanumerico / trattino.",

View file

@ -144,6 +144,7 @@
"globals.fields.updatedAt": "പുതുക്കിയത്",
"globals.fields.uuid": "യുയുഐഡി",
"globals.messages.confirm": "താങ്കൾക്ക് തീർച്ചയാണോ?",
"globals.messages.confirmDiscard": "മാറ്റങ്ങൾ നിരസിക്കട്ടെ?",
"globals.messages.created": "\"{name}\" നിർമ്മിച്ചു",
"globals.messages.deleted": "\"{name}\" നീക്കം ചെയ്തു",
"globals.messages.deletedCount": "{name} ({num}) deleted",
@ -388,7 +389,6 @@
"settings.media.upload.uriHelp": "അപ്ലോഡ് യൂ. ആർ. ഐ പൊതുവായി ദ്രശ്യമായിരിക്കും. `upload_path` ലേക്ക് അപ്ലോഡ് ചെയ്ത മീഡിയകൾ {root_url} ൽ എല്ലാവർക്കും പ്രാപ്യമായിരിക്കും. ഉദാഹരണത്തിന് https://listmonk.yoursite.com/uploads.",
"settings.messengers.maxConns": "പരമാവധി കണക്ഷനുകൾ",
"settings.messengers.maxConnsHelp": "എസ്. എം. ടീ. പി സേർവ്വറിലേയ്ക്കുള്ള പരമാവധി സമാന്തര കണക്ഷനുകൾ.",
"settings.messengers.messageDiscard": "മാറ്റങ്ങൾ നിരസിക്കട്ടെ?",
"settings.messengers.messageSaved": "ക്രമീകരണങ്ങൾ സംരക്ഷിച്ചു. ആപ്പ് പുനരാരംഭിക്കുന്നു ...",
"settings.messengers.name": "സന്ദേശ വാഹകർ",
"settings.messengers.nameHelp": "ഉദാഹരണം: എന്റെ-ലിസ്റ്റ്. അക്കങ്ങളും അക്ഷരങ്ങളും / ഡാഷും.",

View file

@ -144,6 +144,7 @@
"globals.fields.updatedAt": "geüpdatet",
"globals.fields.uuid": "UUID",
"globals.messages.confirm": "Ben je zeker?",
"globals.messages.confirmDiscard": "Veranderingen weggooien?",
"globals.messages.created": "\"{name}\" aangemaakt",
"globals.messages.deleted": "\"{name}\" verwijderd",
"globals.messages.deletedCount": "{name} ({num}) verwijderd",
@ -388,7 +389,6 @@
"settings.media.upload.uriHelp": "Upload URI zichtbaar voor de buitenwereld. De media geüpload naar upload_path zal publiek beschikbaar zijn onder {root_url}, bijvoorbeeld, https://listmonk.yoursite.com/uploads.",
"settings.messengers.maxConns": "Max. connecties",
"settings.messengers.maxConnsHelp": "Maximum concurrente connecties naar de server.",
"settings.messengers.messageDiscard": "Veranderingen weggooien?",
"settings.messengers.messageSaved": "Instellingen opgeslagen. App wordt herstart...",
"settings.messengers.name": "Messengers",
"settings.messengers.nameHelp": "Bv: my-sms. Alphanumerisch / koppelteken.",

View file

@ -144,6 +144,7 @@
"globals.fields.updatedAt": "Zaktualizowano",
"globals.fields.uuid": "UUID",
"globals.messages.confirm": "Na pewno?",
"globals.messages.confirmDiscard": "Odrzucić zmiany?",
"globals.messages.created": "\"{name}\" utworzono",
"globals.messages.deleted": "\"{name}\" usunięto",
"globals.messages.deletedCount": "{name} ({num}) deleted",
@ -388,7 +389,6 @@
"settings.media.upload.uriHelp": "URI do wysyłki jest widoczna dla świata zewnętrznego. Wrzucone media do upload_path będą publicznie dostępne pod {root_url} np https://listmonk.yoursite.com/uploads.",
"settings.messengers.maxConns": "Maksymalna liczba połąćzeń",
"settings.messengers.maxConnsHelp": "Maksymalna liczba jednoczesnych połączeń do serwera.",
"settings.messengers.messageDiscard": "Odrzucić zmiany?",
"settings.messengers.messageSaved": "Ustawienia zapisane. Przeładowuję aplikację...",
"settings.messengers.name": "Komunikatory",
"settings.messengers.nameHelp": "np: my-sms. Alfanumeryczne / myślnik.",

View file

@ -144,6 +144,7 @@
"globals.fields.updatedAt": "Atualizado",
"globals.fields.uuid": "UUID",
"globals.messages.confirm": "Tem certeza?",
"globals.messages.confirmDiscard": "Descartar alterações?",
"globals.messages.created": "\"{name}\" criado",
"globals.messages.deleted": "\"{name}\" excluído",
"globals.messages.deletedCount": "{name} ({num}) deleted",
@ -388,7 +389,6 @@
"settings.media.upload.uriHelp": "URI de envio que é visível ao mundo exterior. Todas as mídias enviadas para o upload_path será publicamente acessível em {root_url}, por exemplo, https://listmonk.exemplo.com.br/uploads.",
"settings.messengers.maxConns": "Máx. conexões",
"settings.messengers.maxConnsHelp": "Máximo de conexões simultâneas para o servidor.",
"settings.messengers.messageDiscard": "Descartar alterações?",
"settings.messengers.messageSaved": "Configurações salvas. Recarregando o aplicativo...",
"settings.messengers.name": "Mensageiros",
"settings.messengers.nameHelp": "ex: meu-sms. Alfanuméricos / traço.",

View file

@ -144,6 +144,7 @@
"globals.fields.updatedAt": "Atualizado a",
"globals.fields.uuid": "UUID",
"globals.messages.confirm": "Tens a certeza?",
"globals.messages.confirmDiscard": "Descartar alterações?",
"globals.messages.created": "\"{name}\" criado",
"globals.messages.deleted": "\"{name}\" eliminado",
"globals.messages.deletedCount": "{name} ({num}) deleted",
@ -388,7 +389,6 @@
"settings.media.upload.uriHelp": "URI de envio que é visível ao mundo exterior. Toda a mídia enviada para o upload_path será publicamente acessível em {root_url}/{}, por exemplo, https://listmonk.oteusite.com/uploads.",
"settings.messengers.maxConns": "N. Max. Conexões",
"settings.messengers.maxConnsHelp": "Número máximo de conexões simultâneas ao servidor.",
"settings.messengers.messageDiscard": "Descartar alterações?",
"settings.messengers.messageSaved": "Definições guardadas. Recarregando aplicação ...",
"settings.messengers.name": "Mensageiros",
"settings.messengers.nameHelp": "eg: o-meu-sms. Alfanumérico / traço.",

View file

@ -144,6 +144,7 @@
"globals.fields.updatedAt": "Actualizat",
"globals.fields.uuid": "UUID",
"globals.messages.confirm": "Ești sigur/ă?",
"globals.messages.confirmDiscard": "Renunți la modificări?",
"globals.messages.created": "\"{nume}\" creat",
"globals.messages.deleted": "\"{nume}\" șters",
"globals.messages.deletedCount": "{nume} ({număr}) șters",
@ -388,7 +389,6 @@
"settings.media.upload.uriHelp": "Încarcă un URI care este vizibil pentru lumea exterioară. Mediile încărcate în upload_path vor fi accesibile publicului sub {root_url}, de exemplu, https://listmonk.yoursite.com/uploads.",
"settings.messengers.maxConns": "Conexiuni maxime",
"settings.messengers.maxConnsHelp": "Conexiuni maxime simultane la server.",
"settings.messengers.messageDiscard": "Renunți la modificări?",
"settings.messengers.messageSaved": "Setari Salvate. Se reîncarcă aplicația ...",
"settings.messengers.name": "Mesageri",
"settings.messengers.nameHelp": "ex: my-sms. Alfanumeric / liniuță.",

View file

@ -144,6 +144,7 @@
"globals.fields.updatedAt": "Обновлено",
"globals.fields.uuid": "UUID",
"globals.messages.confirm": "Уверены?",
"globals.messages.confirmDiscard": "Отказаться от изменений?",
"globals.messages.created": "\"{name}\" создано",
"globals.messages.deleted": "\"{name}\" удалено",
"globals.messages.deletedCount": "{name} ({num}) deleted",
@ -388,7 +389,6 @@
"settings.media.upload.uriHelp": "URI выгрузок, который будет видим снаружи. Медиа-файлы, выгруженные в upload_path, будут доступны публично через {root_url}, например, https://listmonk.yoursite.com/uploads.",
"settings.messengers.maxConns": "Максимальное число соединений",
"settings.messengers.maxConnsHelp": "Максимальное число одновременных соединений к серверу.",
"settings.messengers.messageDiscard": "Отказаться от изменений?",
"settings.messengers.messageSaved": "Параметры сохранены. Перезагружаем приложение...",
"settings.messengers.name": "Мессенджеры",
"settings.messengers.nameHelp": "Напр.: my-sms. Цифры буквы / тире.",

View file

@ -144,6 +144,7 @@
"globals.fields.updatedAt": "Güncelleme",
"globals.fields.uuid": "UUID",
"globals.messages.confirm": "Eminmisiniz?",
"globals.messages.confirmDiscard": "Değişiklikleri yoksay?",
"globals.messages.created": "\"{name}\" oluşturma",
"globals.messages.deleted": "\"{name}\" silme",
"globals.messages.deletedCount": "{name} ({num}) deleted",
@ -388,7 +389,6 @@
"settings.media.upload.uriHelp": "Dış dünya tarafından görülebilen URI'yi yükleyin. Upload_path'e yüklenen medyaya {root_url} altından herkese açık erişime sahip olacak, örneğin https://www.siteniz.com/uploads.",
"settings.messengers.maxConns": "Maksimum bağlantı",
"settings.messengers.maxConnsHelp": "Sunucuya maksimum çoklu bağlantı.",
"settings.messengers.messageDiscard": "Değişiklikleri yoksay?",
"settings.messengers.messageSaved": "Ayarlar kaydedildi. Uygulama yeniden yükleniyor ...",
"settings.messengers.name": "Messengerlar",
"settings.messengers.nameHelp": "örn.: my-sms. Alpfanumerik / bölü.",