mirror of https://github.com/zulip/zulip.git
Add error message when user attempts to submit empty alert word.
Resolves #1194.
This commit is contained in:
parent
3894ea0e30
commit
87e485c89f
|
@ -108,6 +108,16 @@ casper.waitUntilVisible('.edit_bot_form[data-email="1-bot@zulip.com"]', function
|
|||
});
|
||||
|
||||
casper.waitForSelector('#create_alert_word_form', function () {
|
||||
casper.test.info('Attempting to submit an empty alert word');
|
||||
casper.click('#create_alert_word_button');
|
||||
casper.test.info('Checking that an error is displayed');
|
||||
casper.test.assertVisible('#empty_alert_word_error');
|
||||
|
||||
casper.test.info('Closing the error message');
|
||||
casper.click('.close-empty-alert-word-error');
|
||||
casper.test.info('Checking the error is hidden');
|
||||
casper.test.assertNotVisible('#empty_alert_word_error');
|
||||
|
||||
casper.test.info('Filling out the alert word input');
|
||||
casper.sendKeys('#create_alert_word_name', 'some phrase');
|
||||
casper.click('#create_alert_word_button');
|
||||
|
|
|
@ -17,6 +17,7 @@ function update_alert_words() {
|
|||
|
||||
function add_alert_word(word, event) {
|
||||
if (word === '') {
|
||||
$("#empty_alert_word_error").show();
|
||||
return;
|
||||
}
|
||||
var final_li = templates.render('alert_word_settings_item', {'word': word, editing: false});
|
||||
|
@ -68,6 +69,12 @@ exports.set_up_alert_words = function () {
|
|||
add_alert_word(word, event);
|
||||
}
|
||||
});
|
||||
|
||||
$('#alert_words_list').on('click', '.close-empty-alert-word-error', function (event) {
|
||||
event.preventDefault();
|
||||
var alert = $(event.currentTarget).parents('.alert');
|
||||
alert.hide();
|
||||
});
|
||||
};
|
||||
|
||||
return exports;
|
||||
|
|
|
@ -491,6 +491,16 @@ div.edit_bot {
|
|||
width: 8em;
|
||||
}
|
||||
|
||||
#empty_alert_word_error {
|
||||
display: none;
|
||||
margin-left: 38px;
|
||||
margin-right: 38px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
#empty_alert_word_error .close {
|
||||
position: inherit;
|
||||
}
|
||||
|
||||
#alert_words_list {
|
||||
list-style-type: none;
|
||||
|
|
|
@ -11,6 +11,12 @@
|
|||
<input type="text" name="alert_word_name" id="create_alert_word_name" class="required"
|
||||
maxlength=100 placeholder="{{t 'Alert Word' }}" value="" />
|
||||
</div>
|
||||
<div class="alert alert-danger" id="empty_alert_word_error" role="alert">
|
||||
<button type="button" class="close close-empty-alert-word-error" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<span>{{t "Alert words can't be empty!"}}</span>
|
||||
</div>
|
||||
<button class="btn btn-primary add-alert-word" id="create_alert_word_button" type="button">
|
||||
{{t 'Add Alert Word'}}
|
||||
</button>
|
||||
|
|
Loading…
Reference in New Issue