mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
'Autocorrect' for posts per page setting
See #3671 - As @JohnONolan’s suggestion, if the user enters an invalid value for the ‘posts per page’ setting, the number autocorrects to 5, iOS autocorrect-style
This commit is contained in:
parent
02ca955a00
commit
acf8ffc1fb
3 changed files with 14 additions and 22 deletions
|
@ -38,6 +38,12 @@ var SettingsGeneralController = Ember.ObjectController.extend({
|
|||
self.notifications.showErrors(errors);
|
||||
});
|
||||
},
|
||||
|
||||
checkPostsPerPage: function () {
|
||||
if (this.get('postsPerPage') < 1 || this.get('postsPerPage') > 1000 || isNaN(this.get('postsPerPage'))) {
|
||||
this.set('postsPerPage', 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
<div class="form-group">
|
||||
<label for="postsPerPage">Posts per page</label>
|
||||
{{input id="postsPerPage" name="general[postsPerPage]" value=postsPerPage min="1" max="1000" type="number"}}
|
||||
{{input id="postsPerPage" name="general[postsPerPage]" focus-out="checkPostsPerPage" value=postsPerPage min="1" max="1000" type="number"}}
|
||||
<p>How many posts should be displayed on each page</p>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ CasperTest.begin('General settings pane is correct', 8, function suite(test) {
|
|||
});
|
||||
|
||||
//// ## General settings validations tests
|
||||
CasperTest.begin('General settings validation is correct', 7, function suite(test) {
|
||||
CasperTest.begin('General settings validation is correct', 6, function suite(test) {
|
||||
casper.thenOpenAndWaitForPageLoad('settings.general', function testTitleAndUrl() {
|
||||
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
||||
test.assertUrlMatch(/ghost\/settings\/general\/$/, 'Landed on the correct URL');
|
||||
|
@ -136,36 +136,22 @@ CasperTest.begin('General settings validation is correct', 7, function suite(tes
|
|||
|
||||
casper.thenClick('.js-bb-notification .close');
|
||||
|
||||
// Ensure postsPerPage number field form validation
|
||||
// Check postsPerPage autocorrect
|
||||
casper.fillAndSave('form#settings-general', {
|
||||
'general[postsPerPage]': 'notaninteger'
|
||||
});
|
||||
|
||||
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
|
||||
test.assertSelectorHasText('.notification-error', 'be a number');
|
||||
}, casper.failOnTimeout(test, 'postsPerPage error did not appear'), 2000);
|
||||
casper.then(function checkSlugInputValue() {
|
||||
test.assertField('general[postsPerPage]', '5');
|
||||
});
|
||||
|
||||
casper.thenClick('.js-bb-notification .close');
|
||||
|
||||
// Ensure postsPerPage max of 1000
|
||||
casper.fillAndSave('form#settings-general', {
|
||||
'general[postsPerPage]': '1001'
|
||||
});
|
||||
|
||||
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
|
||||
test.assertSelectorHasText('.notification-error', 'maximum number of posts per page is 1000');
|
||||
}, casper.failOnTimeout(test, 'postsPerPage max error did not appear', 2000));
|
||||
|
||||
casper.thenClick('.js-bb-notification .close');
|
||||
|
||||
// Ensure postsPerPage min of 0
|
||||
casper.fillAndSave('form#settings-general', {
|
||||
'general[postsPerPage]': '-1'
|
||||
casper.then(function checkSlugInputValue() {
|
||||
test.assertField('general[postsPerPage]', '5');
|
||||
});
|
||||
|
||||
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
|
||||
test.assertSelectorHasText('.notification-error', 'minimum number of posts per page is 1');
|
||||
}, casper.failOnTimeout(test, 'postsPerPage min error did not appear', 2000));
|
||||
});
|
||||
|
||||
CasperTest.begin('Users screen is correct', 9, function suite(test) {
|
||||
|
|
Loading…
Add table
Reference in a new issue