Skip to content

Commit 112614c

Browse files
author
Julien Veyssier
committed
one single field in docusign request modal to select users and email addresses
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
1 parent ea785e0 commit 112614c

File tree

2 files changed

+52
-33
lines changed

2 files changed

+52
-33
lines changed

src/components/DocuSignModal.vue

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,16 @@
99
</h2>
1010
<span class="field-label">
1111
<span class="icon icon-user" />
12-
{{ t('approval', 'Users') }}
12+
{{ t('approval', 'Users or email addresses') }}
1313
</span>
1414
<MultiselectWho
1515
class="userInput"
16-
:value="selectedUsers"
16+
:value="selectedItems"
1717
:max-height="200"
1818
:types="[0]"
19+
:enable-emails="true"
1920
:placeholder="t('approval', 'Choose Nextcloud users')"
20-
@update:value="updateSelectedUsers($event)" />
21-
<span class="field-label">
22-
<span class="icon icon-mail" />
23-
{{ t('approval', 'Email addresses (coma separated)') }}
24-
</span>
25-
<input v-model="emails"
26-
:placeholder="t('approval', 'Coma separated email addresses')"
27-
type="text">
21+
@update:value="updateSelectedItems($event)" />
2822
<p class="settings-hint">
2923
{{ t('approval', 'Recipients will receive an email from DocuSign with a link to sign the document. You will be informed by email when the document has been signed by all recipients.') }}
3024
</p>
@@ -69,18 +63,13 @@ export default {
6963
show: false,
7064
loading: false,
7165
fileId: 0,
72-
emails: '',
73-
selectedUsers: [],
66+
selectedItems: [],
7467
}
7568
},
7669
7770
computed: {
78-
emailIsValid() {
79-
return /^\w+([.+-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,})+(?:,\w+([.+-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,})+)*$/
80-
.test(this.emails.replace(/\s*,\s*/g, ','))
81-
},
8271
canValidate() {
83-
return this.selectedUsers.length > 0 || this.emailIsValid
72+
return this.selectedItems.length > 0
8473
},
8574
},
8675
@@ -95,22 +84,24 @@ export default {
9584
this.show = true
9685
},
9786
closeRequestModal() {
98-
this.selectedUsers = []
99-
this.emails = ''
87+
this.selectedItems = []
10088
this.show = false
10189
},
10290
setFileId(fileId) {
10391
this.fileId = fileId
10492
},
105-
updateSelectedUsers(newValue) {
106-
this.selectedUsers = newValue
107-
console.debug(this.selectedUsers)
93+
updateSelectedItems(newValue) {
94+
this.selectedItems = newValue
95+
console.debug(this.selectedItems)
10896
},
10997
onSignClick() {
11098
this.loading = true
99+
100+
const targetUserIds = this.selectedItems.filter((i) => { return i.type === 'user' }).map((i) => { return i.entityId })
101+
const targetEmails = this.selectedItems.filter((i) => { return i.type === 'email' }).map((i) => { return i.email })
111102
const req = {
112-
targetUserIds: this.selectedUsers.map((u) => { return u.entityId }),
113-
targetEmails: this.emails ? this.emails.replace(/\s*,\s*/g, ',').split(',') : undefined,
103+
targetUserIds,
104+
targetEmails,
114105
}
115106
const url = generateUrl('/apps/approval/' + this.fileId + '/standalone-sign')
116107
axios.put(url, req).then((response) => {

src/components/MultiselectWho.vue

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
class="approval-avatar-option"
2525
:user="option.entityId"
2626
:show-user-status="false" />
27-
<Avatar v-else-if="['group', 'circle'].includes(option.type)"
27+
<Avatar v-else-if="['group', 'circle', 'email'].includes(option.type)"
2828
class="approval-avatar-option"
2929
:display-name="option.displayName"
3030
:is-no-user="true"
31+
:disable-tooltip="true"
3132
:show-user-status="false" />
3233
<span class="multiselect-name">
3334
{{ option.displayName }}
@@ -73,6 +74,10 @@ export default {
7374
type: String,
7475
default: t('approval', 'Who?'),
7576
},
77+
enableEmails: {
78+
type: Boolean,
79+
default: false,
80+
},
7681
},
7782
7883
data() {
@@ -99,6 +104,21 @@ export default {
99104
}
100105
})
101106
107+
// email suggestion
108+
const cleanQuery = this.query.replace(/\s+/g, '')
109+
if (this.enableEmails
110+
&& /^\w+([.+-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,})+$/.test(cleanQuery)
111+
&& !this.value.find(i => i.type === 'email' && i.email === cleanQuery)
112+
) {
113+
result.push({
114+
type: 'email',
115+
displayName: cleanQuery,
116+
email: cleanQuery,
117+
icon: 'icon-mail',
118+
trackKey: 'email-' + cleanQuery,
119+
})
120+
}
121+
102122
// add current user (who is absent from autocomplete suggestions)
103123
// if it matches the query
104124
if (this.currentUser && this.query) {
@@ -144,7 +164,7 @@ export default {
144164
})
145165
result.push(...circles)
146166
147-
// always add selected users/groups/circles at the end
167+
// always add selected users/groups/circles/emails at the end
148168
result.push(...this.value.map((w) => {
149169
return w.type === 'user'
150170
? {
@@ -162,13 +182,21 @@ export default {
162182
icon: 'icon-group',
163183
trackKey: 'group-' + w.entityId,
164184
}
165-
: {
166-
entityId: w.entityId,
167-
type: 'circle',
168-
displayName: w.displayName,
169-
icon: 'icon-circle',
170-
trackKey: 'circle-' + w.entityId,
171-
}
185+
: w.type === 'circle'
186+
? {
187+
entityId: w.entityId,
188+
type: 'circle',
189+
displayName: w.displayName,
190+
icon: 'icon-circle',
191+
trackKey: 'circle-' + w.entityId,
192+
}
193+
: {
194+
type: 'email',
195+
displayName: w.displayName,
196+
email: w.email,
197+
icon: 'icon-mail',
198+
trackKey: 'email-' + w.email,
199+
}
172200
}))
173201
174202
return result

0 commit comments

Comments
 (0)