2014-06-09 00:48:14 +04:00
|
|
|
/* global moment */
|
2014-06-08 10:02:21 +04:00
|
|
|
import {parseDateString, formatDate} from 'ghost/utils/date-formatting';
|
2014-06-09 00:48:14 +04:00
|
|
|
import SlugGenerator from 'ghost/models/slug-generator';
|
2014-06-15 00:45:50 +04:00
|
|
|
import boundOneWay from 'ghost/utils/bound-one-way';
|
2014-08-01 00:29:35 +04:00
|
|
|
import isNumber from 'ghost/utils/isNumber';
|
2014-06-08 10:02:21 +04:00
|
|
|
|
|
|
|
var PostSettingsMenuController = Ember.ObjectController.extend({
|
2014-09-15 04:40:24 +04:00
|
|
|
//State for if the user is viewing a tab's pane.
|
|
|
|
needs: 'application',
|
2014-09-21 22:56:30 +04:00
|
|
|
|
2014-10-18 22:39:47 +04:00
|
|
|
lastPromise: null,
|
|
|
|
|
2014-10-13 19:23:06 +04:00
|
|
|
isViewingSubview: Ember.computed('controllers.application.showSettingsMenu', function (key, value) {
|
2014-09-15 04:40:24 +04:00
|
|
|
// Not viewing a subview if we can't even see the PSM
|
2014-10-13 19:23:06 +04:00
|
|
|
if (!this.get('controllers.application.showSettingsMenu')) {
|
2014-09-15 04:40:24 +04:00
|
|
|
return false;
|
2014-06-16 03:05:37 +04:00
|
|
|
}
|
2014-09-15 04:40:24 +04:00
|
|
|
if (arguments.length > 1) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}),
|
2014-08-10 18:40:04 +04:00
|
|
|
selectedAuthor: null,
|
2014-09-04 17:56:07 +04:00
|
|
|
initializeSelectedAuthor: function () {
|
2014-08-02 09:21:43 +04:00
|
|
|
var self = this;
|
2014-09-16 02:46:40 +04:00
|
|
|
|
2014-08-02 09:21:43 +04:00
|
|
|
return this.get('author').then(function (author) {
|
|
|
|
self.set('selectedAuthor', author);
|
|
|
|
return author;
|
|
|
|
});
|
2014-09-04 17:56:07 +04:00
|
|
|
}.observes('model'),
|
2014-08-10 18:40:04 +04:00
|
|
|
|
2014-07-17 09:54:32 +04:00
|
|
|
changeAuthor: function () {
|
|
|
|
var author = this.get('author'),
|
|
|
|
selectedAuthor = this.get('selectedAuthor'),
|
|
|
|
model = this.get('model'),
|
|
|
|
self = this;
|
|
|
|
//return if nothing changed
|
|
|
|
if (selectedAuthor.get('id') === author.get('id')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
model.set('author', selectedAuthor);
|
2014-08-02 22:27:12 +04:00
|
|
|
|
|
|
|
//if this is a new post (never been saved before), don't try to save it
|
|
|
|
if (this.get('isNew')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-22 21:17:09 +04:00
|
|
|
model.save().catch(function (errors) {
|
2014-07-17 09:54:32 +04:00
|
|
|
self.showErrors(errors);
|
|
|
|
self.set('selectedAuthor', author);
|
|
|
|
model.rollback();
|
|
|
|
});
|
|
|
|
}.observes('selectedAuthor'),
|
2014-07-30 05:57:19 +04:00
|
|
|
authors: Ember.computed(function () {
|
2014-07-17 09:54:32 +04:00
|
|
|
//Loaded asynchronously, so must use promise proxies.
|
2014-08-02 09:21:43 +04:00
|
|
|
var deferred = {};
|
2014-08-01 00:19:52 +04:00
|
|
|
|
2014-09-22 19:30:00 +04:00
|
|
|
deferred.promise = this.store.find('user', {limit: 'all'}).then(function (users) {
|
2014-09-27 18:39:27 +04:00
|
|
|
return users.rejectBy('id', 'me').sortBy('name');
|
2014-08-01 00:19:52 +04:00
|
|
|
}).then(function (users) {
|
2014-08-02 09:21:43 +04:00
|
|
|
return users.filter(function (user) {
|
|
|
|
return user.get('active');
|
|
|
|
});
|
2014-07-17 09:54:32 +04:00
|
|
|
});
|
2014-08-01 00:19:52 +04:00
|
|
|
|
2014-07-17 09:54:32 +04:00
|
|
|
return Ember.ArrayProxy
|
|
|
|
.extend(Ember.PromiseProxyMixin)
|
|
|
|
.create(deferred);
|
2014-07-30 05:57:19 +04:00
|
|
|
}),
|
2014-10-22 01:20:51 +04:00
|
|
|
|
|
|
|
publishedAtValue: Ember.computed('published_at', function () {
|
2014-06-09 00:48:14 +04:00
|
|
|
var pubDate = this.get('published_at');
|
|
|
|
if (pubDate) {
|
|
|
|
return formatDate(pubDate);
|
|
|
|
}
|
|
|
|
return formatDate(moment());
|
2014-07-30 05:57:19 +04:00
|
|
|
}),
|
2014-06-09 00:48:14 +04:00
|
|
|
|
2014-06-15 00:45:50 +04:00
|
|
|
slugValue: boundOneWay('slug'),
|
2014-10-22 01:20:51 +04:00
|
|
|
|
|
|
|
//Lazy load the slug generator
|
2014-06-09 00:48:14 +04:00
|
|
|
slugGenerator: Ember.computed(function () {
|
2014-07-01 16:18:47 +04:00
|
|
|
return SlugGenerator.create({
|
2014-07-31 08:25:42 +04:00
|
|
|
ghostPaths: this.get('ghostPaths'),
|
|
|
|
slugType: 'post'
|
2014-07-01 16:18:47 +04:00
|
|
|
});
|
2014-06-09 00:48:14 +04:00
|
|
|
}),
|
|
|
|
//Requests slug from title
|
2014-10-18 00:57:10 +04:00
|
|
|
generateAndSetSlug: function (destination) {
|
2014-06-09 00:48:14 +04:00
|
|
|
var self = this,
|
2014-10-18 22:39:47 +04:00
|
|
|
title = this.get('titleScratch'),
|
|
|
|
afterSave = this.get('lastPromise'),
|
|
|
|
promise;
|
|
|
|
|
|
|
|
// Only set an "untitled" slug once per post
|
|
|
|
if (title === '(Untitled)' && this.get('slug')) {
|
|
|
|
return;
|
|
|
|
}
|
2014-07-17 09:54:32 +04:00
|
|
|
|
2014-10-18 22:39:47 +04:00
|
|
|
promise = Ember.RSVP.resolve(afterSave).then(function () {
|
|
|
|
return self.get('slugGenerator').generateSlug(title).then(function (slug) {
|
|
|
|
self.set(destination, slug);
|
|
|
|
});
|
2014-06-09 00:48:14 +04:00
|
|
|
});
|
2014-10-18 22:39:47 +04:00
|
|
|
|
|
|
|
this.set('lastPromise', promise);
|
2014-06-09 00:48:14 +04:00
|
|
|
},
|
2014-09-15 04:40:24 +04:00
|
|
|
|
2014-09-21 22:56:30 +04:00
|
|
|
metaTitleScratch: boundOneWay('meta_title'),
|
|
|
|
metaDescriptionScratch: boundOneWay('meta_description'),
|
2014-09-19 03:42:07 +04:00
|
|
|
|
2014-09-21 22:56:30 +04:00
|
|
|
seoTitle: Ember.computed('titleScratch', 'metaTitleScratch', function () {
|
|
|
|
var metaTitle = this.get('metaTitleScratch') || '';
|
2014-09-19 03:42:07 +04:00
|
|
|
|
2014-10-17 20:18:52 +04:00
|
|
|
metaTitle = metaTitle.length > 0 ? metaTitle : this.get('titleScratch');
|
|
|
|
|
|
|
|
if (metaTitle.length > 70) {
|
|
|
|
metaTitle = metaTitle.substring(0, 70).trim();
|
|
|
|
metaTitle = Ember.Handlebars.Utils.escapeExpression(metaTitle);
|
|
|
|
metaTitle = new Ember.Handlebars.SafeString(metaTitle + '…');
|
|
|
|
}
|
|
|
|
|
|
|
|
return metaTitle;
|
2014-09-19 03:42:07 +04:00
|
|
|
}),
|
|
|
|
|
2014-09-23 13:37:08 +04:00
|
|
|
seoDescription: Ember.computed('scratch', 'metaDescriptionScratch', function () {
|
|
|
|
var metaDescription = this.get('metaDescriptionScratch') || '',
|
|
|
|
el,
|
|
|
|
html = '',
|
|
|
|
placeholder;
|
|
|
|
|
|
|
|
if (metaDescription.length > 0) {
|
|
|
|
placeholder = metaDescription;
|
|
|
|
} else {
|
|
|
|
el = $('.rendered-markdown');
|
|
|
|
|
|
|
|
// Get rendered markdown
|
|
|
|
if (!_.isUndefined(el) && el.length > 0) {
|
|
|
|
html = el.clone();
|
|
|
|
html.find('.image-uploader').remove();
|
|
|
|
html = html[0].innerHTML;
|
|
|
|
}
|
2014-09-19 03:42:07 +04:00
|
|
|
|
2014-09-23 13:37:08 +04:00
|
|
|
// Strip HTML
|
|
|
|
placeholder = $('<div />', { html: html }).text();
|
|
|
|
// Replace new lines and trim
|
|
|
|
placeholder = placeholder.replace(/\n+/g, ' ').trim();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (placeholder.length > 156) {
|
|
|
|
// Limit to 156 characters
|
2014-10-07 19:02:11 +04:00
|
|
|
placeholder = placeholder.substring(0, 156).trim();
|
2014-09-23 13:37:08 +04:00
|
|
|
placeholder = Ember.Handlebars.Utils.escapeExpression(placeholder);
|
|
|
|
placeholder = new Ember.Handlebars.SafeString(placeholder + '…');
|
|
|
|
}
|
|
|
|
|
|
|
|
return placeholder;
|
2014-09-19 03:42:07 +04:00
|
|
|
}),
|
|
|
|
|
2014-10-22 01:20:51 +04:00
|
|
|
seoURL: Ember.computed('slug', function () {
|
2014-10-17 20:18:52 +04:00
|
|
|
var blogUrl = this.get('config').blogUrl,
|
2014-10-22 01:20:51 +04:00
|
|
|
seoSlug = this.get('slug') ? this.get('slug') : '',
|
|
|
|
seoURL = blogUrl + '/' + seoSlug;
|
|
|
|
|
|
|
|
// only append a slash to the URL if the slug exists
|
|
|
|
if (seoSlug) {
|
|
|
|
seoURL += '/';
|
|
|
|
}
|
2014-10-17 20:18:52 +04:00
|
|
|
|
|
|
|
if (seoURL.length > 70) {
|
|
|
|
seoURL = seoURL.substring(0, 70).trim();
|
|
|
|
seoURL = new Ember.Handlebars.SafeString(seoURL + '…');
|
|
|
|
}
|
|
|
|
|
|
|
|
return seoURL;
|
2014-09-19 03:42:07 +04:00
|
|
|
}),
|
2014-09-15 04:40:24 +04:00
|
|
|
|
|
|
|
// observe titleScratch, keeping the post's slug in sync
|
|
|
|
// with it until saved for the first time.
|
|
|
|
addTitleObserver: function () {
|
2014-10-18 00:57:10 +04:00
|
|
|
if (this.get('isNew') || this.get('title') === '(Untitled)') {
|
2014-09-15 04:40:24 +04:00
|
|
|
this.addObserver('titleScratch', this, 'titleObserver');
|
|
|
|
}
|
|
|
|
}.observes('model'),
|
2014-10-22 01:20:51 +04:00
|
|
|
|
2014-06-09 00:48:14 +04:00
|
|
|
titleObserver: function () {
|
2014-10-22 01:20:51 +04:00
|
|
|
var debounceId,
|
|
|
|
title = this.get('title'),
|
|
|
|
slug = this.get('slug');
|
2014-10-18 22:39:47 +04:00
|
|
|
|
2014-10-22 01:20:51 +04:00
|
|
|
// generate a slug if a post is new and doesn't have a title yet or
|
|
|
|
// if the title is still '(Untitled)' and the slug is unaltered.
|
|
|
|
if ((this.get('isNew') && !title) || title === '(Untitled)' && /^untitled(-\d+){0,1}$/.test(slug)) {
|
2014-10-18 22:39:47 +04:00
|
|
|
debounceId = Ember.run.debounce(this, 'generateAndSetSlug', ['slug'], 700);
|
2014-06-16 03:05:37 +04:00
|
|
|
}
|
2014-10-18 22:39:47 +04:00
|
|
|
|
|
|
|
this.set('debounceId', debounceId);
|
2014-06-16 03:05:37 +04:00
|
|
|
},
|
2014-06-08 10:02:21 +04:00
|
|
|
|
2014-07-01 16:18:47 +04:00
|
|
|
showErrors: function (errors) {
|
|
|
|
errors = Ember.isArray(errors) ? errors : [errors];
|
|
|
|
this.notifications.showErrors(errors);
|
|
|
|
},
|
|
|
|
showSuccess: function (message) {
|
|
|
|
this.notifications.showSuccess(message);
|
|
|
|
},
|
2014-06-08 10:02:21 +04:00
|
|
|
actions: {
|
2014-07-01 16:18:47 +04:00
|
|
|
togglePage: function () {
|
2014-07-15 08:02:34 +04:00
|
|
|
var self = this;
|
2014-07-01 16:18:47 +04:00
|
|
|
|
2014-07-15 08:02:34 +04:00
|
|
|
this.toggleProperty('page');
|
2014-07-01 16:18:47 +04:00
|
|
|
// If this is a new post. Don't save the model. Defer the save
|
|
|
|
// to the user pressing the save button
|
|
|
|
if (this.get('isNew')) {
|
|
|
|
return;
|
|
|
|
}
|
2014-07-15 08:02:34 +04:00
|
|
|
|
2014-09-22 21:17:09 +04:00
|
|
|
this.get('model').save().catch(function (errors) {
|
2014-07-01 16:18:47 +04:00
|
|
|
self.showErrors(errors);
|
2014-09-23 12:47:35 +04:00
|
|
|
self.get('model').rollback();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
toggleFeatured: function () {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
this.toggleProperty('featured');
|
|
|
|
// If this is a new post. Don't save the model. Defer the save
|
|
|
|
// to the user pressing the save button
|
|
|
|
if (this.get('isNew')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.get('model').save(this.get('saveOptions')).catch(function (errors) {
|
|
|
|
self.showErrors(errors);
|
2014-07-01 16:18:47 +04:00
|
|
|
self.get('model').rollback();
|
|
|
|
});
|
|
|
|
},
|
2014-06-09 00:48:14 +04:00
|
|
|
/**
|
|
|
|
* triggered by user manually changing slug
|
|
|
|
*/
|
|
|
|
updateSlug: function (newSlug) {
|
|
|
|
var slug = this.get('slug'),
|
2014-06-08 10:02:21 +04:00
|
|
|
self = this;
|
2014-07-17 09:54:32 +04:00
|
|
|
|
2014-06-16 03:05:37 +04:00
|
|
|
newSlug = newSlug || slug;
|
2014-06-08 10:02:21 +04:00
|
|
|
|
2014-08-12 18:46:14 +04:00
|
|
|
newSlug = newSlug && newSlug.trim();
|
2014-06-08 10:02:21 +04:00
|
|
|
|
2014-06-16 03:05:37 +04:00
|
|
|
// Ignore unchanged slugs or candidate slugs that are empty
|
|
|
|
if (!newSlug || slug === newSlug) {
|
2014-08-12 21:00:09 +04:00
|
|
|
// reset the input to its previous state
|
|
|
|
this.set('slugValue', slug);
|
|
|
|
|
2014-06-08 10:02:21 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-16 03:05:37 +04:00
|
|
|
this.get('slugGenerator').generateSlug(newSlug).then(function (serverSlug) {
|
|
|
|
// If after getting the sanitized and unique slug back from the API
|
|
|
|
// we end up with a slug that matches the existing slug, abort the change
|
|
|
|
if (serverSlug === slug) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Because the server transforms the candidate slug by stripping
|
|
|
|
// certain characters and appending a number onto the end of slugs
|
2014-06-21 01:36:44 +04:00
|
|
|
// to enforce uniqueness, there are cases where we can get back a
|
2014-06-16 03:05:37 +04:00
|
|
|
// candidate slug that is a duplicate of the original except for
|
|
|
|
// the trailing incrementor (e.g., this-is-a-slug and this-is-a-slug-2)
|
|
|
|
|
|
|
|
// get the last token out of the slug candidate and see if it's a number
|
|
|
|
var slugTokens = serverSlug.split('-'),
|
|
|
|
check = Number(slugTokens.pop());
|
|
|
|
|
|
|
|
// if the candidate slug is the same as the existing slug except
|
|
|
|
// for the incrementor then the existing slug should be used
|
2014-08-01 00:29:35 +04:00
|
|
|
if (isNumber(check) && check > 0) {
|
2014-06-16 03:05:37 +04:00
|
|
|
if (slug === slugTokens.join('-') && serverSlug !== newSlug) {
|
2014-08-12 21:00:09 +04:00
|
|
|
self.set('slugValue', slug);
|
|
|
|
|
2014-06-16 03:05:37 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
self.set('slug', serverSlug);
|
|
|
|
|
2014-07-03 21:09:05 +04:00
|
|
|
if (self.hasObserverFor('titleScratch')) {
|
|
|
|
self.removeObserver('titleScratch', self, 'titleObserver');
|
2014-06-16 03:05:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// If this is a new post. Don't save the model. Defer the save
|
|
|
|
// to the user pressing the save button
|
|
|
|
if (self.get('isNew')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-22 21:17:09 +04:00
|
|
|
return self.get('model').save();
|
2014-07-01 16:18:47 +04:00
|
|
|
}).catch(function (errors) {
|
|
|
|
self.showErrors(errors);
|
|
|
|
self.get('model').rollback();
|
2014-06-16 03:05:37 +04:00
|
|
|
});
|
2014-06-08 10:02:21 +04:00
|
|
|
},
|
|
|
|
|
2014-06-09 00:48:14 +04:00
|
|
|
/**
|
|
|
|
* Parse user's set published date.
|
|
|
|
* Action sent by post settings menu view.
|
|
|
|
* (#1351)
|
|
|
|
*/
|
|
|
|
setPublishedAt: function (userInput) {
|
|
|
|
var errMessage = '',
|
|
|
|
newPublishedAt = parseDateString(userInput),
|
|
|
|
publishedAt = this.get('published_at'),
|
|
|
|
self = this;
|
2014-06-08 10:02:21 +04:00
|
|
|
|
2014-06-09 00:48:14 +04:00
|
|
|
if (!userInput) {
|
|
|
|
//Clear out the published_at field for a draft
|
|
|
|
if (this.get('isDraft')) {
|
|
|
|
this.set('published_at', null);
|
2014-06-08 10:02:21 +04:00
|
|
|
}
|
2014-06-09 00:48:14 +04:00
|
|
|
return;
|
|
|
|
}
|
2014-06-08 10:02:21 +04:00
|
|
|
|
|
|
|
// Validate new Published date
|
2014-06-09 00:48:14 +04:00
|
|
|
if (!newPublishedAt.isValid()) {
|
2014-06-08 10:02:21 +04:00
|
|
|
errMessage = 'Published Date must be a valid date with format: ' +
|
|
|
|
'DD MMM YY @ HH:mm (e.g. 6 Dec 14 @ 15:00)';
|
|
|
|
}
|
2014-06-09 00:48:14 +04:00
|
|
|
if (newPublishedAt.diff(new Date(), 'h') > 0) {
|
2014-06-08 10:02:21 +04:00
|
|
|
errMessage = 'Published Date cannot currently be in the future.';
|
|
|
|
}
|
|
|
|
|
2014-06-09 00:48:14 +04:00
|
|
|
//If errors, notify and exit.
|
2014-06-08 10:02:21 +04:00
|
|
|
if (errMessage) {
|
2014-07-01 16:18:47 +04:00
|
|
|
this.showErrors(errMessage);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do nothing if the user didn't actually change the date
|
|
|
|
if (publishedAt && publishedAt.isSame(newPublishedAt)) {
|
2014-06-08 10:02:21 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Validation complete
|
2014-06-09 00:48:14 +04:00
|
|
|
this.set('published_at', newPublishedAt);
|
2014-06-08 10:02:21 +04:00
|
|
|
|
2014-07-01 16:18:47 +04:00
|
|
|
// If this is a new post. Don't save the model. Defer the save
|
|
|
|
// to the user pressing the save button
|
|
|
|
if (this.get('isNew')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-22 21:17:09 +04:00
|
|
|
this.get('model').save().catch(function (errors) {
|
2014-09-16 02:46:40 +04:00
|
|
|
self.showErrors(errors);
|
|
|
|
self.get('model').rollback();
|
|
|
|
});
|
|
|
|
},
|
2014-09-19 03:42:07 +04:00
|
|
|
|
|
|
|
setMetaTitle: function (metaTitle) {
|
2014-09-23 13:37:08 +04:00
|
|
|
var self = this,
|
|
|
|
currentTitle = this.get('meta_title') || '';
|
|
|
|
|
|
|
|
// Only update if the title has changed
|
|
|
|
if (currentTitle === metaTitle) {
|
|
|
|
return;
|
|
|
|
}
|
2014-09-19 03:42:07 +04:00
|
|
|
|
|
|
|
this.set('meta_title', metaTitle);
|
|
|
|
|
|
|
|
// If this is a new post. Don't save the model. Defer the save
|
|
|
|
// to the user pressing the save button
|
|
|
|
if (this.get('isNew')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-22 21:17:09 +04:00
|
|
|
this.get('model').save().catch(function (errors) {
|
2014-09-19 03:42:07 +04:00
|
|
|
self.showErrors(errors);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
setMetaDescription: function (metaDescription) {
|
2014-09-23 13:37:08 +04:00
|
|
|
var self = this,
|
|
|
|
currentDescription = this.get('meta_description') || '';
|
|
|
|
|
|
|
|
// Only update if the description has changed
|
|
|
|
if (currentDescription === metaDescription) {
|
|
|
|
return;
|
|
|
|
}
|
2014-09-19 03:42:07 +04:00
|
|
|
|
|
|
|
this.set('meta_description', metaDescription);
|
|
|
|
|
|
|
|
// If this is a new post. Don't save the model. Defer the save
|
|
|
|
// to the user pressing the save button
|
|
|
|
if (this.get('isNew')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-22 21:17:09 +04:00
|
|
|
this.get('model').save().catch(function (errors) {
|
2014-09-19 03:42:07 +04:00
|
|
|
self.showErrors(errors);
|
|
|
|
});
|
|
|
|
},
|
2014-09-16 02:46:40 +04:00
|
|
|
|
|
|
|
setCoverImage: function (image) {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
this.set('image', image);
|
|
|
|
|
|
|
|
if (this.get('isNew')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-22 21:17:09 +04:00
|
|
|
this.get('model').save().catch(function (errors) {
|
2014-09-16 02:46:40 +04:00
|
|
|
self.showErrors(errors);
|
|
|
|
self.get('model').rollback();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
clearCoverImage: function () {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
this.set('image', '');
|
|
|
|
|
|
|
|
if (this.get('isNew')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-22 21:17:09 +04:00
|
|
|
this.get('model').save().catch(function (errors) {
|
2014-07-01 16:18:47 +04:00
|
|
|
self.showErrors(errors);
|
|
|
|
self.get('model').rollback();
|
2014-06-21 01:36:44 +04:00
|
|
|
});
|
2014-09-15 04:40:24 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
showSubview: function () {
|
|
|
|
this.set('isViewingSubview', true);
|
|
|
|
},
|
|
|
|
|
|
|
|
closeSubview: function () {
|
|
|
|
this.set('isViewingSubview', false);
|
2014-06-08 10:02:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-08-02 09:21:43 +04:00
|
|
|
export default PostSettingsMenuController;
|