diff --git a/client/components/modals/emails/EReaderDeviceModal.vue b/client/components/modals/emails/EReaderDeviceModal.vue index 79d80f7c..70b295ae 100644 --- a/client/components/modals/emails/EReaderDeviceModal.vue +++ b/client/components/modals/emails/EReaderDeviceModal.vue @@ -46,7 +46,12 @@ export default { ereaderDevice: { type: Object, default: () => null - } + }, + users: { + type: Array, + default: () => [] + }, + loadUsers: Function }, data() { return { @@ -56,8 +61,7 @@ export default { email: '', availabilityOption: 'adminAndUp', users: [] - }, - users: [] + } } }, watch: { @@ -108,25 +112,13 @@ export default { methods: { availabilityOptionChanged(option) { if (option === 'specificUsers' && !this.users.length) { - this.loadUsers() + this.callLoadUsers() } }, - async loadUsers() { + async callLoadUsers() { this.processing = true - this.users = await this.$axios - .$get('/api/users') - .then((res) => { - return res.users.sort((a, b) => { - return a.createdAt - b.createdAt - }) - }) - .catch((error) => { - console.error('Failed', error) - return [] - }) - .finally(() => { - this.processing = false - }) + await this.loadUsers() + this.processing = false }, submitForm() { this.$refs.ereaderNameInput.blur() @@ -226,10 +218,6 @@ export default { this.newDevice.email = this.ereaderDevice.email this.newDevice.availabilityOption = this.ereaderDevice.availabilityOption || 'adminOrUp' this.newDevice.users = this.ereaderDevice.users || [] - - if (this.newDevice.availabilityOption === 'specificUsers' && !this.users.length) { - this.loadUsers() - } } else { this.newDevice.name = '' this.newDevice.email = '' diff --git a/client/pages/config/email.vue b/client/pages/config/email.vue index 32609173..47aec621 100644 --- a/client/pages/config/email.vue +++ b/client/pages/config/email.vue @@ -91,12 +91,12 @@ -
No Devices