Skip to content

Commit

Permalink
Cherry pick PR89 and PR91 (#95)
Browse files Browse the repository at this point in the history
* Bugfix sidebar slot (#91)

* Resend actions on index page (#89)

- line item context action
- bulk aktion
- inline action button in transportState column

---------

Co-authored-by: FK <[email protected]>
  • Loading branch information
schneider-felix and flkasper authored Oct 9, 2024
1 parent 2ee23f2 commit b1f6fe1
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
</template>
<template #content>
<sw-entity-listing
ref="table"
v-if="items"
:items="items"
:columns="columns"
:isLoading="isLoading"
:repository="mailArchiveRepository"
@selection-change="onSelectionChanged"
>
<template #column-receiver="{ item }">
<span v-for="(element, index) in item.receiver">
Expand All @@ -27,25 +29,63 @@
{{ date(item.createdAt, {hour: '2-digit', minute: '2-digit', second: '2-digit'}) }}
</template>

<template slot="column-transportState" slot-scope="{ item }">
<template #column-transportState="{ 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 #detail-action="{ 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 @@ -93,6 +95,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 @@ -125,6 +128,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 b1f6fe1

Please sign in to comment.