Avoid accidental auto-submit of new msg form, for subject field
This commit is contained in:
		
							parent
							
								
									9125d7ef74
								
							
						
					
					
						commit
						714c0a6cfd
					
				
					 3 changed files with 19 additions and 3 deletions
				
			
		|  | @ -9,7 +9,8 @@ | ||||||
|   <div tal:define="vmodel vmodel|'field_model_' + name;"> |   <div tal:define="vmodel vmodel|'field_model_' + name;"> | ||||||
|     <b-input type="textarea" |     <b-input type="textarea" | ||||||
|              name="${name}" |              name="${name}" | ||||||
|              v-model="${vmodel}"> |              v-model="${vmodel}" | ||||||
|  |              tal:attributes="attributes|field.widget.attributes|{};"> | ||||||
|     </b-input> |     </b-input> | ||||||
|   </div> |   </div> | ||||||
| </div> | </div> | ||||||
|  |  | ||||||
|  | @ -44,6 +44,19 @@ | ||||||
|     TailboneFormData.possibleRecipients = new Map(${json.dumps(available_recipients)|n}) |     TailboneFormData.possibleRecipients = new Map(${json.dumps(available_recipients)|n}) | ||||||
|     TailboneFormData.recipientDisplayMap = ${json.dumps(recipient_display_map)|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> |   </script> | ||||||
| </%def> | </%def> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -221,11 +221,13 @@ class MessageView(MasterView): | ||||||
|         if self.creating: |         if self.creating: | ||||||
|             f.set_widget('subject', dfwidget.TextInputWidget( |             f.set_widget('subject', dfwidget.TextInputWidget( | ||||||
|                 placeholder="please enter a subject", |                 placeholder="please enter a subject", | ||||||
|                 autocomplete='off')) |                 autocomplete='off', | ||||||
|  |                 attributes={'@keydown.native': 'subjectKeydown'})) | ||||||
|             f.set_required('subject') |             f.set_required('subject') | ||||||
| 
 | 
 | ||||||
|         # body |         # 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: |         if self.creating: | ||||||
|             f.remove('sender', 'sent') |             f.remove('sender', 'sent') | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar