Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Show error message for invalid data in PostsPerPage (#419)
Browse files Browse the repository at this point in the history
closes TryGhost/Ghost#7746
- Added gh-form-group around PostsPerPage
- Changed focusOut action to validate
- Removed now redundant `checkPostsPerPage()` call
  • Loading branch information
John O'Mahoney authored and acburdine committed Jan 8, 2017
1 parent 000db35 commit 2ea63c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
8 changes: 0 additions & 8 deletions app/controllers/settings/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,6 @@ export default Controller.extend(SettingsSaveMixin, {
},

actions: {
checkPostsPerPage() {
let postsPerPage = this.get('model.postsPerPage');

if (postsPerPage < 1 || postsPerPage > 1000 || isNaN(postsPerPage)) {
this.set('model.postsPerPage', 5);
}
},

setTheme(theme) {
this.set('model.activeTheme', theme.name);
this.send('save');
Expand Down
11 changes: 7 additions & 4 deletions app/templates/settings/general.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@
<fieldset>

<div class="form-group">
<label for="postsPerPage">Posts per page</label>
{{! `pattern` brings up numeric keypad allowing any number of digits}}
{{gh-input model.postsPerPage id="postsPerPage" name="general[postsPerPage]" focus-out="checkPostsPerPage" min="1" max="1000" type="number" pattern="[0-9]*" update=(action (mut model.postsPerPage))}}
<p>How many posts should be displayed on each page</p>
{{#gh-form-group errors=model.errors hasValidated=model.hasValidated property="postsPerPage"}}
<label for="postsPerPage">Posts per page</label>
{{! `pattern` brings up numeric keypad allowing any number of digits}}
{{gh-input model.postsPerPage id="postsPerPage" name="general[postsPerPage]" focusOut=(action "validate" "postsPerPage" target=model) min="1" max="1000" type="number" pattern="[0-9]*" update=(action (mut model.postsPerPage))}}
{{gh-error-message errors=model.errors property="postsPerPage"}}
<p>How many posts should be displayed on each page</p>
{{/gh-form-group}}
</div>

<div class="form-group for-checkbox">
Expand Down

0 comments on commit 2ea63c6

Please sign in to comment.