0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-13 22:41:32 -05:00
ghost/core/client/models/settings.js
Jacob Gable 4066d8c680 Ember settings/general
- Settings fixture that doesn't seem to work
- SettingsGeneralRoute with model function calling api
- SettingsGeneralModel with save method stubbed
- SettingsGeneralController with actions for save, uploadLogo and uploadCover
- Let ApplicationRoute handleValidationErrors
- Fix actions hash in controller and use bind-attr
- Refactor to use single SettingsModel
- Implement description word count
- Fix broken ajax reference by actually importing ajax method
- Refactor to use count-words helper
- Refactor isDatedPermalinks into controller
- Refactor the isDatedPermalinks to use a custom setter
- Remove isDatedPermalinks code from the model
2014-05-07 11:32:49 -05:00

50 lines
No EOL
1.5 KiB
JavaScript

var validator = window.validator;
import BaseModel from 'ghost/models/base';
export default BaseModel.extend({
url: BaseModel.apiRoot + '/settings/?type=blog,theme,app',
title: null,
description: null,
email: null,
logo: null,
cover: null,
defaultLang: null,
postsPerPage: null,
forceI18n: null,
permalinks: null,
activeTheme: null,
activeApps: null,
installedApps: null,
availableThemes: null,
availableApps: null,
validate: function () {
var validationErrors = [],
postsPerPage;
if (!validator.isLength(this.get('title'), 0, 150)) {
validationErrors.push({message: "Title is too long", el: 'title'});
}
if (!validator.isLength(this.get('description'), 0, 200)) {
validationErrors.push({message: "Description is too long", el: 'description'});
}
if (!validator.isEmail(this.get('email')) || !validator.isLength(this.get('email'), 0, 254)) {
validationErrors.push({message: "Please supply a valid email address", el: 'email'});
}
postsPerPage = this.get('postsPerPage');
if (!validator.isInt(postsPerPage) || postsPerPage > 1000) {
validationErrors.push({message: "Please use a number less than 1000", el: 'postsPerPage'});
}
if (!validator.isInt(postsPerPage) || postsPerPage < 0) {
validationErrors.push({message: "Please use a number greater than 0", el: 'postsPerPage'});
}
return validationErrors;
}
});