Skip to content

Commit

Permalink
Resend actions on index page (#89)
Browse files Browse the repository at this point in the history
- line item context action
- bulk aktion
- inline action button in transportState column
  • Loading branch information
flkasper authored Oct 4, 2024
1 parent 83509a4 commit 9973eb5
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

<template slot="content">
<sw-entity-listing
ref="table"
v-if="items"
:items="items"
:columns="columns"
:isLoading="isLoading"
:repository="mailArchiveRepository"
@selection-change="onSelectionChanged"
>
<template slot="column-receiver" slot-scope="{ item }">
<span v-for="(element, index) in item.receiver">
Expand All @@ -30,24 +32,64 @@
</template>

<template slot="column-transportState" slot-scope="{ item }">

{{ translateState(item.transportState) }}

<template v-if="item.transportState === 'failed'">
<sw-icon
name="regular-exclamation-triangle"
color="#f00"
class="frosh-mail-archive__data-grid-danger-icon"
v-tooltip="{
message: $tc('frosh-mail-archive.list.columns.transportFailed')
}"
small></sw-icon>
name="regular-exclamation-triangle"
color="#f00"
class="frosh-mail-archive__data-grid-danger-icon"
v-tooltip="{ message: $tc('frosh-mail-archive.list.columns.transportFailed') }"
small
></sw-icon>

<sw-button
square
size="small"
variant="context"
@click="resendMail(item)"
>
<sw-icon
name="regular-undo"
class="frosh-mail-archive__data-grid-danger-icon"
v-tooltip="{ message: $tc('frosh-mail-archive.list.actions.resendAction') }"
small
></sw-icon>
</sw-button>

</template>
{{ translateState(item.transportState) }}
</template>

<template slot="detail-action" slot-scope="{ item }">

<sw-context-menu-item class="sw-entity-listing__context-menu-show-action"
:routerLink="{ name: 'frosh.mail.archive.detail', params: { id: item.id } }">
{{ $tc('frosh-mail-archive.list.columns.action') }}
{{ $tc('frosh-mail-archive.list.actions.showAction') }}
</sw-context-menu-item>

<sw-context-menu-item class="sw-entity-listing__context-menu-show-action" @click="resendMail(item)">
{{ $tc('frosh-mail-archive.list.actions.resendAction') }}
</sw-context-menu-item>

</template>

<template #bulk-additional="{ selectionCount }">
<a
v-if="selectionCount > 0"
class="link link-primary"
@click="onBulkResendClick"
>
{{ $tc('frosh-mail-archive.list.actions.bulkResendAction') }}

<sw-icon
name="regular-exclamation-triangle"
color="orange"
class="frosh-mail-archive__data-grid-warning-icon"
v-tooltip="{ message: $tc('frosh-mail-archive.list.actions.bulkResendWarningTooltip') }"
small
></sw-icon>
</a>
</template>
</sw-entity-listing>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import './frosh-mail-archive-index.scss';

Component.register('frosh-mail-archive-index', {
template,
inject: ['repositoryFactory'],
inject: ['repositoryFactory', 'froshMailArchiveService'],
mixins: [
Mixin.getByName('listing'),
Mixin.getByName('notification'),
],

metaInfo() {
Expand All @@ -30,7 +31,8 @@ Component.register('frosh-mail-archive-index', {
transportState: null,
customerId: null,
term: null
}
},
selectedItems: {},
}
},

Expand Down Expand Up @@ -90,6 +92,7 @@ Component.register('frosh-mail-archive-index', {
translateState(state) {
return this.$tc(`frosh-mail-archive.state.${state}`);
},

getList() {
this.isLoading = true;

Expand Down Expand Up @@ -122,6 +125,45 @@ Component.register('frosh-mail-archive-index', {
});
},

resendMail(item) {
this.isLoading = true;

this.froshMailArchiveService.resendMail(item.id).then(async () => {
this.createNotificationSuccess({
title: this.$tc('frosh-mail-archive.detail.resend-success-notification.title'),
message: this.$tc('frosh-mail-archive.detail.resend-success-notification.message')
});
await this.getList();
}).catch(() => {
this.createNotificationError({
title: this.$tc('frosh-mail-archive.detail.resend-error-notification.title'),
message: this.$tc('frosh-mail-archive.detail.resend-error-notification.message')
});
}).finally(() => {
this.isLoading = false;
});
},

onBulkResendClick() {
const ids = Object.keys(this.selectedItems);
if (ids.length === 0) {
return
}
this.isLoading = true;

Promise.all(ids.map((id) => {
return this.froshMailArchiveService.resendMail(id);
})).finally(async () => {
this.$refs.table?.resetSelection();
await this.getList();
this.isLoading = false;
});
},

onSelectionChanged(selection) {
this.selectedItems = selection;
},

resetFilter() {
this.filter = {
salesChannelId: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
"unknown": "unbekannt"
},
"list": {
"actions": {
"bulkResendAction": "Erneut versenden",
"bulkResendWarningTooltip": "Achtung: Manche MailProvider haben eine Begrenzung, wie viele Mails gleichzeitig versendet werden können.",
"resendAction": "E-Mail erneut versenden",
"showAction": "Anzeigen"
},
"columns": {
"sentDate": "Versanddatum",
"subject": "Betreff",
"receiver": "Empfänger",
"action": "Anzeigen",
"transportState": "Status",
"transportFailed": "Versand der E-Mail fehlgeschlagen"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
"unknown": "unknown"
},
"list": {
"actions": {
"bulkResendAction": "Resend",
"bulkResendWarningTooltip": "Attention: Some mail providers have a limit on how many emails can be sent at the same time.",
"resendAction": "Resend mail",
"showAction": "Show"
},
"columns": {
"sentDate": "Sent date",
"subject": "Subject",
"receiver": "Recipients",
"action": "Show",
"transportState": "State",
"transportFailed": "Mail delivery failed."
},
Expand Down

0 comments on commit 9973eb5

Please sign in to comment.