Skip to content

Commit

Permalink
Add preconfirm optin option to bulk list management UI. Closes #935.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Nov 1, 2022
1 parent ef1f84e commit d8e3e25
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
7 changes: 6 additions & 1 deletion frontend/cypress/e2e/subscribers.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('Subscribers', () => {
it('Does bulk subscriber list add and remove', () => {
const cases = [
// radio: action to perform, rows: table rows to select and perform on: [expected statuses of those rows after thea action]
{ radio: 'check-list-add', lists: [0, 1], rows: { 0: ['unconfirmed', 'unconfirmed'] } },
{ radio: 'check-list-add', lists: [0, 1], rows: { 0: ['confirmed', 'confirmed'] } },
{ radio: 'check-list-unsubscribe', lists: [0, 1], rows: { 0: ['unsubscribed', 'unsubscribed'], 1: ['unsubscribed'] } },
{ radio: 'check-list-remove', lists: [0, 1], rows: { 1: [] } },
{ radio: 'check-list-add', lists: [0, 1], rows: { 0: ['unsubscribed', 'unsubscribed'], 1: ['unconfirmed', 'unconfirmed'] } },
Expand All @@ -101,6 +101,11 @@ describe('Subscribers', () => {
// Select the radio option in the modal.
cy.get(`[data-cy=${c.radio}] .check`).click();

// For the first test, check the optin preconfirm box.
if (n === 0) {
cy.get('[data-cy=preconfirm]').click();
}

// Save.
cy.get('.modal button.is-primary').click();

Expand Down
15 changes: 14 additions & 1 deletion frontend/src/views/SubscriberBulkList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
:selected="form.lists"
:all="lists.results"
></list-selector>

<b-field :message="$t('subscribers.preconfirmHelp')">
<b-checkbox v-model="form.preconfirm" data-cy="preconfirm"
:native-value="true" :disabled="!hasOptinList">
{{ $t('subscribers.preconfirm') }}
</b-checkbox>
</b-field>

</section>

<footer class="modal-card-foot has-text-right">
Expand Down Expand Up @@ -63,19 +71,24 @@ export default Vue.extend({
form: {
action: 'add',
lists: [],
preconfirm: false,
},
};
},
methods: {
onSubmit() {
this.$emit('finished', this.form.action, this.form.lists);
this.$emit('finished', this.form.action, this.form.preconfirm, this.form.lists);
this.$parent.close();
},
},
computed: {
...mapState(['lists', 'loading']),
hasOptinList() {
return this.form.lists.some((l) => l.optin === 'double');
},
},
});
</script>
6 changes: 5 additions & 1 deletion frontend/src/views/Subscribers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,18 @@ export default Vue.extend({
this.$utils.confirm(this.$t('subscribers.confirmDelete', { num: this.numSelectedSubscribers }), fn);
},
bulkChangeLists(action, lists) {
bulkChangeLists(action, preconfirm, lists) {
const data = {
action,
query: this.fullQueryExp,
list_ids: this.queryParams.listID ? [this.queryParams.listID] : null,
target_list_ids: lists.map((l) => l.id),
};
if (preconfirm) {
data.status = 'confirmed';
}
let fn = null;
if (!this.bulk.all && this.bulk.checked.length > 0) {
// If 'all' is not selected, perform by IDs.
Expand Down

0 comments on commit d8e3e25

Please sign in to comment.