Fix plugin after I broke it while refactoring.
This commit is contained in:
parent
44ade676e1
commit
eb6575fd44
|
@ -4,11 +4,10 @@ import InputValidation from 'discourse/models/input-validation';
|
|||
import { default as computed, observes, on } from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
export default Ember.Controller.extend(ModalFunctionality, {
|
||||
|
||||
@on('init')
|
||||
setupKeydown() {
|
||||
Ember.run.schedule('afterRender', () => {
|
||||
$('#chat_integration_edit_channel_modal').keydown(e => {
|
||||
$('#chat-integration-edit-channel-modal').keydown(e => {
|
||||
if (e.keyCode === 13) {
|
||||
this.send('save');
|
||||
}
|
||||
|
@ -21,7 +20,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
setupValidations() {
|
||||
if (this.get('model.provider')) {
|
||||
const theKeys = this.get('model.provider.channel_parameters').map( ( param ) => param['key'] );
|
||||
Ember.defineProperty(this,'paramValidation', Ember.computed(`model.channel.data.{${theKeys.join(',')}},this._paramValidation`));
|
||||
Ember.defineProperty(this,'paramValidation', Ember.computed(`model.channel.data.${theKeys.join(',')}`, this._paramValidation));
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -74,11 +73,11 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
let invalid = false;
|
||||
|
||||
Object.keys(paramValidation).forEach(key =>{
|
||||
if (!validations[key]) {
|
||||
if (!paramValidation[key]) {
|
||||
invalid = true;
|
||||
}
|
||||
|
||||
if (!validations[key]['ok']) {
|
||||
if (!paramValidation[key]['ok']) {
|
||||
invalid = true;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
@on('init')
|
||||
setupKeydown() {
|
||||
Ember.run.schedule('afterRender', () => {
|
||||
$('#chat_integration_edit_channel_modal').keydown(e => {
|
||||
$('#chat-integration-edit-channel-modal').keydown(e => {
|
||||
if (e.keyCode === 13) {
|
||||
this.send('save');
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
||||
import { default as computed, on } from "ember-addons/ember-computed-decorators";
|
||||
|
||||
export default Ember.Controller.extend(ModalFunctionality, {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{{#d-modal-body id="chat_integration_edit_channel_modal" title="chat_integration.edit_channel_modal.title"}}
|
||||
{{#d-modal-body id="chat-integration-edit-channel-modal" title="chat_integration.edit_channel_modal.title"}}
|
||||
<div>
|
||||
<form {{action "save" on="submit"}}>
|
||||
<table>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{{!-- {{#d-modal-body id="chat_integration_edit_rule_modal" title="chat_integration.edit_rule_modal.title"}}
|
||||
{{#d-modal-body id="chat-integration-edit-rule_modal" title="chat_integration.edit_rule_modal.title"}}
|
||||
<div>
|
||||
<form {{action "save" on="submit"}}>
|
||||
<table>
|
||||
|
@ -107,4 +107,4 @@
|
|||
action="cancel"
|
||||
title="chat_integration.edit_rule_modal.cancel"
|
||||
label="chat_integration.edit_rule_modal.cancel"}}
|
||||
</div> --}}
|
||||
</div>
|
||||
|
|
|
@ -50,9 +50,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
#chat_integration_edit_channel_modal,
|
||||
#chat-integration-edit-channel-modal,
|
||||
#chat_integration_test_modal,
|
||||
#chat_integration_edit_rule_modal {
|
||||
#chat-integration-edit-rule_modal {
|
||||
table {
|
||||
width:100%;
|
||||
|
||||
|
|
|
@ -72,9 +72,9 @@ test("Create channel works", assert => {
|
|||
});
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists('#chat_integration_edit_channel_modal'), 'it displays the modal');
|
||||
assert.ok(exists('#chat-integration-edit-channel-modal'), 'it displays the modal');
|
||||
assert.ok(find('#save-channel').prop('disabled'), 'it disables the save button');
|
||||
fillIn('#chat_integration_edit_channel_modal input', '#general');
|
||||
fillIn('#chat-integration-edit-channel-modal input', '#general');
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
|
@ -86,7 +86,7 @@ test("Create channel works", assert => {
|
|||
});
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(!exists('#chat_integration_edit_channel_modal'), 'modal closes on save');
|
||||
assert.ok(!exists('#chat-integration-edit-channel-modal'), 'modal closes on save');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -99,9 +99,9 @@ test("Edit channel works", assert => {
|
|||
});
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists('#chat_integration_edit_channel_modal'), 'it displays the modal');
|
||||
assert.ok(exists('#chat-integration-edit-channel-modal'), 'it displays the modal');
|
||||
assert.ok(!find('#save-channel').prop('disabled'), 'save is enabled');
|
||||
fillIn('#chat_integration_edit_channel_modal input', ' general');
|
||||
fillIn('#chat-integration-edit-channel-modal input', ' general');
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
|
@ -109,15 +109,15 @@ test("Edit channel works", assert => {
|
|||
});
|
||||
|
||||
andThen(() => {
|
||||
fillIn('#chat_integration_edit_channel_modal input', '#random');
|
||||
fillIn('#chat-integration-edit-channel-modal input', '#random');
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
$("#chat_integration_edit_channel_modal input").trigger( $.Event( "keydown", { keyCode: 13 } ) ); // Press enter
|
||||
$("#chat-integration-edit-channel-modal input").trigger( $.Event( "keydown", { keyCode: 13 } ) ); // Press enter
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(!exists('#chat_integration_edit_channel_modal'), 'modal saves on enter');
|
||||
assert.ok(!exists('#chat-integration-edit-channel-modal'), 'modal saves on enter');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -132,14 +132,14 @@ test("Create rule works", assert => {
|
|||
click('.channel-footer button:first');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists('#chat_integration_edit_rule_modal'), 'modal opens on edit');
|
||||
assert.ok(exists('#chat-integration-edit-rule_modal'), 'modal opens on edit');
|
||||
assert.ok(find('#save-rule').prop('disabled') === false, 'save is enabled');
|
||||
});
|
||||
|
||||
click('#save-rule');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(!exists('#chat_integration_edit_rule_modal'), 'modal closes on save');
|
||||
assert.ok(!exists('#chat-integration-edit-rule_modal'), 'modal closes on save');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -153,14 +153,14 @@ test("Edit rule works", assert => {
|
|||
click('.edit:first');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists('#chat_integration_edit_rule_modal'), 'modal opens on edit');
|
||||
assert.ok(exists('#chat-integration-edit-rule_modal'), 'modal opens on edit');
|
||||
assert.ok(find('#save-rule').prop('disabled') === false, 'it enables the save button');
|
||||
});
|
||||
|
||||
click('#save-rule');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(!exists('#chat_integration_edit_rule_modal'), 'modal closes on save');
|
||||
assert.ok(!exists('#chat-integration-edit-rule_modal'), 'modal closes on save');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue