Avoid accidental auto-submit of new msg form, for subject field
This commit is contained in:
parent
9125d7ef74
commit
714c0a6cfd
|
@ -9,7 +9,8 @@
|
|||
<div tal:define="vmodel vmodel|'field_model_' + name;">
|
||||
<b-input type="textarea"
|
||||
name="${name}"
|
||||
v-model="${vmodel}">
|
||||
v-model="${vmodel}"
|
||||
tal:attributes="attributes|field.widget.attributes|{};">
|
||||
</b-input>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -44,6 +44,19 @@
|
|||
TailboneFormData.possibleRecipients = new Map(${json.dumps(available_recipients)|n})
|
||||
TailboneFormData.recipientDisplayMap = ${json.dumps(recipient_display_map)|n}
|
||||
|
||||
TailboneForm.methods.subjectKeydown = function(event) {
|
||||
|
||||
// do not auto-submit form when user presses enter in subject field
|
||||
if (event.which == 13) {
|
||||
event.preventDefault()
|
||||
|
||||
// set focus to msg body input if possible
|
||||
if (this.$refs.messageBody && this.$refs.messageBody.focus) {
|
||||
this.$refs.messageBody.focus()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
|
|
|
@ -221,11 +221,13 @@ class MessageView(MasterView):
|
|||
if self.creating:
|
||||
f.set_widget('subject', dfwidget.TextInputWidget(
|
||||
placeholder="please enter a subject",
|
||||
autocomplete='off'))
|
||||
autocomplete='off',
|
||||
attributes={'@keydown.native': 'subjectKeydown'}))
|
||||
f.set_required('subject')
|
||||
|
||||
# body
|
||||
f.set_widget('body', dfwidget.TextAreaWidget(cols=50, rows=15))
|
||||
f.set_widget('body', dfwidget.TextAreaWidget(
|
||||
cols=50, rows=15, attributes={'ref': 'messageBody'}))
|
||||
|
||||
if self.creating:
|
||||
f.remove('sender', 'sent')
|
||||
|
|
Loading…
Reference in a new issue