Allow enter key to submit admin modal forms
This commit is contained in:
parent
092f05d566
commit
11c8817ebd
|
@ -6,6 +6,16 @@ import InputValidation from 'discourse/models/input-validation';
|
|||
|
||||
export default Ember.Controller.extend(ModalFunctionality, {
|
||||
|
||||
setupKeydown: function() {
|
||||
Ember.run.schedule('afterRender', () => {
|
||||
$('#chat_integration_edit_channel_modal').keydown(e => {
|
||||
if (e.keyCode === 13) {
|
||||
this.send('save');
|
||||
}
|
||||
});
|
||||
});
|
||||
}.on('init'),
|
||||
|
||||
// The validation property must be defined at runtime since the possible parameters vary by provider
|
||||
setupValidations: function(){
|
||||
if(this.get('model.provider')){
|
||||
|
@ -79,6 +89,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
},
|
||||
|
||||
save: function(){
|
||||
if(this.get('saveDisabled')){return};
|
||||
|
||||
const self = this;
|
||||
|
||||
|
|
|
@ -2,7 +2,17 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
|||
import { ajax } from 'discourse/lib/ajax';
|
||||
|
||||
export default Ember.Controller.extend(ModalFunctionality, {
|
||||
sendDisabled: function(){
|
||||
setupKeydown: function() {
|
||||
Ember.run.schedule('afterRender', () => {
|
||||
$('#chat_integration_test_modal').keydown(e => {
|
||||
if (e.keyCode === 13) {
|
||||
this.send('send');
|
||||
}
|
||||
});
|
||||
});
|
||||
}.on('init'),
|
||||
|
||||
sendDisabled: function(){
|
||||
if(this.get('model').topic_id){
|
||||
return false
|
||||
}
|
||||
|
@ -12,6 +22,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
actions: {
|
||||
|
||||
send: function(){
|
||||
if(this.get('sendDisabled')){return};
|
||||
self = this;
|
||||
this.set('loading', true);
|
||||
ajax("/admin/plugins/chat/test", {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{#d-modal-body id="chat_integration_edit_channel_modal" title="chat_integration.edit_channel_modal.title"}}
|
||||
<div>
|
||||
<form>
|
||||
<form {{action "save" on="submit"}}>
|
||||
<table>
|
||||
|
||||
<tr class="input">
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
{{#d-modal-body id="chat_integration_test_modal" title="chat_integration.test_modal.title"}}
|
||||
<div>
|
||||
<form>
|
||||
<form {{action "send" on="submit"}}>
|
||||
<table>
|
||||
|
||||
|
||||
<tr class="input">
|
||||
<td class="label"><label for='channel'>{{i18n "chat_integration.test_modal.topic"}}</label></td>
|
||||
<td>
|
||||
{{choose-topic selectedTopicId=model.topic_id}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue