Refactored usage of .get('property') with es5 getters

no issue
- ran [es5-getter-ember-codemod](https://github.com/rondale-sc/es5-getter-ember-codemod)
- [es5 getters RFC](https://github.com/emberjs/rfcs/blob/master/text/0281-es5-getters.md)
- updates the majority of `object.get('property')` with `object.property` with exceptions:
  - `.get('nested.property')` - it's not possible to determine if this is relying on "safe" path chaining for when `nested` doesn't exist
  - `.get('config.x')` and `.get('settings.x')` - both our `config` and `settings` services are proxy objects which do not support es5 getters
- this PR is not exhaustive, there are still a number of places where `.get('service.foo')` and similar could be replaced but it gets us a long way there in a quick and automated fashion
This commit is contained in:
Kevin Ansfield 2019-03-06 13:53:54 +00:00
parent e161dd4180
commit 352c4af1d7
137 changed files with 895 additions and 895 deletions

View File

@ -30,7 +30,7 @@ export default Component.extend({
actions: {
closeNotification() {
this.get('notifications').closeNotification(this.get('message'));
this.notifications.closeNotification(this.message);
}
}
});

View File

@ -8,7 +8,7 @@ export default Component.extend({
didReceiveAttrs() {
this._super(...arguments);
let showSettingsMenu = this.get('showSettingsMenu');
let showSettingsMenu = this.showSettingsMenu;
$('body').toggleClass('settings-menu-expanded', showSettingsMenu);
}

View File

@ -9,11 +9,11 @@ export default BasicDropdown.extend({
didInsertElement() {
this._super(...arguments);
this.get('dropdown').on('close', this, this.close);
this.dropdown.on('close', this, this.close);
},
willDestroyElement() {
this._super(...arguments);
this.get('dropdown').off('close');
this.dropdown.off('close');
}
});

View File

@ -30,14 +30,14 @@ const CmEditorComponent = Component.extend({
_value: boundOneWay('value'), // make sure a value exists
didReceiveAttrs() {
if (this.get('_value') === null || undefined) {
if (this._value === null || undefined) {
this.set('_value', '');
}
},
didInsertElement() {
this._super(...arguments);
this.get('initCodeMirror').perform();
this.initCodeMirror.perform();
},
willDestroyElement() {
@ -60,7 +60,7 @@ const CmEditorComponent = Component.extend({
},
initCodeMirror: task(function* () {
let loader = this.get('lazyLoader');
let loader = this.lazyLoader;
yield loader.loadScript('codemirror', 'assets/codemirror/codemirror.js');
scheduleOnce('afterRender', this, this._initCodeMirror);
@ -68,7 +68,7 @@ const CmEditorComponent = Component.extend({
_initCodeMirror() {
let options = this.getProperties('lineNumbers', 'lineWrapping', 'indentUnit', 'mode', 'theme', 'autofocus');
assign(options, {value: this.get('_value')});
assign(options, {value: this._value});
let textarea = this.element.querySelector('textarea');
if (textarea && textarea === document.activeElement) {
@ -105,7 +105,7 @@ const CmEditorComponent = Component.extend({
_focus(codeMirror, event) {
this.set('isFocused', true);
once(this, this.get('focus-in'), codeMirror.getValue(), codeMirror, event);
once(this, this['focus-in'], codeMirror.getValue(), codeMirror, event);
},
_blur(/* codeMirror, event */) {

View File

@ -19,6 +19,6 @@ export default Component.extend({
classNames: ['content-cover'],
click() {
this.get('ui').closeMenus();
this.ui.closeMenus();
}
});

View File

@ -25,13 +25,13 @@ export default Component.extend({
hasError: or('dateError', 'timeError'),
timezone: computed('blogTimezone', function () {
let blogTimezone = this.get('blogTimezone');
let blogTimezone = this.blogTimezone;
return moment.utc().tz(blogTimezone).format('z');
}),
dateError: computed('errors.[]', 'dateErrorProperty', function () {
let errors = this.get('errors');
let property = this.get('dateErrorProperty');
let errors = this.errors;
let property = this.dateErrorProperty;
if (errors && !isEmpty(errors.errorsFor(property))) {
return errors.errorsFor(property).get('firstObject').message;
@ -39,8 +39,8 @@ export default Component.extend({
}),
timeError: computed('errors.[]', 'timeErrorProperty', function () {
let errors = this.get('errors');
let property = this.get('timeErrorProperty');
let errors = this.errors;
let property = this.timeErrorProperty;
if (errors && !isEmpty(errors.errorsFor(property))) {
return errors.errorsFor(property).get('firstObject').message;
@ -48,11 +48,11 @@ export default Component.extend({
}),
didReceiveAttrs() {
let date = this.get('date');
let time = this.get('time');
let minDate = this.get('minDate');
let maxDate = this.get('maxDate');
let blogTimezone = this.get('blogTimezone');
let date = this.date;
let time = this.time;
let minDate = this.minDate;
let maxDate = this.maxDate;
let blogTimezone = this.blogTimezone;
if (!isBlank(date)) {
this.set('_date', moment(date));
@ -61,11 +61,11 @@ export default Component.extend({
}
if (isBlank(time)) {
this.set('_time', this.get('_date').format('HH:mm'));
this.set('_time', this._date.format('HH:mm'));
} else {
this.set('_time', this.get('time'));
this.set('_time', this.time);
}
this.set('_previousTime', this.get('_time'));
this.set('_previousTime', this._time);
// unless min/max date is at midnight moment will diable that day
if (minDate === 'now') {
@ -89,11 +89,11 @@ export default Component.extend({
// if date or time is set and the other property is blank set that too
// so that we don't get "can't be blank" errors
setDate(date) {
if (date !== this.get('_date')) {
this.get('setDate')(date);
if (date !== this._date) {
this.setDate(date);
if (isBlank(this.get('time'))) {
this.get('setTime')(this.get('_time'));
if (isBlank(this.time)) {
this.setTime(this._time);
}
}
},
@ -103,12 +103,12 @@ export default Component.extend({
time = `0${time}`;
}
if (time !== this.get('_previousTime')) {
this.get('setTime')(time);
if (time !== this._previousTime) {
this.setTime(time);
this.set('_previousTime', time);
if (isBlank(this.get('date'))) {
this.get('setDate')(this.get('_date'));
if (isBlank(this.date)) {
this.setDate(this._date);
}
}
}

View File

@ -11,7 +11,7 @@ export default Component.extend({
count: '',
didInsertElement() {
this.get('_poll').perform();
this._poll.perform();
},
_poll: task(function* () {
@ -19,7 +19,7 @@ export default Component.extend({
let pattern = /(-?\d+)(\d{3})/;
try {
let data = yield this.get('ajax').request(url);
let data = yield this.ajax.request(url);
let count = data.count.toString();
while (pattern.test(count)) {
@ -30,7 +30,7 @@ export default Component.extend({
if (config.environment !== 'test') {
yield timeout(2000);
this.get('_poll').perform();
this._poll.perform();
}
} catch (e) {
// no-op - we don't want to create noise for a failed download count

View File

@ -15,9 +15,9 @@ export default Component.extend(DropdownMixin, {
// Notify dropdown service this dropdown should be toggled
click(event) {
this._super(event);
this.get('dropdown').toggleDropdown(this.get('dropdownName'), this);
this.dropdown.toggleDropdown(this.dropdownName, this);
if (this.get('tagName') === 'a') {
if (this.tagName === 'a') {
return false;
}
}

View File

@ -21,11 +21,11 @@ export default Component.extend(DropdownMixin, {
// Managed the toggle between the fade-in and fade-out classes
fadeIn: computed('isOpen', 'closing', function () {
return this.get('isOpen') && !this.get('closing');
return this.isOpen && !this.closing;
}),
didInsertElement() {
let dropdownService = this.get('dropdown');
let dropdownService = this.dropdown;
this._super(...arguments);
@ -34,7 +34,7 @@ export default Component.extend(DropdownMixin, {
},
willDestroyElement() {
let dropdownService = this.get('dropdown');
let dropdownService = this.dropdown;
this._super(...arguments);
@ -51,14 +51,14 @@ export default Component.extend(DropdownMixin, {
close() {
this.set('closing', true);
if (this.get('button')) {
if (this.button) {
this.set('button.isOpen', false);
}
this.$().on('animationend webkitAnimationEnd oanimationend MSAnimationEnd', (event) => {
if (event.originalEvent.animationName === 'fade-out') {
run(this, function () {
if (this.get('closing')) {
if (this.closing) {
this.set('isOpen', false);
this.set('closing', false);
}
@ -69,11 +69,11 @@ export default Component.extend(DropdownMixin, {
// Called by the dropdown service when any dropdown button is clicked.
toggle(options) {
let isClosing = this.get('closing');
let isOpen = this.get('isOpen');
let name = this.get('name');
let isClosing = this.closing;
let isOpen = this.isOpen;
let name = this.name;
let targetDropdownName = options.target;
let button = this.get('button');
let button = this.button;
if (name === targetDropdownName && (!isOpen || isClosing)) {
if (!button) {
@ -89,7 +89,7 @@ export default Component.extend(DropdownMixin, {
click(event) {
this._super(event);
if (this.get('closeOnClick')) {
if (this.closeOnClick) {
return this.close();
}
}

View File

@ -26,8 +26,8 @@ export default Component.extend({
// we want to ensure that the "Saving..." message is shown for at least
// a few seconds so that it's noticeable
didReceiveAttrs() {
if (this.get('isSaving')) {
this.get('showSavingMessage').perform();
if (this.isSaving) {
this.showSavingMessage.perform();
}
},

View File

@ -52,7 +52,7 @@ export default Component.extend({
actions: {
toggleFullScreen(isFullScreen) {
this.set('isFullScreen', isFullScreen);
this.get('ui').set('isFullScreen', isFullScreen);
this.ui.set('isFullScreen', isFullScreen);
run.scheduleOnce('afterRender', this, this._setHeaderClass);
},
@ -90,7 +90,7 @@ export default Component.extend({
this._editorTitleElement = editorTitle;
if (this.get('isSplitScreen')) {
if (this.isSplitScreen) {
this.set('headerClass', smallHeaderClass);
return;
}

View File

@ -21,8 +21,8 @@ export default Component.extend({
isVisible: notEmpty('errors'),
message: computed('errors.[]', 'property', function () {
let property = this.get('property');
let errors = this.get('errors');
let property = this.property;
let errors = this.errors;
let messages = [];
let index;

View File

@ -10,36 +10,36 @@ const FeatureFlagComponent = Component.extend({
classNames: 'checkbox',
attributeBindings: ['for', 'disabled'],
disabled: computed('_disabled', function () {
if (this.get('_disabled')) {
if (this._disabled) {
return true;
}
return false;
}),
value: computed('_flagValue', {
get() {
return this.get('_flagValue');
return this._flagValue;
},
set(key, value) {
if (this.get('flag') === 'members' && value === true) {
if (this.flag === 'members' && value === true) {
this.set(`feature.subscribers`, false);
}
return this.set(`feature.${this.get('flag')}`, value);
return this.set(`feature.${this.flag}`, value);
}
}),
for: computed('flag', function () {
return `labs-${this.get('flag')}`;
return `labs-${this.flag}`;
}),
name: computed('flag', function () {
return `labs[${this.get('flag')}]`;
return `labs[${this.flag}]`;
}),
init() {
this._super(...arguments);
defineProperty(this, '_flagValue', readOnly(`feature.${this.get('flag')}`), function () {
return this.get(`feature.${this.get('flag')}`);
defineProperty(this, '_flagValue', readOnly(`feature.${this.flag}`), function () {
return this.get(`feature.${this.flag}`);
});
}
});

View File

@ -5,7 +5,7 @@ import XFileInput from 'emberx-file-input/components/x-file-input';
export default XFileInput.extend({
change(e) {
let action = this.get('action');
let action = this.action;
let files = this.files(e);
if (files.length && action) {

View File

@ -15,7 +15,7 @@ export default Component.extend({
actions: {
upload() {
if (!this.get('uploadButtonDisabled') && this._file) {
if (!this.uploadButtonDisabled && this._file) {
this.onUpload(this._file);
}
@ -23,7 +23,7 @@ export default Component.extend({
this.set('uploadButtonDisabled', true);
// Reset form
if (this.get('shouldResetForm')) {
if (this.shouldResetForm) {
this.$().closest('form')[0].reset();
}
}

View File

@ -48,8 +48,8 @@ export default Component.extend({
uploadFailed: () => {},
formData: computed('file', function () {
let paramName = this.get('paramName');
let file = this.get('file');
let paramName = this.paramName;
let file = this.file;
let formData = new FormData();
formData.append(paramName, file);
@ -58,7 +58,7 @@ export default Component.extend({
}),
progressStyle: computed('uploadPercentage', function () {
let percentage = this.get('uploadPercentage');
let percentage = this.uploadPercentage;
let width = '';
if (percentage > 0) {
@ -74,13 +74,13 @@ export default Component.extend({
// process can be triggered externally
init() {
this._super(...arguments);
let listenTo = this.get('listenTo');
let listenTo = this.listenTo;
this.accept = this.accept || DEFAULTS.accept;
this.extensions = this.extensions || DEFAULTS.extensions;
if (listenTo) {
this.get('eventBus').subscribe(`${listenTo}:upload`, this, function (file) {
this.eventBus.subscribe(`${listenTo}:upload`, this, function (file) {
if (file) {
this.set('file', file);
}
@ -91,20 +91,20 @@ export default Component.extend({
didReceiveAttrs() {
this._super(...arguments);
let accept = this.get('accept');
let extensions = this.get('extensions');
let accept = this.accept;
let extensions = this.extensions;
this._accept = (!isBlank(accept) && !isEmberArray(accept)) ? accept.split(',') : accept;
this._extensions = (!isBlank(extensions) && !isEmberArray(extensions)) ? extensions.split(',') : extensions;
},
willDestroyElement() {
let listenTo = this.get('listenTo');
let listenTo = this.listenTo;
this._super(...arguments);
if (listenTo) {
this.get('eventBus').unsubscribe(`${listenTo}:upload`);
this.eventBus.unsubscribe(`${listenTo}:upload`);
}
},
@ -134,7 +134,7 @@ export default Component.extend({
},
upload() {
if (this.get('file')) {
if (this.file) {
this.generateRequest();
}
},
@ -178,9 +178,9 @@ export default Component.extend({
},
generateRequest() {
let ajax = this.get('ajax');
let formData = this.get('formData');
let url = this.get('url');
let ajax = this.ajax;
let formData = this.formData;
let url = this.url;
this.uploadStarted();
@ -225,7 +225,7 @@ export default Component.extend({
let message;
if (isVersionMismatchError(error)) {
this.get('notifications').showAPIError(error);
this.notifications.showAPIError(error);
}
if (isUnsupportedMediaTypeError(error)) {

View File

@ -13,12 +13,12 @@ const FullScreenModalComponent = Component.extend({
modifier: null,
modalPath: computed('modal', function () {
return `modal-${this.get('modal') || 'unknown'}`;
return `modal-${this.modal || 'unknown'}`;
}),
modalClasses: computed('modifiers', function () {
let modalClass = 'fullscreen-modal';
let modifiers = (this.get('modifier') || '').split(' ');
let modifiers = (this.modifier || '').split(' ');
let modalClasses = emberA([modalClass]);
modifiers.forEach((modifier) => {
@ -33,7 +33,7 @@ const FullScreenModalComponent = Component.extend({
didInsertElement() {
run.schedule('afterRender', this, function () {
this.get('dropdown').closeDropdowns();
this.dropdown.closeDropdowns();
});
},

View File

@ -6,28 +6,28 @@ export default Component.extend({
actions: {
update() {
let action = this.get('update');
let action = this.update;
if (action) {
action(...arguments);
}
},
uploadStarted() {
let action = this.get('uploadStarted');
let action = this.uploadStarted;
if (action) {
action(...arguments);
}
},
uploadFinished() {
let action = this.get('uploadFinished');
let action = this.uploadFinished;
if (action) {
action(...arguments);
}
},
remove() {
let action = this.get('remove');
let action = this.remove;
if (action) {
action();
}

View File

@ -65,7 +65,7 @@ export default Component.extend({
// TODO: this wouldn't be necessary if the server could accept direct
// file uploads
formData: computed('file', function () {
let file = this.get('file');
let file = this.file;
let formData = new FormData();
formData.append(this.paramName, file);
@ -78,13 +78,13 @@ export default Component.extend({
}),
description: computed('text', 'altText', function () {
let altText = this.get('altText');
let altText = this.altText;
return this.get('text') || (altText ? `Upload image of "${altText}"` : 'Upload an image');
return this.text || (altText ? `Upload image of "${altText}"` : 'Upload an image');
}),
progressStyle: computed('uploadPercentage', function () {
let percentage = this.get('uploadPercentage');
let percentage = this.uploadPercentage;
let width = '';
if (percentage > 0) {
@ -99,14 +99,14 @@ export default Component.extend({
init() {
this._super(...arguments);
if (!this.get('accept')) {
this.set('accept', this.get('_defaultAccept'));
if (!this.accept) {
this.set('accept', this._defaultAccept);
}
if (!this.get('extensions')) {
this.set('extensions', this.get('_defaultExtensions'));
if (!this.extensions) {
this.set('extensions', this._defaultExtensions);
}
if (!this.get('uploadUrl')) {
this.set('uploadUrl', this.get('_defaultUploadUrl'));
if (!this.uploadUrl) {
this.set('uploadUrl', this._defaultUploadUrl);
}
if (!this.paramsHash) {
this.set('paramsHash', this._defaultParamsHash);
@ -114,7 +114,7 @@ export default Component.extend({
},
didReceiveAttrs() {
let image = this.get('image');
let image = this.image;
this.set('url', image);
},
@ -157,7 +157,7 @@ export default Component.extend({
},
saveUrl() {
let url = this.get('url');
let url = this.url;
this.update(url);
}
},
@ -233,11 +233,11 @@ export default Component.extend({
let message;
if (isVersionMismatchError(error)) {
this.get('notifications').showAPIError(error);
this.notifications.showAPIError(error);
}
if (isUnsupportedMediaTypeError(error)) {
let validExtensions = this.get('extensions').join(', .').toUpperCase();
let validExtensions = this.extensions.join(', .').toUpperCase();
validExtensions = `.${validExtensions}`;
message = `The image type you uploaded is not supported. Please use ${validExtensions}`;
@ -254,9 +254,9 @@ export default Component.extend({
},
generateRequest() {
let ajax = this.get('ajax');
let formData = this.get('formData');
let uploadUrl = this.get('uploadUrl');
let ajax = this.ajax;
let formData = this.formData;
let uploadUrl = this.uploadUrl;
// CASE: we want to upload an icon and we have to POST it to a different endpoint, expecially for icons
let url = `${ghostPaths().apiRoot}${uploadUrl}`;
@ -294,7 +294,7 @@ export default Component.extend({
},
_defaultValidator(file) {
let extensions = this.get('extensions');
let extensions = this.extensions;
let [, extension] = (/(?:\.([^.]+))?$/).exec(file.name);
if (!isEmberArray(extensions)) {

View File

@ -10,11 +10,11 @@ export default Component.extend({
slowLoadTimeout: 200,
didInsertElement() {
this.get('startSpinnerTimeout').perform();
this.startSpinnerTimeout.perform();
},
startSpinnerTimeout: task(function* () {
yield timeout(this.get('slowLoadTimeout'));
yield timeout(this.slowLoadTimeout);
this.set('showSpinner', true);
})
});

View File

@ -6,7 +6,7 @@ export default Component.extend({
ariaRole: 'main',
mouseEnter() {
let action = this.get('onMouseEnter');
let action = this.onMouseEnter;
if (action) {
action();
}

View File

@ -57,7 +57,7 @@ export default Component.extend(ShortcutsMixin, {
onSplitScreenToggle() {},
simpleMDEOptions: computed('options', function () {
let options = this.get('options') || {};
let options = this.options || {};
let defaultOptions = {
// use our Showdown config with sanitization for previews
previewRender(markdown) {
@ -142,19 +142,19 @@ export default Component.extend(ShortcutsMixin, {
let toolbar = defaultOptions.toolbar;
if (!this.get('enableSideBySide')) {
if (!this.enableSideBySide) {
let sideBySide = toolbar.findBy('name', 'side-by-side');
let index = toolbar.indexOf(sideBySide);
toolbar.splice(index, 1);
}
if (!this.get('enablePreview')) {
if (!this.enablePreview) {
let preview = toolbar.findBy('name', 'preview');
let index = toolbar.indexOf(preview);
toolbar.splice(index, 1);
}
if (!this.get('enableHemingway')) {
if (!this.enableHemingway) {
let hemingway = toolbar.findBy('name', 'hemingway');
let index = toolbar.indexOf(hemingway);
toolbar.splice(index, 1);
@ -193,13 +193,13 @@ export default Component.extend(ShortcutsMixin, {
shortcuts[`${ctrlOrCmd}+shift+i`] = {action: 'openImageFileDialog'};
shortcuts['ctrl+alt+s'] = {action: 'toggleSpellcheck'};
if (this.get('enablePreview')) {
if (this.enablePreview) {
shortcuts['ctrl+alt+r'] = {action: 'togglePreview'};
}
if (this.get('enableSideBySide')) {
if (this.enableSideBySide) {
shortcuts['ctrl+alt+p'] = {action: 'toggleSplitScreen'};
}
if (this.get('enableHemingway')) {
if (this.enableHemingway) {
shortcuts['ctrl+alt+h'] = {action: 'toggleHemingway'};
}
@ -210,7 +210,7 @@ export default Component.extend(ShortcutsMixin, {
didReceiveAttrs() {
this._super(...arguments);
let uploadedImageUrls = this.get('uploadedImageUrls');
let uploadedImageUrls = this.uploadedImageUrls;
if (!isEmpty(uploadedImageUrls) && uploadedImageUrls !== this._uploadedImageUrls) {
this._uploadedImageUrls = uploadedImageUrls;
@ -224,16 +224,16 @@ export default Component.extend(ShortcutsMixin, {
// focus the editor when the markdown value changes, this is necessary
// because both the autofocus and markdown values can change without a
// re-render, eg. navigating from edit->new
if (this.get('autofocus') && this._editor && this.get('markdown') !== this._editor.value()) {
if (this.autofocus && this._editor && this.markdown !== this._editor.value()) {
this.send('focusEditor');
}
// use internal values to avoid updating bound values
if (!isEmpty(this.get('isFullScreen'))) {
this.set('_isFullScreen', this.get('isFullScreen'));
if (!isEmpty(this.isFullScreen)) {
this.set('_isFullScreen', this.isFullScreen);
}
if (!isEmpty(this.get('isSplitScreen'))) {
this.set('_isSplitScreen', this.get('isSplitScreen'));
if (!isEmpty(this.isSplitScreen)) {
this.set('_isSplitScreen', this.isSplitScreen);
}
this._updateButtonState();
@ -258,7 +258,7 @@ export default Component.extend(ShortcutsMixin, {
},
willDestroyElement() {
if (this.get('_isSplitScreen')) {
if (this._isSplitScreen) {
this._disconnectSplitPreview();
}
@ -348,7 +348,7 @@ export default Component.extend(ShortcutsMixin, {
},
toggleUnsplash() {
if (this.get('_showUnsplash')) {
if (this._showUnsplash) {
return this.toggleProperty('_showUnsplash');
}
@ -378,20 +378,20 @@ export default Component.extend(ShortcutsMixin, {
},
toggleFullScreen() {
let isFullScreen = !this.get('_isFullScreen');
let isFullScreen = !this._isFullScreen;
this.set('_isFullScreen', isFullScreen);
this._updateButtonState();
this.onFullScreenToggle(isFullScreen);
// leave split screen when exiting full screen mode
if (!isFullScreen && this.get('_isSplitScreen')) {
if (!isFullScreen && this._isSplitScreen) {
this.send('toggleSplitScreen');
}
},
toggleSplitScreen() {
let isSplitScreen = !this.get('_isSplitScreen');
let isSplitScreen = !this._isSplitScreen;
let previewButton = this._editor.toolbarElements.preview;
this.set('_isSplitScreen', isSplitScreen);
@ -536,7 +536,7 @@ export default Component.extend(ShortcutsMixin, {
let hemingwayButton = this._editor.toolbarElements.hemingway;
if (sideBySideButton) {
if (this.get('_isSplitScreen')) {
if (this._isSplitScreen) {
sideBySideButton.classList.add('active');
} else {
sideBySideButton.classList.remove('active');
@ -679,7 +679,7 @@ export default Component.extend(ShortcutsMixin, {
cm.focus();
this.get('notifications').showNotification(
this.notifications.showNotification(
htmlSafe(notificationText),
{key: 'editor.hemingwaymode'}
);

View File

@ -54,7 +54,7 @@ export default Component.extend({
},
_setIconStyle() {
let icon = this.get('icon');
let icon = this.icon;
if (icon === this._icon) {
return;

View File

@ -19,7 +19,7 @@ export default Component.extend(ValidationState, {
errors: readOnly('navItem.errors'),
errorClass: computed('hasError', function () {
if (this.get('hasError')) {
if (this.hasError) {
return 'gh-blognav-item--error';
}
}),

View File

@ -34,7 +34,7 @@ export default Component.extend({
this.$().on('animationend webkitAnimationEnd oanimationend MSAnimationEnd', (event) => {
if (event.originalEvent.animationName === 'fade-out') {
this.get('notifications').closeNotification(this.get('message'));
this.notifications.closeNotification(this.message);
}
});
},
@ -46,7 +46,7 @@ export default Component.extend({
actions: {
closeNotification() {
this.get('notifications').closeNotification(this.get('message'));
this.notifications.closeNotification(this.message);
}
}
});

View File

@ -49,7 +49,7 @@ export default Component.extend(SettingsMenuMixin, {
}),
seoDescription: computed('post.scratch', 'metaDescriptionScratch', function () {
let metaDescription = this.get('metaDescriptionScratch') || '';
let metaDescription = this.metaDescriptionScratch || '';
let mobiledoc = this.get('post.scratch');
let [markdownCard] = mobiledoc.cards;
let markdown = markdownCard && markdownCard[1] && markdownCard[1].markdown;
@ -90,13 +90,13 @@ export default Component.extend(SettingsMenuMixin, {
// can add throbbers only when the animation has finished
// TODO: use liquid-fire to handle PSM slide-in and replace tabs manager
// with something more ember-like
if (this.get('showSettingsMenu') && !this._showSettingsMenu) {
this.get('showThrobbers').perform();
if (this.showSettingsMenu && !this._showSettingsMenu) {
this.showThrobbers.perform();
}
// fired when menu is closed
if (!this.get('showSettingsMenu') && this._showSettingsMenu) {
let post = this.get('post');
if (!this.showSettingsMenu && this._showSettingsMenu) {
let post = this.post;
let errors = post.get('errors');
// reset the publish date if it has an error
@ -109,7 +109,7 @@ export default Component.extend(SettingsMenuMixin, {
this.set('_showThrobbers', false);
}
this._showSettingsMenu = this.get('showSettingsMenu');
this._showSettingsMenu = this.showSettingsMenu;
},
actions: {
@ -130,7 +130,7 @@ export default Component.extend(SettingsMenuMixin, {
this._super(...arguments);
this.set('subview', null);
this.get('showThrobbers').perform();
this.showThrobbers.perform();
},
discardEnter() {
@ -146,9 +146,9 @@ export default Component.extend(SettingsMenuMixin, {
return;
}
this.get('savePost').perform().catch((error) => {
this.savePost.perform().catch((error) => {
this.showError(error);
this.get('post').rollbackAttributes();
this.post.rollbackAttributes();
});
},
@ -156,16 +156,16 @@ export default Component.extend(SettingsMenuMixin, {
* triggered by user manually changing slug
*/
updateSlug(newSlug) {
return this.get('updateSlug')
return this.updateSlug
.perform(newSlug)
.catch((error) => {
this.showError(error);
this.get('post').rollbackAttributes();
this.post.rollbackAttributes();
});
},
setPublishedAtBlogDate(date) {
let post = this.get('post');
let post = this.post;
let dateString = moment(date).format('YYYY-MM-DD');
post.get('errors').remove('publishedAtBlogDate');
@ -174,12 +174,12 @@ export default Component.extend(SettingsMenuMixin, {
post.validate({property: 'publishedAtBlog'});
} else {
post.set('publishedAtBlogDate', dateString);
return this.get('savePost').perform();
return this.savePost.perform();
}
},
setPublishedAtBlogTime(time) {
let post = this.get('post');
let post = this.post;
post.get('errors').remove('publishedAtBlogDate');
@ -187,12 +187,12 @@ export default Component.extend(SettingsMenuMixin, {
post.validate({property: 'publishedAtBlog'});
} else {
post.set('publishedAtBlogTime', time);
return this.get('savePost').perform();
return this.savePost.perform();
}
},
setCustomExcerpt(excerpt) {
let post = this.get('post');
let post = this.post;
let currentExcerpt = post.get('customExcerpt');
if (excerpt === currentExcerpt) {
@ -201,11 +201,11 @@ export default Component.extend(SettingsMenuMixin, {
post.set('customExcerpt', excerpt);
return post.validate({property: 'customExcerpt'}).then(() => this.get('savePost').perform());
return post.validate({property: 'customExcerpt'}).then(() => this.savePost.perform());
},
setHeaderInjection(code) {
let post = this.get('post');
let post = this.post;
let currentCode = post.get('codeinjectionHead');
if (code === currentCode) {
@ -214,11 +214,11 @@ export default Component.extend(SettingsMenuMixin, {
post.set('codeinjectionHead', code);
return post.validate({property: 'codeinjectionHead'}).then(() => this.get('savePost').perform());
return post.validate({property: 'codeinjectionHead'}).then(() => this.savePost.perform());
},
setFooterInjection(code) {
let post = this.get('post');
let post = this.post;
let currentCode = post.get('codeinjectionFoot');
if (code === currentCode) {
@ -227,12 +227,12 @@ export default Component.extend(SettingsMenuMixin, {
post.set('codeinjectionFoot', code);
return post.validate({property: 'codeinjectionFoot'}).then(() => this.get('savePost').perform());
return post.validate({property: 'codeinjectionFoot'}).then(() => this.savePost.perform());
},
setMetaTitle(metaTitle) {
// Grab the post and current stored meta title
let post = this.get('post');
let post = this.post;
let currentTitle = post.get('metaTitle');
// If the title entered matches the stored meta title, do nothing
@ -249,13 +249,13 @@ export default Component.extend(SettingsMenuMixin, {
return;
}
return this.get('savePost').perform();
return this.savePost.perform();
});
},
setMetaDescription(metaDescription) {
// Grab the post and current stored meta description
let post = this.get('post');
let post = this.post;
let currentDescription = post.get('metaDescription');
// If the title entered matches the stored meta title, do nothing
@ -272,13 +272,13 @@ export default Component.extend(SettingsMenuMixin, {
return;
}
return this.get('savePost').perform();
return this.savePost.perform();
});
},
setOgTitle(ogTitle) {
// Grab the post and current stored facebook title
let post = this.get('post');
let post = this.post;
let currentTitle = post.get('ogTitle');
// If the title entered matches the stored facebook title, do nothing
@ -295,13 +295,13 @@ export default Component.extend(SettingsMenuMixin, {
return;
}
return this.get('savePost').perform();
return this.savePost.perform();
});
},
setOgDescription(ogDescription) {
// Grab the post and current stored facebook description
let post = this.get('post');
let post = this.post;
let currentDescription = post.get('ogDescription');
// If the title entered matches the stored facebook description, do nothing
@ -318,13 +318,13 @@ export default Component.extend(SettingsMenuMixin, {
return;
}
return this.get('savePost').perform();
return this.savePost.perform();
});
},
setTwitterTitle(twitterTitle) {
// Grab the post and current stored twitter title
let post = this.get('post');
let post = this.post;
let currentTitle = post.get('twitterTitle');
// If the title entered matches the stored twitter title, do nothing
@ -341,13 +341,13 @@ export default Component.extend(SettingsMenuMixin, {
return;
}
return this.get('savePost').perform();
return this.savePost.perform();
});
},
setTwitterDescription(twitterDescription) {
// Grab the post and current stored twitter description
let post = this.get('post');
let post = this.post;
let currentDescription = post.get('twitterDescription');
// If the description entered matches the stored twitter description, do nothing
@ -364,7 +364,7 @@ export default Component.extend(SettingsMenuMixin, {
return;
}
return this.get('savePost').perform();
return this.savePost.perform();
});
},
@ -375,9 +375,9 @@ export default Component.extend(SettingsMenuMixin, {
return;
}
this.get('savePost').perform().catch((error) => {
this.savePost.perform().catch((error) => {
this.showError(error);
this.get('post').rollbackAttributes();
this.post.rollbackAttributes();
});
},
@ -388,9 +388,9 @@ export default Component.extend(SettingsMenuMixin, {
return;
}
this.get('savePost').perform().catch((error) => {
this.savePost.perform().catch((error) => {
this.showError(error);
this.get('post').rollbackAttributes();
this.post.rollbackAttributes();
});
},
@ -401,9 +401,9 @@ export default Component.extend(SettingsMenuMixin, {
return;
}
this.get('savePost').perform().catch((error) => {
this.savePost.perform().catch((error) => {
this.showError(error);
this.get('post').rollbackAttributes();
this.post.rollbackAttributes();
});
},
@ -414,9 +414,9 @@ export default Component.extend(SettingsMenuMixin, {
return;
}
this.get('savePost').perform().catch((error) => {
this.savePost.perform().catch((error) => {
this.showError(error);
this.get('post').rollbackAttributes();
this.post.rollbackAttributes();
});
},
@ -427,9 +427,9 @@ export default Component.extend(SettingsMenuMixin, {
return;
}
this.get('savePost').perform().catch((error) => {
this.savePost.perform().catch((error) => {
this.showError(error);
this.get('post').rollbackAttributes();
this.post.rollbackAttributes();
});
},
@ -440,14 +440,14 @@ export default Component.extend(SettingsMenuMixin, {
return;
}
this.get('savePost').perform().catch((error) => {
this.savePost.perform().catch((error) => {
this.showError(error);
this.get('post').rollbackAttributes();
this.post.rollbackAttributes();
});
},
changeAuthors(newAuthors) {
let post = this.get('post');
let post = this.post;
// return if nothing changed
if (newAuthors.mapBy('id').join() === post.get('authors').mapBy('id').join()) {
@ -462,15 +462,15 @@ export default Component.extend(SettingsMenuMixin, {
return;
}
this.get('savePost').perform().catch((error) => {
this.savePost.perform().catch((error) => {
this.showError(error);
post.rollbackAttributes();
});
},
deletePost() {
if (this.get('deletePost')) {
this.get('deletePost')();
if (this.deletePost) {
this.deletePost();
}
}
},
@ -483,7 +483,7 @@ export default Component.extend(SettingsMenuMixin, {
showError(error) {
// TODO: remove null check once ValidationEngine has been removed
if (error) {
this.get('notifications').showAPIError(error);
this.notifications.showAPIError(error);
}
}
});

View File

@ -46,17 +46,17 @@ export default Component.extend({
}),
didReceiveAttrs() {
if (this.get('active')) {
if (this.active) {
this.scrollIntoView();
}
},
click() {
this.onClick(this.get('post'));
this.onClick(this.post);
},
doubleClick() {
this.onDoubleClick(this.get('post'));
this.onDoubleClick(this.post);
},
scrollIntoView() {

View File

@ -54,7 +54,7 @@ export default Component.extend({
this._super(...arguments);
if (this.get('config.useGravatar')) {
this.get('setGravatar').perform();
this.setGravatar.perform();
}
},
@ -119,12 +119,12 @@ export default Component.extend({
},
setGravatar: task(function* () {
yield timeout(this.get('debounce'));
yield timeout(this.debounce);
let email = this.get('email');
let email = this.email;
if (validator.isEmail(email || '')) {
let size = this.get('size');
let size = this.size;
let gravatarUrl = `//www.gravatar.com/avatar/${md5(email)}?s=${size}&d=404`;
try {
@ -158,7 +158,7 @@ export default Component.extend({
let fileName = data.files[0].name;
if ((/\.(gif|jpe?g|png|svg?z)$/i).test(fileName)) {
let action = this.get('setImage');
let action = this.setImage;
if (action) {
action(data);
}

View File

@ -14,7 +14,7 @@ export default Component.extend({
didReceiveAttrs() {
this._super(...arguments);
let percentage = this.get('percentage');
let percentage = this.percentage;
let width = (percentage > 0) ? `${percentage}%` : '0';
this.set('progressStyle', htmlSafe(`width: ${width}`));

View File

@ -18,7 +18,7 @@ export default Component.extend({
updateAuthors() {},
availableAuthorNames: computed('availableAuthors.@each.name', function () {
return this.get('availableAuthors').map(author => author.get('name').toLowerCase());
return this.availableAuthors.map(author => author.get('name').toLowerCase());
}),
init() {

View File

@ -38,7 +38,7 @@ export default Component.extend({
},
hideCreateOptionOnMatchingTag(term) {
return !this.get('availableTagNames').includes(term.toLowerCase());
return !this.availableTagNames.includes(term.toLowerCase());
},
updateTags(newTags) {

View File

@ -41,7 +41,7 @@ export default Component.extend({
}),
selectedTemplate: computed('post.customTemplate', 'customTemplates.[]', function () {
let templates = this.get('customTemplates');
let templates = this.customTemplates;
let filename = this.get('post.customTemplate');
return templates.findBy('filename', filename);
@ -50,7 +50,7 @@ export default Component.extend({
// hooks
didInsertElement() {
this._super(...arguments);
this.get('loadActiveTheme').perform();
this.loadActiveTheme.perform();
},
actions: {
@ -61,7 +61,7 @@ export default Component.extend({
// tasks
loadActiveTheme: task(function* () {
let store = this.get('store');
let store = this.store;
let themes = yield store.peekAll('theme');
if (isEmpty(themes)) {

View File

@ -14,19 +14,19 @@ export default Component.extend({
'data-test-publishmenu-draft': true,
didInsertElement() {
this.get('post').set('publishedAtBlogTZ', this.get('post.publishedAtUTC'));
this.post.set('publishedAtBlogTZ', this.get('post.publishedAtUTC'));
this.send('setSaveType', 'publish');
},
actions: {
setSaveType(type) {
if (this.get('saveType') !== type) {
if (this.saveType !== type) {
let hasDateError = !isEmpty(this.get('post.errors').errorsFor('publishedAtBlogDate'));
let hasTimeError = !isEmpty(this.get('post.errors').errorsFor('publishedAtBlogTime'));
let minDate = this._getMinDate();
this.set('_minDate', minDate);
this.get('setSaveType')(type);
this.setSaveType(type);
// when publish: switch to now to avoid validation errors
// when schedule: switch to last valid or new minimum scheduled date
@ -37,21 +37,21 @@ export default Component.extend({
this._publishedAtBlogTZ = this.get('post.publishedAtUTC');
}
this.get('post').set('publishedAtBlogTZ', this.get('post.publishedAtUTC'));
this.post.set('publishedAtBlogTZ', this.get('post.publishedAtUTC'));
} else {
if (!this._publishedAtBlogTZ || moment(this._publishedAtBlogTZ).isBefore(minDate)) {
this.get('post').set('publishedAtBlogTZ', minDate);
this.post.set('publishedAtBlogTZ', minDate);
} else {
this.get('post').set('publishedAtBlogTZ', this._publishedAtBlogTZ);
this.post.set('publishedAtBlogTZ', this._publishedAtBlogTZ);
}
}
this.get('post').validate();
this.post.validate();
}
},
setDate(date) {
let post = this.get('post');
let post = this.post;
let dateString = moment(date).format('YYYY-MM-DD');
post.set('publishedAtBlogDate', dateString);
@ -59,7 +59,7 @@ export default Component.extend({
},
setTime(time) {
let post = this.get('post');
let post = this.post;
post.set('publishedAtBlogTime', time);
return post.validate();

View File

@ -5,6 +5,6 @@ export default Component.extend({
'data-test-publishmenu-published': true,
didInsertElement() {
this.get('setSaveType')('publish');
this.setSaveType('publish');
}
});

View File

@ -29,29 +29,29 @@ export default Component.extend({
didInsertElement() {
this.set('_minDate', new Date());
this.get('setSaveType')('schedule');
this.setSaveType('schedule');
},
actions: {
setSaveType(type) {
if (this.get('saveType') !== type) {
if (this.saveType !== type) {
this.set('_minDate', new Date());
this.get('setSaveType')(type);
this.setSaveType(type);
// when draft switch to now to avoid validation errors
// when schedule switch back to saved date to avoid unnecessary re-scheduling
if (type === 'draft') {
this.get('post').set('publishedAtBlogTZ', new Date());
this.post.set('publishedAtBlogTZ', new Date());
} else {
this.get('post').set('publishedAtBlogTZ', this.get('post.publishedAtUTC'));
this.post.set('publishedAtBlogTZ', this.get('post.publishedAtUTC'));
}
this.get('post').validate();
this.post.validate();
}
},
setDate(date) {
let post = this.get('post');
let post = this.post;
let dateString = moment(date).format('YYYY-MM-DD');
post.set('publishedAtBlogDate', dateString);
@ -59,9 +59,9 @@ export default Component.extend({
},
setTime(time) {
let post = this.get('post');
let post = this.post;
if (!this.get('isClosing')) {
if (!this.isClosing) {
post.set('publishedAtBlogTime', time);
return post.validate();
}

View File

@ -23,7 +23,7 @@ export default Component.extend({
forcePublishedMenu: reads('post.pastScheduledTime'),
postState: computed('post.{isPublished,isScheduled}', 'forcePublishedMenu', function () {
if (this.get('forcePublishedMenu') || this.get('post.isPublished')) {
if (this.forcePublishedMenu || this.get('post.isPublished')) {
return 'published';
} else if (this.get('post.isScheduled')) {
return 'scheduled';
@ -33,7 +33,7 @@ export default Component.extend({
}),
triggerText: computed('postState', function () {
let state = this.get('postState');
let state = this.postState;
if (state === 'published') {
return 'Update';
@ -45,8 +45,8 @@ export default Component.extend({
}),
_runningText: computed('postState', 'saveType', function () {
let saveType = this.get('saveType');
let postState = this.get('postState');
let saveType = this.saveType;
let postState = this.postState;
let runningText;
if (postState === 'draft') {
@ -65,8 +65,8 @@ export default Component.extend({
}),
buttonText: computed('postState', 'saveType', function () {
let saveType = this.get('saveType');
let postState = this.get('postState');
let saveType = this.saveType;
let postState = this.postState;
let buttonText;
if (postState === 'draft') {
@ -85,8 +85,8 @@ export default Component.extend({
}),
successText: computed('_previousStatus', 'postState', function () {
let postState = this.get('postState');
let previousStatus = this.get('_previousStatus');
let postState = this.postState;
let previousStatus = this._previousStatus;
let buttonText;
if (previousStatus === 'draft') {
@ -112,7 +112,7 @@ export default Component.extend({
// calls to `setSaveType` due to the component re-rendering
// TODO: we should have a better way of dealing with this where we don't
// rely on the side-effect of component rendering calling setSaveType
let postStatus = this.get('postStatus');
let postStatus = this.postStatus;
if (postStatus !== this._postStatus) {
if (this.get('saveTask.isRunning')) {
this.get('saveTask.last').then(() => {
@ -123,12 +123,12 @@ export default Component.extend({
}
}
this._postStatus = this.get('postStatus');
this._postStatus = this.postStatus;
},
actions: {
setSaveType(saveType) {
let post = this.get('post');
let post = this.post;
this.set('saveType', saveType);
@ -145,13 +145,13 @@ export default Component.extend({
this._cachePublishedAtBlogTZ();
this.set('isClosing', false);
this.get('post.errors').clear();
if (this.get('onOpen')) {
this.get('onOpen')();
if (this.onOpen) {
this.onOpen();
}
},
close(dropdown, e) {
let post = this.get('post');
let post = this.post;
// don't close the menu if the datepicker popup is clicked
if (e && $(e.target).closest('.ember-power-datepicker-content').length) {
@ -163,8 +163,8 @@ export default Component.extend({
post.set('statusScratch', null);
post.validate();
if (this.get('onClose')) {
this.get('onClose')();
if (this.onClose) {
this.onClose();
}
this.set('isClosing', true);
@ -176,16 +176,16 @@ export default Component.extend({
save: task(function* () {
// runningText needs to be declared before the other states change during the
// save action.
this.set('runningText', this.get('_runningText'));
this.set('runningText', this._runningText);
this.set('_previousStatus', this.get('post.status'));
this.get('setSaveType')(this.get('saveType'));
this.setSaveType(this.saveType);
try {
// validate publishedAtBlog first to avoid an alert for displayed errors
yield this.get('post').validate({property: 'publishedAtBlog'});
yield this.post.validate({property: 'publishedAtBlog'});
// actual save will show alert for other failed validations
let post = yield this.get('saveTask').perform();
let post = yield this.saveTask.perform();
this._cachePublishedAtBlogTZ();
return post;
@ -204,6 +204,6 @@ export default Component.extend({
// when closing the menu we reset the publishedAtBlogTZ date so that the
// unsaved changes made to the scheduled date aren't reflected in the PSM
_resetPublishedAtBlogTZ() {
this.get('post').set('publishedAtBlogTZ', this._publishedAtBlogTZ);
this.post.set('publishedAtBlogTZ', this._publishedAtBlogTZ);
}
});

View File

@ -8,7 +8,7 @@ export default Component.extend(InViewportMixin, {
registerElement() {},
didInsertElement() {
let offset = this.get('triggerOffset') || {};
let offset = this.triggerOffset || {};
// if triggerOffset is a number we use it for all dimensions
if (typeof offset === 'number') {

View File

@ -19,7 +19,7 @@ export default Component.extend({
}
}
this.get('select').actions.search(term);
this.select.actions.search(term);
},
focusInput() {
@ -31,7 +31,7 @@ export default Component.extend({
},
handleKeydown(e) {
let select = this.get('select');
let select = this.select;
// TODO: remove keycode check once EPS is updated to 1.0
if (!select.isOpen || e.keyCode === 32) {

View File

@ -9,12 +9,12 @@ import {task, timeout, waitForProperty} from 'ember-concurrency';
export function computedGroup(category) {
return computed('content', 'currentSearch', function () {
if (!this.get('currentSearch') || !this.get('content')) {
if (!this.currentSearch || !this.content) {
return [];
}
return this.get('content').filter((item) => {
let search = this.get('currentSearch').toString().toLowerCase();
return this.content.filter((item) => {
let search = this.currentSearch.toString().toLowerCase();
return (item.category === category) && (item.title.toString().toLowerCase().indexOf(search) >= 0);
});
@ -41,20 +41,20 @@ export default Component.extend({
groupedContent: computed('posts', 'pages', 'users', 'tags', function () {
let groups = [];
if (!isEmpty(this.get('posts'))) {
groups.pushObject({groupName: 'Posts', options: this.get('posts')});
if (!isEmpty(this.posts)) {
groups.pushObject({groupName: 'Posts', options: this.posts});
}
if (!isEmpty(this.get('pages'))) {
groups.pushObject({groupName: 'Pages', options: this.get('pages')});
if (!isEmpty(this.pages)) {
groups.pushObject({groupName: 'Pages', options: this.pages});
}
if (!isEmpty(this.get('users'))) {
groups.pushObject({groupName: 'Users', options: this.get('users')});
if (!isEmpty(this.users)) {
groups.pushObject({groupName: 'Users', options: this.users});
}
if (!isEmpty(this.get('tags'))) {
groups.pushObject({groupName: 'Tags', options: this.get('tags')});
if (!isEmpty(this.tags)) {
groups.pushObject({groupName: 'Tags', options: this.tags});
}
return groups;
@ -73,22 +73,22 @@ export default Component.extend({
if (selected.category === 'Posts') {
let id = selected.id.replace('post.', '');
this.get('router').transitionTo('editor.edit', 'post', id);
this.router.transitionTo('editor.edit', 'post', id);
}
if (selected.category === 'Pages') {
let id = selected.id.replace('page.', '');
this.get('router').transitionTo('editor.edit', 'page', id);
this.router.transitionTo('editor.edit', 'page', id);
}
if (selected.category === 'Users') {
let id = selected.id.replace('user.', '');
this.get('router').transitionTo('staff.user', id);
this.router.transitionTo('staff.user', id);
}
if (selected.category === 'Tags') {
let id = selected.id.replace('tag.', '');
this.get('router').transitionTo('settings.tags.tag', id);
this.router.transitionTo('settings.tags.tag', id);
}
},
@ -123,13 +123,13 @@ export default Component.extend({
// set dependent CP term and re-calculate CP
this.set('currentSearch', term);
return this.get('groupedContent');
return this.groupedContent;
}).restartable(),
refreshContent: task(function* () {
let promises = [];
let now = new Date();
let contentExpiresAt = this.get('contentExpiresAt');
let contentExpiresAt = this.contentExpiresAt;
if (contentExpiresAt > now) {
return true;
@ -148,75 +148,75 @@ export default Component.extend({
console.error(error);
}
let contentExpiry = this.get('contentExpiry');
let contentExpiry = this.contentExpiry;
this.set('contentExpiresAt', new Date(now.getTime() + contentExpiry));
}).drop(),
_loadPosts() {
let store = this.get('store');
let store = this.store;
let postsUrl = `${store.adapterFor('post').urlForQuery({}, 'post')}/`;
let postsQuery = {fields: 'id,title,page', limit: 'all', status: 'all'};
let content = this.get('content');
let content = this.content;
return this.get('ajax').request(postsUrl, {data: postsQuery}).then((posts) => {
return this.ajax.request(postsUrl, {data: postsQuery}).then((posts) => {
content.pushObjects(posts.posts.map(post => ({
id: `post.${post.id}`,
title: post.title,
category: 'Posts'
})));
}).catch((error) => {
this.get('notifications').showAPIError(error, {key: 'search.loadPosts.error'});
this.notifications.showAPIError(error, {key: 'search.loadPosts.error'});
});
},
_loadPages() {
let store = this.get('store');
let store = this.store;
let pagesUrl = `${store.adapterFor('page').urlForQuery({}, 'page')}/`;
let pagesQuery = {fields: 'id,title,page', limit: 'all', status: 'all'};
let content = this.get('content');
let content = this.content;
return this.get('ajax').request(pagesUrl, {data: pagesQuery}).then((pages) => {
return this.ajax.request(pagesUrl, {data: pagesQuery}).then((pages) => {
content.pushObjects(pages.pages.map(page => ({
id: `page.${page.id}`,
title: page.title,
category: 'Pages'
})));
}).catch((error) => {
this.get('notifications').showAPIError(error, {key: 'search.loadPosts.error'});
this.notifications.showAPIError(error, {key: 'search.loadPosts.error'});
});
},
_loadUsers() {
let store = this.get('store');
let store = this.store;
let usersUrl = `${store.adapterFor('user').urlForQuery({}, 'user')}/`;
let usersQuery = {fields: 'name,slug', limit: 'all'};
let content = this.get('content');
let content = this.content;
return this.get('ajax').request(usersUrl, {data: usersQuery}).then((users) => {
return this.ajax.request(usersUrl, {data: usersQuery}).then((users) => {
content.pushObjects(users.users.map(user => ({
id: `user.${user.slug}`,
title: user.name,
category: 'Users'
})));
}).catch((error) => {
this.get('notifications').showAPIError(error, {key: 'search.loadUsers.error'});
this.notifications.showAPIError(error, {key: 'search.loadUsers.error'});
});
},
_loadTags() {
let store = this.get('store');
let store = this.store;
let tagsUrl = `${store.adapterFor('tag').urlForQuery({}, 'tag')}/`;
let tagsQuery = {fields: 'name,slug', limit: 'all'};
let content = this.get('content');
let content = this.content;
return this.get('ajax').request(tagsUrl, {data: tagsQuery}).then((tags) => {
return this.ajax.request(tagsUrl, {data: tagsQuery}).then((tags) => {
content.pushObjects(tags.tags.map(tag => ({
id: `tag.${tag.slug}`,
title: tag.name,
category: 'Tags'
})));
}).catch((error) => {
this.get('notifications').showAPIError(error, {key: 'search.loadTags.error'});
this.notifications.showAPIError(error, {key: 'search.loadTags.error'});
});
},

View File

@ -28,9 +28,9 @@ export default TextArea.extend({
// https://github.com/sparksuite/simplemde-markdown-editor#configuration
defaultOptions: computed(function () {
return {
autofocus: this.get('autofocus'),
autofocus: this.autofocus,
indentWithTabs: false,
placeholder: this.get('placeholder'),
placeholder: this.placeholder,
tabSize: 4
};
}),
@ -38,7 +38,7 @@ export default TextArea.extend({
init() {
this._super(...arguments);
if (isEmpty(this.get('options'))) {
if (isEmpty(this.options)) {
this.set('options', {});
}
},
@ -53,9 +53,9 @@ export default TextArea.extend({
// compare values before forcing a content reset to avoid clobbering
// the undo behaviour
if (this.get('value') !== this._editor.value()) {
if (this.value !== this._editor.value()) {
let cursor = this._editor.codemirror.getDoc().getCursor();
this._editor.value(this.get('value'));
this._editor.value(this.value);
this._editor.codemirror.getDoc().setCursor(cursor);
}
},
@ -78,8 +78,8 @@ export default TextArea.extend({
let editorOptions = assign(
{element: document.getElementById(this.elementId)},
this.get('defaultOptions'),
this.get('options')
this.defaultOptions,
this.options
);
// disable spellchecker when testing so that the exterally loaded plugin
@ -89,7 +89,7 @@ export default TextArea.extend({
}
this._editor = new SimpleMDE(editorOptions);
this._editor.value(this.get('value') || '');
this._editor.value(this.value || '');
this._editor.codemirror.on('change', (instance, changeObj) => {
// avoid a "modified x twice in a single render" error that occurs
@ -107,7 +107,7 @@ export default TextArea.extend({
this.onBlur();
});
if (this.get('autofocus')) {
if (this.autofocus) {
this._editor.codemirror.execCommand('goDocEnd');
}

View File

@ -7,9 +7,9 @@ export default Component.extend({
actions: {
onScrolledToBottom() {
let loadNextPage = this.get('loadNextPage');
let loadNextPage = this.loadNextPage;
if (!this.get('isLoading')) {
if (!this.isLoading) {
loadNextPage();
}
}

View File

@ -39,9 +39,9 @@ export default Component.extend({
}),
seoTitle: computed('scratchName', 'scratchMetaTitle', function () {
let metaTitle = this.get('scratchMetaTitle') || '';
let metaTitle = this.scratchMetaTitle || '';
metaTitle = metaTitle.length > 0 ? metaTitle : this.get('scratchName');
metaTitle = metaTitle.length > 0 ? metaTitle : this.scratchName;
if (metaTitle && metaTitle.length > 70) {
metaTitle = metaTitle.substring(0, 70).trim();
@ -54,7 +54,7 @@ export default Component.extend({
seoURL: computed('scratchSlug', function () {
let blogUrl = this.get('config.blogUrl');
let seoSlug = this.get('scratchSlug') || '';
let seoSlug = this.scratchSlug || '';
let seoURL = `${blogUrl}/tag/${seoSlug}`;
@ -73,9 +73,9 @@ export default Component.extend({
}),
seoDescription: computed('scratchDescription', 'scratchMetaDescription', function () {
let metaDescription = this.get('scratchMetaDescription') || '';
let metaDescription = this.scratchMetaDescription || '';
metaDescription = metaDescription.length > 0 ? metaDescription : this.get('scratchDescription');
metaDescription = metaDescription.length > 0 ? metaDescription : this.scratchDescription;
if (metaDescription && metaDescription.length > 156) {
metaDescription = metaDescription.substring(0, 156).trim();

View File

@ -17,9 +17,9 @@ export default Component.extend({
isEmpty: equal('tags.length', 0),
displaySettingsPane: computed('isEmpty', 'selectedTag', 'isMobile', function () {
let isEmpty = this.get('isEmpty');
let selectedTag = this.get('selectedTag');
let isMobile = this.get('isMobile');
let isEmpty = this.isEmpty;
let selectedTag = this.selectedTag;
let isMobile = this.isMobile;
// always display settings pane for blank-slate on mobile
if (isMobile && isEmpty) {
@ -37,17 +37,17 @@ export default Component.extend({
init() {
this._super(...arguments);
this.get('mediaQueries').on('change', this, this._fireMobileChangeActions);
this.mediaQueries.on('change', this, this._fireMobileChangeActions);
},
willDestroyElement() {
this._super(...arguments);
this.get('mediaQueries').off('change', this, this._fireMobileChangeActions);
this.mediaQueries.off('change', this, this._fireMobileChangeActions);
},
_fireMobileChangeActions(key, value) {
if (key === 'maxWidth600') {
let leftMobileAction = this.get('leftMobile');
let leftMobileAction = this.leftMobile;
this.set('isMobile', value);

View File

@ -50,19 +50,19 @@ const GhTaskButton = Component.extend({
}),
isIdleClass: computed('isIdle', function () {
if (this.get('isIdle')) {
return this.get('idleClass');
if (this.isIdle) {
return this.idleClass;
}
}),
isRunningClass: computed('isRunning', function () {
if (this.get('isRunning')) {
return this.get('runningClass') || this.get('idleClass');
if (this.isRunning) {
return this.runningClass || this.idleClass;
}
}),
isSuccess: computed('hasRun', 'isRunning', 'task.last.value', function () {
if (!this.get('hasRun') || this.get('isRunning')) {
if (!this.hasRun || this.isRunning) {
return false;
}
@ -71,13 +71,13 @@ const GhTaskButton = Component.extend({
}),
isSuccessClass: computed('isSuccess', function () {
if (this.get('isSuccess')) {
return this.get('successClass');
if (this.isSuccess) {
return this.successClass;
}
}),
isFailure: computed('hasRun', 'isRunning', 'isSuccess', 'task.last.error', function () {
if (!this.get('hasRun') || this.get('isRunning') || this.get('isSuccess')) {
if (!this.hasRun || this.isRunning || this.isSuccess) {
return false;
}
@ -85,13 +85,13 @@ const GhTaskButton = Component.extend({
}),
isFailureClass: computed('isFailure', function () {
if (this.get('isFailure')) {
return this.get('failureClass');
if (this.isFailure) {
return this.failureClass;
}
}),
isIdle: computed('isRunning', 'isSuccess', 'isFailure', function () {
return !this.get('isRunning') && !this.get('isSuccess') && !this.get('isFailure');
return !this.isRunning && !this.isSuccess && !this.isFailure;
}),
init() {
@ -105,31 +105,31 @@ const GhTaskButton = Component.extend({
// task directly
if (this.defaultClick) {
if (!this.isRunning) {
this.get('_restartAnimation').perform();
this._restartAnimation.perform();
}
return;
}
// do nothing if disabled externally
if (this.get('disabled')) {
if (this.disabled) {
return false;
}
let task = this.get('task');
let task = this.task;
let taskName = this.get('task.name');
let lastTaskName = this.get('task.last.task.name');
// task-buttons are never disabled whilst running so that clicks when a
// taskGroup is running don't get dropped BUT that means we need to check
// here to avoid spamming actions from multiple clicks
if (this.get('isRunning') && taskName === lastTaskName) {
if (this.isRunning && taskName === lastTaskName) {
return;
}
this.action();
task.perform();
this.get('_restartAnimation').perform();
this._restartAnimation.perform();
// prevent the click from bubbling and triggering form actions
return false;

View File

@ -14,7 +14,7 @@ export default TextArea.extend(TextInputMixin, {
this._super(...arguments);
// trigger auto-expand any time the value changes
if (this.get('autoExpand')) {
if (this.autoExpand) {
run.scheduleOnce('afterRender', this, this._autoExpand);
}
},
@ -23,7 +23,7 @@ export default TextArea.extend(TextInputMixin, {
this._super(...arguments);
// disable the draggable resize element that browsers add to textareas
if (this.get('autoExpand')) {
if (this.autoExpand) {
this.element.style.resize = 'none';
}
},
@ -33,12 +33,12 @@ export default TextArea.extend(TextInputMixin, {
// set up resize handler on element insert so that we can autoexpand
// when the element container changes size
if (this.get('autoExpand')) {
if (this.autoExpand) {
run.scheduleOnce('afterRender', this, this._setupAutoExpand);
}
if (this.get('didCreateTextarea')) {
this.get('didCreateTextarea')(this.element);
if (this.didCreateTextarea) {
this.didCreateTextarea(this.element);
}
},
@ -60,7 +60,7 @@ export default TextArea.extend(TextInputMixin, {
_setupAutoExpand() {
this._resizeCallback = run.bind(this, this._onResize);
this.get('resizeDetector').setup(this.get('autoExpand'), this._resizeCallback);
this.resizeDetector.setup(this.autoExpand, this._resizeCallback);
this._autoExpand();
},
@ -69,6 +69,6 @@ export default TextArea.extend(TextInputMixin, {
},
_teardownAutoExpand() {
this.get('resizeDetector').teardown(this.get('autoExpand'), this._resizeCallback);
this.resizeDetector.teardown(this.autoExpand, this._resizeCallback);
}
});

View File

@ -7,7 +7,7 @@ export default Component.extend({
themes: null,
sortedThemes: computed('themes.@each.active', function () {
let themes = get(this, 'themes').map((t) => {
let themes = this.themes.map((t) => {
let theme = {};
let themePackage = get(t, 'package');

View File

@ -18,16 +18,16 @@ export default Component.extend({
availableTimezoneNames: mapBy('availableTimezones', 'name'),
hasTimezoneOverride: computed('activeTimezone', 'availableTimezoneNames', function () {
let activeTimezone = this.get('activeTimezone');
let availableTimezoneNames = this.get('availableTimezoneNames');
let activeTimezone = this.activeTimezone;
let availableTimezoneNames = this.availableTimezoneNames;
return !availableTimezoneNames.includes(activeTimezone);
}),
selectedTimezone: computed('activeTimezone', 'availableTimezones', 'hasTimezoneOverride', function () {
let hasTimezoneOverride = this.get('hasTimezoneOverride');
let activeTimezone = this.get('activeTimezone');
let availableTimezones = this.get('availableTimezones');
let hasTimezoneOverride = this.hasTimezoneOverride;
let activeTimezone = this.activeTimezone;
let availableTimezones = this.availableTimezones;
if (hasTimezoneOverride) {
return {name: '', label: ''};
@ -39,8 +39,8 @@ export default Component.extend({
}),
selectableTimezones: computed('availableTimezones', 'hasTimezoneOverride', function () {
let hasTimezoneOverride = this.get('hasTimezoneOverride');
let availableTimezones = this.get('availableTimezones');
let hasTimezoneOverride = this.hasTimezoneOverride;
let availableTimezones = this.availableTimezones;
if (hasTimezoneOverride) {
return [{name: '', label: ''}, ...availableTimezones];
@ -50,8 +50,8 @@ export default Component.extend({
}),
localTime: computed('hasTimezoneOverride', 'activeTimezone', 'selectedTimezone', 'clock.second', function () {
let hasTimezoneOverride = this.get('hasTimezoneOverride');
let timezone = hasTimezoneOverride ? this.get('activeTimezone') : this.get('selectedTimezone.name');
let hasTimezoneOverride = this.hasTimezoneOverride;
let timezone = hasTimezoneOverride ? this.activeTimezone : this.get('selectedTimezone.name');
this.get('clock.second');
return timezone ? moment().tz(timezone).format('HH:mm:ss') : moment().utc().format('HH:mm:ss');

View File

@ -30,7 +30,7 @@ export default Component.extend({
triggerComponent: 'gh-token-input/trigger',
optionsWithoutSelected: computed('options.[]', 'selected.[]', function () {
return this.get('optionsWithoutSelectedTask').perform();
return this.optionsWithoutSelectedTask.perform();
}),
actions: {
@ -41,7 +41,7 @@ export default Component.extend({
let lastSelection = select.selected[select.selected.length - 1];
if (lastSelection) {
this.get('onchange')(select.selected.slice(0, -1), select);
this.onchange(select.selected.slice(0, -1), select);
select.actions.search('');
select.actions.open(event);
}
@ -65,40 +65,40 @@ export default Component.extend({
onfocus() {
key.setScope('gh-token-input');
if (this.get('onfocus')) {
this.get('onfocus')(...arguments);
if (this.onfocus) {
this.onfocus(...arguments);
}
},
onblur() {
key.setScope('default');
if (this.get('onblur')) {
this.get('onblur')(...arguments);
if (this.onblur) {
this.onblur(...arguments);
}
}
},
optionsWithoutSelectedTask: task(function* () {
let options = yield this.get('options');
let selected = yield this.get('selected');
let options = yield this.options;
let selected = yield this.selected;
return options.filter(o => !selected.includes(o));
}),
shouldShowCreateOption(term, options) {
if (!this.get('allowCreation')) {
if (!this.allowCreation) {
return false;
}
if (this.get('showCreateWhen')) {
return this.get('showCreateWhen')(term, options);
if (this.showCreateWhen) {
return this.showCreateWhen(term, options);
} else {
return this.hideCreateOptionOnSameTerm(term, options);
}
},
hideCreateOptionOnSameTerm(term, options) {
let searchField = this.get('searchField');
let searchField = this.searchField;
let existingOption = options.findBy(searchField, term);
return !existingOption;
},
@ -110,17 +110,17 @@ export default Component.extend({
},
searchAndSuggest(term, select) {
return this.get('searchAndSuggestTask').perform(term, select);
return this.searchAndSuggestTask.perform(term, select);
},
searchAndSuggestTask: task(function* (term, select) {
let newOptions = (yield this.get('optionsWithoutSelected')).toArray();
let newOptions = (yield this.optionsWithoutSelected).toArray();
if (term.length === 0) {
return newOptions;
}
let searchAction = this.get('search');
let searchAction = this.search;
if (searchAction) {
let results = yield searchAction(term, select);
@ -153,9 +153,9 @@ export default Component.extend({
let suggestion = selection.find(option => option.__isSuggestion__);
if (suggestion) {
this.get('oncreate')(suggestion.__value__, select);
this.oncreate(suggestion.__value__, select);
} else {
this.get('onchange')(selection, select);
this.onchange(selection, select);
}
// clear select search
@ -164,8 +164,8 @@ export default Component.extend({
filter(options, searchText) {
let matcher;
if (this.get('searchField')) {
matcher = (option, text) => this.matcher(get(option, this.get('searchField')), text);
if (this.searchField) {
matcher = (option, text) => this.matcher(get(option, this.searchField), text);
} else {
matcher = (option, text) => this.matcher(option, text);
}
@ -181,7 +181,7 @@ export default Component.extend({
},
buildSuggestionLabel(term) {
let buildSuggestion = this.get('buildSuggestion');
let buildSuggestion = this.buildSuggestion;
if (buildSuggestion) {
return buildSuggestion(term);
}

View File

@ -13,11 +13,11 @@ export default DraggableObject.extend({
internal: readOnly('content.isInternal'),
primary: computed('idx', 'internal', function () {
return !this.get('internal') && this.get('idx') === 0;
return !this.internal && this.idx === 0;
}),
title: computed('internal', function () {
if (this.get('internal')) {
if (this.internal) {
return `Internal tag`;
}
})

View File

@ -7,7 +7,7 @@ export default EmberPowerSelectMultipleTrigger.extend({
actions: {
chooseOption(option) {
this.get('select').actions.choose(option);
this.select.actions.choose(option);
},
handleOptionMouseDown(event) {
@ -31,13 +31,13 @@ export default EmberPowerSelectMultipleTrigger.extend({
// update EPS' selected value directly. We have to create a copy
// after sorting in order to force the onchange action to be triggered
let selectedCopy = this.select.selected.slice();
this.get('select').actions.select(selectedCopy);
this.select.actions.select(selectedCopy);
},
// copied directly from EPS, the default behaviour of stopping propagation
// of keydown events prevents our shortcuts from being triggered
onKeydown(e) {
let {onKeydown, select} = this.getProperties('onKeydown', 'select');
let {onKeydown, select} = this;
if (onKeydown && onKeydown(e) === false) {
e.stopPropagation();
return false;
@ -47,11 +47,11 @@ export default EmberPowerSelectMultipleTrigger.extend({
if (isBlank(e.target.value)) {
let lastSelection = select.selected[select.selected.length - 1];
if (lastSelection) {
select.actions.select(this.get('buildSelection')(lastSelection, select), e);
select.actions.select(this.buildSelection(lastSelection, select), e);
if (typeof lastSelection === 'string') {
select.actions.search(lastSelection);
} else {
let searchField = this.get('searchField');
let searchField = this.searchField;
assert('`{{power-select-multiple}}` requires a `searchField` when the options are not strings to remove options using backspace', searchField);
select.actions.search(get(lastSelection, searchField));
}

View File

@ -89,8 +89,8 @@ const GhTourItemComponent = Component.extend({
isMobile: reads('mediaQueries.isMobile'),
isVisible: computed('isMobile', '_throbber', function () {
let isMobile = this.get('isMobile');
let hasThrobber = !isBlank(this.get('_throbber'));
let isMobile = this.isMobile;
let hasThrobber = !isBlank(this._throbber);
return !isMobile && hasThrobber;
}),
@ -105,14 +105,14 @@ const GhTourItemComponent = Component.extend({
this._handleOptOut = run.bind(this, this._remove);
this._handleViewed = run.bind(this, this._removeIfViewed);
this.get('tour').on('optOut', this._handleOptOut);
this.get('tour').on('viewed', this._handleViewed);
this.tour.on('optOut', this._handleOptOut);
this.tour.on('viewed', this._handleViewed);
},
didReceiveAttrs() {
let throbberId = this.get('throbberId');
let throbber = this.get('tour').activeThrobber(throbberId);
let triangleClass = this.get('popoverTriangleClass');
let throbberId = this.throbberId;
let throbber = this.tour.activeThrobber(throbberId);
let triangleClass = this.popoverTriangleClass;
let popoverPositions = triangleClassPositions[triangleClass];
this._throbber = throbber;
@ -122,8 +122,8 @@ const GhTourItemComponent = Component.extend({
},
willDestroyElement() {
this.get('tour').off('optOut', this._handleOptOut);
this.get('tour').off('viewed', this._handleViewed);
this.tour.off('optOut', this._handleOptOut);
this.tour.off('viewed', this._handleViewed);
this._super(...arguments);
},
@ -137,21 +137,21 @@ const GhTourItemComponent = Component.extend({
},
markAsViewed() {
let throbberId = this.get('throbberId');
this.get('tour').markThrobberAsViewed(throbberId);
let throbberId = this.throbberId;
this.tour.markThrobberAsViewed(throbberId);
this.set('_throbber', null);
this._close();
},
optOut() {
this.get('tour').optOut();
this.tour.optOut();
this.set('_throbber', null);
this._close();
}
},
_removeIfViewed(id) {
if (id === this.get('throbberId')) {
if (id === this.throbberId) {
this._remove();
}
},

View File

@ -23,7 +23,7 @@ const TrimFocusInputComponent = GhostTextInput.extend({
this.element.value = value;
this._elementValueDidChange(event);
let inputMethod = this.get('input');
let inputMethod = this.input;
if (inputMethod) {
inputMethod(event);
}

View File

@ -26,7 +26,7 @@ export default Component.extend({
containerStyle: computed('photo.color', 'zoomed', function () {
let styles = [];
let ratio = this.get('photo.ratio');
let zoomed = this.get('zoomed');
let zoomed = this.zoomed;
styles.push(`background-color: ${this.get('photo.color')}`);
@ -81,7 +81,7 @@ export default Component.extend({
select(event) {
event.preventDefault();
event.stopPropagation();
this.select(this.get('photo'));
this.select(this.photo);
},
zoom(event) {
@ -90,7 +90,7 @@ export default Component.extend({
// only zoom when it wasn't one of the child links clicked
if (!$target.is('a') && $target.closest('a').hasClass('gh-unsplash-photo')) {
event.preventDefault();
this.zoom(this.get('photo'));
this.zoom(this.photo);
}
// don't propagate otherwise we can trigger the closeZoom action on the overlay

View File

@ -45,12 +45,12 @@ export default Component.extend(ShortcutsMixin, {
didInsertElement() {
this._super(...arguments);
this._resizeCallback = bind(this, this._handleResize);
this.get('resizeDetector').setup('[data-unsplash]', this._resizeCallback);
this.resizeDetector.setup('[data-unsplash]', this._resizeCallback);
this.registerShortcuts();
},
willDestroyElement() {
this.get('resizeDetector').teardown('[data-unsplash]', this._resizeCallback);
this.resizeDetector.teardown('[data-unsplash]', this._resizeCallback);
this.removeShortcuts();
this.send('resetKeyScope');
this._super(...arguments);
@ -58,7 +58,7 @@ export default Component.extend(ShortcutsMixin, {
actions: {
loadNextPage() {
this.get('unsplash').loadNextPage();
this.unsplash.loadNextPage();
},
search(term) {
@ -75,7 +75,7 @@ export default Component.extend(ShortcutsMixin, {
},
select(photo) {
this.get('unsplash').triggerDownload(photo);
this.unsplash.triggerDownload(photo);
let selectParams = {
src: photo.urls.regular,
@ -92,7 +92,7 @@ export default Component.extend(ShortcutsMixin, {
},
retry() {
this.get('unsplash').retryLastRequest();
this.unsplash.retryLastRequest();
},
setKeyScope() {
@ -104,7 +104,7 @@ export default Component.extend(ShortcutsMixin, {
},
handleEscape() {
if (this.get('zoomedPhoto')) {
if (this.zoomedPhoto) {
return this.send('closeZoom');
}
@ -122,6 +122,6 @@ export default Component.extend(ShortcutsMixin, {
columns = 2;
}
this.get('unsplash').changeColumnCount(columns);
this.unsplash.changeColumnCount(columns);
}
});

View File

@ -95,12 +95,12 @@ export default Component.extend({
this._super(...arguments);
// set up any defaults
if (!this.get('uploadUrl')) {
if (!this.uploadUrl) {
this.set('uploadUrl', this._defaultUploadUrl);
}
// if we have new files, validate and start an upload
let files = this.get('files');
let files = this.files;
this._setFiles(files);
},
@ -132,14 +132,14 @@ export default Component.extend({
// we cancel early if any file fails client-side validation
if (this._validate()) {
this.get('_uploadFiles').perform(files);
this._uploadFiles.perform(files);
}
}
},
_validate() {
let files = this.get('files');
let validate = this.get('validate') || this._defaultValidator.bind(this);
let files = this.files;
let validate = this.validate || this._defaultValidator.bind(this);
let ok = [];
let errors = [];
@ -167,7 +167,7 @@ export default Component.extend({
// we only check the file extension by default because IE doesn't always
// expose the mime-type, we'll rely on the API for final validation
_defaultValidator(file) {
let extensions = this.get('extensions');
let extensions = this.extensions;
let [, extension] = (/(?:\.([^.]+))?$/).exec(file.name);
// if extensions is falsy exit early and accept all files
@ -199,25 +199,25 @@ export default Component.extend({
let file = files[i];
let tracker = new UploadTracker({file});
this.get('_uploadTrackers').pushObject(tracker);
uploads.push(this.get('_uploadFile').perform(tracker, file, i));
this._uploadTrackers.pushObject(tracker);
uploads.push(this._uploadFile.perform(tracker, file, i));
}
// populates this.errors and this.uploadUrls
yield all(uploads);
if (!isEmpty(this.get('errors'))) {
this.onFailed(this.get('errors'));
if (!isEmpty(this.errors)) {
this.onFailed(this.errors);
}
this.onComplete(this.get('uploadUrls'));
this.onComplete(this.uploadUrls);
}).drop(),
// eslint-disable-next-line ghost/ember/order-in-components
_uploadFile: task(function* (tracker, file, index) {
let ajax = this.get('ajax');
let ajax = this.ajax;
let formData = this._getFormData(file);
let url = `${ghostPaths().apiRoot}${this.get('uploadUrl')}`;
let url = `${ghostPaths().apiRoot}${this.uploadUrl}`;
try {
this.onUploadStart(file);
@ -269,7 +269,7 @@ export default Component.extend({
fileName: file.name
};
this.get('uploadUrls')[index] = result;
this.uploadUrls[index] = result;
this.onUploadSuccess(result);
return true;
@ -288,7 +288,7 @@ export default Component.extend({
};
// TODO: check for or expose known error types?
this.get('errors').pushObject(result);
this.errors.pushObject(result);
this.onUploadFailure(result);
}
}).maxConcurrency(MAX_SIMULTANEOUS_UPLOADS).enqueue(),
@ -296,7 +296,7 @@ export default Component.extend({
// NOTE: this is necessary because the API doesn't accept direct file uploads
_getFormData(file) {
let formData = new FormData();
formData.append(this.get('paramName'), file, file.name);
formData.append(this.paramName, file, file.name);
Object.keys(this.paramsHash || {}).forEach((key) => {
formData.append(key, this.paramsHash[key]);

View File

@ -20,8 +20,8 @@ export default Component.extend({
let noSchemeBlogUrl = blogUrl.substr(blogUrl.indexOf('://') + 3);
// Get the prefix and slug values
let prefix = this.get('prefix') ? `${this.get('prefix')}/` : '';
let slug = this.get('slug') ? `${this.get('slug')}/` : '';
let prefix = this.prefix ? `${this.prefix}/` : '';
let slug = this.slug ? `${this.slug}/` : '';
// Join parts of the URL together with slashes
let theUrl = `${noSchemeBlogUrl}/${prefix}${slug}`;

View File

@ -34,8 +34,8 @@ export default Component.extend({
actions: {
resend() {
let invite = this.get('invite');
let notifications = this.get('notifications');
let invite = this.invite;
let notifications = this.notifications;
this.set('isSending', true);
invite.resend().then((result) => {
@ -44,7 +44,7 @@ export default Component.extend({
// the server deletes the old record and creates a new one when
// resending so we need to update the store accordingly
invite.unloadRecord();
this.get('store').pushPayload('invite', result);
this.store.pushPayload('invite', result);
// If sending the invitation email fails, the API will still return a status of 201
// but the invite's status in the response object will be 'invited-pending'.
@ -61,9 +61,9 @@ export default Component.extend({
},
revoke() {
let invite = this.get('invite');
let invite = this.invite;
let email = invite.get('email');
let notifications = this.get('notifications');
let notifications = this.notifications;
// reload the invite to get the most up-to-date information
invite.reload().then(() => {
@ -76,7 +76,7 @@ export default Component.extend({
}).catch((error) => {
if (isNotFoundError(error)) {
// if the invite no longer exists, then show a warning and reload the route
let action = this.get('reload');
let action = this.reload;
if (action) {
action();
}

View File

@ -13,11 +13,11 @@ export default Component.extend(ValidationStateMixin, {
classNameBindings: ['errorClass'],
errorClass: computed('property', 'hasError', 'hasValidated.[]', function () {
let hasValidated = this.get('hasValidated');
let property = this.get('property');
let hasValidated = this.hasValidated;
let property = this.property;
if (hasValidated && hasValidated.includes(property)) {
return this.get('hasError') ? 'error' : 'success';
return this.hasError ? 'error' : 'success';
} else {
return '';
}

View File

@ -11,26 +11,26 @@ export default ModalComponent.extend({
actions: {
confirm() {
this.get('deleteAll').perform();
this.deleteAll.perform();
}
},
_deleteAll() {
let deleteUrl = this.get('ghostPaths.url').api('db');
return this.get('ajax').del(deleteUrl);
return this.ajax.del(deleteUrl);
},
_unloadData() {
this.get('store').unloadAll('post');
this.get('store').unloadAll('tag');
this.store.unloadAll('post');
this.store.unloadAll('tag');
},
_showSuccess() {
this.get('notifications').showAlert('All content deleted from database.', {type: 'success', key: 'all-content.delete.success'});
this.notifications.showAlert('All content deleted from database.', {type: 'success', key: 'all-content.delete.success'});
},
_showFailure(error) {
this.get('notifications').showAPIError(error, {key: 'all-content.delete'});
this.notifications.showAPIError(error, {key: 'all-content.delete'});
},
deleteAll: task(function* () {

View File

@ -11,12 +11,12 @@ export default ModalComponent.extend({
actions: {
confirm() {
this.get('deletePost').perform();
this.deletePost.perform();
}
},
_deletePost() {
let post = this.get('post');
let post = this.post;
// definitely want to clear the data store and post of any unsaved,
// client-generated tags
@ -27,16 +27,16 @@ export default ModalComponent.extend({
_success() {
// clear any previous error messages
this.get('notifications').closeAlerts('post.delete');
this.notifications.closeAlerts('post.delete');
// trigger the success action
if (this.get('onSuccess')) {
this.get('onSuccess')();
if (this.onSuccess) {
this.onSuccess();
}
},
_failure(error) {
this.get('notifications').showAPIError(error, {key: 'post.delete.failed'});
this.notifications.showAPIError(error, {key: 'post.delete.failed'});
},
deletePost: task(function* () {

View File

@ -10,7 +10,7 @@ export default ModalComponent.extend({
actions: {
confirm() {
this.get('deleteSubscriber').perform();
this.deleteSubscriber.perform();
}
},

View File

@ -15,7 +15,7 @@ export default ModalComponent.extend({
actions: {
confirm() {
this.get('deleteTag').perform();
this.deleteTag.perform();
}
},

View File

@ -11,7 +11,7 @@ export default ModalComponent.extend({
actions: {
confirm() {
this.get('deleteTheme').perform();
this.deleteTheme.perform();
}
},

View File

@ -10,7 +10,7 @@ export default ModalComponent.extend({
actions: {
confirm() {
this.get('deleteUser').perform();
this.deleteUser.perform();
}
},

View File

@ -35,7 +35,7 @@ export default ModalComponent.extend({
},
closeModal() {
if (!this.get('closeDisabled')) {
if (!this.closeDisabled) {
this._super(...arguments);
}
}

View File

@ -32,7 +32,7 @@ export default ModalComponent.extend(ValidationEngine, {
this._super(...arguments);
// TODO: this should not be needed, ValidationEngine acts as a
// singleton and so it's errors and hasValidated state stick around
this.get('errors').clear();
this.errors.clear();
this.set('hasValidated', emberA());
},
@ -43,33 +43,33 @@ export default ModalComponent.extend(ValidationEngine, {
},
confirm() {
this.get('sendInvitation').perform();
this.sendInvitation.perform();
}
},
validate() {
let email = this.get('email');
let email = this.email;
// TODO: either the validator should check the email's existence or
// the API should return an appropriate error when attempting to save
return new Promise((resolve, reject) => this._super().then(() => RSVP.hash({
users: this.get('store').findAll('user', {reload: true}),
invites: this.get('store').findAll('invite', {reload: true})
users: this.store.findAll('user', {reload: true}),
invites: this.store.findAll('invite', {reload: true})
}).then((data) => {
let existingUser = data.users.findBy('email', email);
let existingInvite = data.invites.findBy('email', email);
if (existingUser || existingInvite) {
this.get('errors').clear('email');
this.errors.clear('email');
if (existingUser) {
this.get('errors').add('email', 'A user with that email address already exists.');
this.errors.add('email', 'A user with that email address already exists.');
} else {
this.get('errors').add('email', 'A user with that email address was already invited.');
this.errors.add('email', 'A user with that email address was already invited.');
}
// TODO: this shouldn't be needed, ValidationEngine doesn't mark
// properties as validated when validating an entire object
this.get('hasValidated').addObject('email');
this.hasValidated.addObject('email');
reject();
} else {
resolve();
@ -77,34 +77,34 @@ export default ModalComponent.extend(ValidationEngine, {
}), () => {
// TODO: this shouldn't be needed, ValidationEngine doesn't mark
// properties as validated when validating an entire object
this.get('hasValidated').addObject('email');
this.hasValidated.addObject('email');
reject();
}));
},
fetchRoles: task(function * () {
let roles = yield this.get('store').query('role', {permissions: 'assign'});
let roles = yield this.store.query('role', {permissions: 'assign'});
let authorRole = roles.findBy('name', 'Author');
this.set('roles', roles);
this.set('authorRole', authorRole);
if (!this.get('role')) {
if (!this.role) {
this.set('role', authorRole);
}
}),
sendInvitation: task(function* () {
let email = this.get('email');
let role = this.get('role');
let notifications = this.get('notifications');
let email = this.email;
let role = this.role;
let notifications = this.notifications;
let notificationText = `Invitation sent! (${email})`;
let invite;
try {
yield this.validate();
invite = this.get('store').createRecord('invite', {
invite = this.store.createRecord('invite', {
email,
role
});

View File

@ -16,13 +16,13 @@ export default ModalComponent.extend({
},
confirm() {
this.get('addSubscriber').perform();
this.addSubscriber.perform();
}
},
addSubscriber: task(function* () {
try {
yield this.get('confirm')();
yield this.confirm();
this.send('closeModal');
} catch (error) {
// TODO: server-side validation errors should be serialized

View File

@ -22,15 +22,15 @@ export default ModalComponent.extend(ValidationEngine, {
actions: {
confirm() {
this.get('reauthenticate').perform();
this.reauthenticate.perform();
}
},
_authenticate() {
let session = this.get('session');
let session = this.session;
let authStrategy = 'authenticator:cookie';
let identification = this.get('identification');
let password = this.get('password');
let identification = this.identification;
let password = this.password;
session.set('skipAuthSuccessHandler', true);
@ -50,24 +50,24 @@ export default ModalComponent.extend(ValidationEngine, {
this.set('authenticationError', null);
return this.validate({property: 'signin'}).then(() => this._authenticate().then(() => {
this.get('notifications').closeAlerts();
this.notifications.closeAlerts();
this.send('closeModal');
return true;
}).catch((error) => {
if (error && error.payload && error.payload.errors) {
error.payload.errors.forEach((err) => {
if (isVersionMismatchError(err)) {
return this.get('notifications').showAPIError(error);
return this.notifications.showAPIError(error);
}
err.message = htmlSafe(err.context || err.message);
});
this.get('errors').add('password', 'Incorrect password');
this.get('hasValidated').pushObject('password');
this.errors.add('password', 'Incorrect password');
this.hasValidated.pushObject('password');
this.set('authenticationError', error.payload.errors[0].message);
}
}), () => {
this.get('hasValidated').pushObject('password');
this.hasValidated.pushObject('password');
return false;
});
},

View File

@ -10,7 +10,7 @@ export default ModalComponent.extend({
actions: {
confirm() {
return this.get('suspendUser').perform();
return this.suspendUser.perform();
}
},

View File

@ -9,7 +9,7 @@ export default ModalComponent.extend({
actions: {
confirm() {
this.get('transferOwnership').perform();
this.transferOwnership.perform();
}
},

View File

@ -10,7 +10,7 @@ export default ModalComponent.extend({
actions: {
confirm() {
return this.get('unsuspendUser').perform();
return this.unsuspendUser.perform();
}
},

View File

@ -31,7 +31,7 @@ export default ModalComponent.extend({
}),
didReceiveAttrs() {
let image = this.get('image');
let image = this.image;
this.set('url', image);
this.set('newUrl', image);
},
@ -48,7 +48,7 @@ export default ModalComponent.extend({
},
confirm() {
this.get('uploadImage').perform();
this.uploadImage.perform();
},
isUploading() {
@ -88,9 +88,9 @@ export default ModalComponent.extend({
uploadImage: task(function* () {
let model = this.get('model.model');
let newUrl = this.get('newUrl');
let newUrl = this.newUrl;
let result = this._validateUrl(newUrl);
let notifications = this.get('notifications');
let notifications = this.notifications;
if (result === true) {
this.set('image', newUrl);

View File

@ -42,12 +42,12 @@ export default ModalComponent.extend({
}),
fileThemeName: computed('file', function () {
let file = this.get('file');
let file = this.file;
return file.name.replace(/\.zip$/, '');
}),
canActivateTheme: computed('theme', function () {
let theme = this.get('theme');
let theme = this.theme;
return theme && !theme.get('active');
}),
@ -62,12 +62,12 @@ export default ModalComponent.extend({
validateTheme(file) {
let themeName = file.name.replace(/\.zip$/, '').replace(/[^\w@.]/gi, '-').toLowerCase();
let currentThemeNames = this.get('currentThemeNames');
let currentThemeNames = this.currentThemeNames;
this.set('file', file);
let [, extension] = (/(?:\.([^.]+))?$/).exec(file.name);
let extensions = this.get('extensions');
let extensions = this.extensions;
if (!extension || extensions.indexOf(extension.toLowerCase()) === -1) {
return new UnsupportedMediaTypeError();
@ -92,7 +92,7 @@ export default ModalComponent.extend({
// we need to schedule afterRender so that the upload component is
// displayed again in order to subscribe/respond to the event bus
run.schedule('afterRender', this, function () {
this.get('eventBus').publish('themeUploader:upload', this.get('file'));
this.eventBus.publish('themeUploader:upload', this.file);
});
},
@ -105,9 +105,9 @@ export default ModalComponent.extend({
},
uploadSuccess(response) {
this.get('store').pushPayload(response);
this.store.pushPayload(response);
let theme = this.get('store').peekRecord('theme', response.themes[0].name);
let theme = this.store.peekRecord('theme', response.themes[0].name);
this.set('theme', theme);
@ -155,12 +155,12 @@ export default ModalComponent.extend({
},
activate() {
this.get('model.activate')(this.get('theme'));
this.get('model.activate')(this.theme);
this.closeModal();
},
closeModal() {
if (!this.get('closeDisabled')) {
if (!this.closeDisabled) {
this._super(...arguments);
}
},

View File

@ -21,7 +21,7 @@ export default Controller.extend({
return false;
}
return (this.get('currentPath') !== 'error404' || this.get('session.isAuthenticated'))
&& !this.get('currentPath').match(/(signin|signup|setup|reset)/);
return (this.currentPath !== 'error404' || this.get('session.isAuthenticated'))
&& !this.currentPath.match(/(signin|signup|setup|reset)/);
})
});

View File

@ -152,9 +152,9 @@ export default Controller.extend({
this.set('post.scratch', mobiledoc);
// save 3 seconds after last edit
this.get('_autosave').perform();
this._autosave.perform();
// force save at 60 seconds
this.get('_timedSave').perform();
this._timedSave.perform();
},
updateTitleScratch(title) {
this.set('post.titleScratch', title);
@ -176,22 +176,22 @@ export default Controller.extend({
},
save(options) {
return this.get('save').perform(options);
return this.save.perform(options);
},
// used to prevent unexpected background saves. Triggered when opening
// publish menu, starting a manual save, and when leaving the editor
cancelAutosave() {
this.get('_autosave').cancelAll();
this.get('_timedSave').cancelAll();
this._autosave.cancelAll();
this._timedSave.cancelAll();
},
toggleLeaveEditorModal(transition) {
let leaveTransition = this.get('leaveEditorTransition');
let leaveTransition = this.leaveEditorTransition;
// "cancel" was clicked in the "are you sure?" modal so we just
// reset the saved transition and remove the modal
if (!transition && this.get('showLeaveEditorModal')) {
if (!transition && this.showLeaveEditorModal) {
this.set('leaveEditorTransition', null);
this.set('showLeaveEditorModal', false);
return;
@ -208,11 +208,11 @@ export default Controller.extend({
}
// if an autosave is scheduled, cancel it, save then transition
if (this.get('_autosaveRunning')) {
if (this._autosaveRunning) {
this.send('cancelAutosave');
this.get('autosave').cancelAll();
this.autosave.cancelAll();
return this.get('autosave').perform().then(() => {
return this.autosave.perform().then(() => {
transition.retry();
});
}
@ -224,10 +224,10 @@ export default Controller.extend({
// called by the "are you sure?" modal
leaveEditor() {
let transition = this.get('leaveEditorTransition');
let transition = this.leaveEditorTransition;
if (!transition) {
this.get('notifications').showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
this.notifications.showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
return;
}
@ -269,7 +269,7 @@ export default Controller.extend({
// separate task for autosave so that it doesn't override a manual save
autosave: task(function* () {
if (!this.get('save.isRunning')) {
return yield this.get('save').perform({
return yield this.save.perform({
silent: true,
backgroundSave: true
});
@ -285,7 +285,7 @@ export default Controller.extend({
this.send('cancelAutosave');
if (options.backgroundSave && !this.get('hasDirtyAttributes')) {
if (options.backgroundSave && !this.hasDirtyAttributes) {
return;
}
@ -294,11 +294,11 @@ export default Controller.extend({
status = 'draft';
} else {
if (this.get('post.pastScheduledTime')) {
status = (!this.get('willSchedule') && !this.get('willPublish')) ? 'draft' : 'published';
status = (!this.willSchedule && !this.willPublish) ? 'draft' : 'published';
} else {
if (this.get('willPublish') && !this.get('post.isScheduled')) {
if (this.willPublish && !this.get('post.isScheduled')) {
status = 'published';
} else if (this.get('willSchedule') && !this.get('post.isPublished')) {
} else if (this.willSchedule && !this.get('post.isPublished')) {
status = 'scheduled';
} else {
status = 'draft';
@ -338,23 +338,23 @@ export default Controller.extend({
this.set('post.twitterDescription', this.get('post.twitterDescriptionScratch'));
if (!this.get('post.slug')) {
this.get('saveTitle').cancelAll();
this.saveTitle.cancelAll();
yield this.get('generateSlug').perform();
yield this.generateSlug.perform();
}
try {
let post = yield this.get('post').save(options);
let post = yield this.post.save(options);
if (!options.silent) {
this._showSaveNotification(prevStatus, post.get('status'), isNew ? true : false);
}
this.get('post').set('statusScratch', null);
this.post.set('statusScratch', null);
// redirect to edit route if saving a new record
if (isNew && post.get('id')) {
if (!this.get('leaveEditorTransition')) {
if (!this.leaveEditorTransition) {
this.replaceRoute('editor.edit', post);
}
return true;
@ -377,7 +377,7 @@ export default Controller.extend({
throw undefined;
}
return this.get('post');
return this.post;
}
}).group('saveTasks'),
@ -398,7 +398,7 @@ export default Controller.extend({
return;
}
serverSlug = yield this.get('slugGenerator').generateSlug('post', newSlug);
serverSlug = yield this.slugGenerator.generateSlug('post', newSlug);
// 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
@ -434,14 +434,14 @@ export default Controller.extend({
return;
}
return yield this.get('post').save();
return yield this.post.save();
}).group('saveTasks'),
// used in the PSM so that saves are sequential and don't trigger collision
// detection errors
savePost: task(function* () {
try {
return yield this.get('post').save();
return yield this.post.save();
} catch (error) {
if (error) {
let status = this.get('post.status');
@ -453,7 +453,7 @@ export default Controller.extend({
}).group('saveTasks'),
saveTitle: task(function* () {
let post = this.get('post');
let post = this.post;
let currentTitle = post.get('title');
let newTitle = post.get('titleScratch').trim();
@ -467,11 +467,11 @@ export default Controller.extend({
// generate a slug if a post is new and doesn't have a title yet or
// if the title is still '(Untitled)'
if ((post.get('isNew') && !currentTitle) || currentTitle === DEFAULT_TITLE) {
yield this.get('generateSlug').perform();
yield this.generateSlug.perform();
}
if (this.get('post.isDraft')) {
yield this.get('autosave').perform();
yield this.autosave.perform();
}
this.send('updateDocumentTitle');
@ -486,7 +486,7 @@ export default Controller.extend({
}
try {
let slug = yield this.get('slugGenerator').generateSlug('post', title);
let slug = yield this.slugGenerator.generateSlug('post', title);
if (!isBlank(slug)) {
this.set('post.slug', slug);
@ -496,7 +496,7 @@ export default Controller.extend({
// but a rejected promise needs to be handled here so that a resolved
// promise is returned.
if (isVersionMismatchError(error)) {
this.get('notifications').showAPIError(error);
this.notifications.showAPIError(error);
}
}
}).enqueue(),
@ -506,7 +506,7 @@ export default Controller.extend({
// called by the new/edit routes to change the post model
setPost(post) {
// don't do anything else if we're setting the same post
if (post === this.get('post')) {
if (post === this.post) {
// set autofocus as change signal to the persistent editor on new->edit
this.set('shouldFocusEditor', post.get('isNew'));
return;
@ -526,13 +526,13 @@ export default Controller.extend({
post.set('titleScratch', post.get('title'));
post.set('scratch', post.get('mobiledoc'));
this._previousTagNames = this.get('_tagNames');
this._previousTagNames = this._tagNames;
this._attachModelHooks();
// triggered any time the admin tab is closed, we need to use a native
// dialog here instead of our custom modal
window.onbeforeunload = () => {
if (this.get('hasDirtyAttributes')) {
if (this.hasDirtyAttributes) {
return '==============================\n\n'
+ 'Hey there! It looks like you\'re in the middle of writing'
+ ' something and you haven\'t saved all of your content.'
@ -547,7 +547,7 @@ export default Controller.extend({
// which will either finish autosave then retry transition or abort and show
// the "are you sure?" modal
willTransition(transition) {
let post = this.get('post');
let post = this.post;
// exit early and allow transition if we have no post, occurs if reset
// has already been called as in the `leaveEditor` action
@ -563,7 +563,7 @@ export default Controller.extend({
this._koenig.cleanup();
}
let hasDirtyAttributes = this.get('hasDirtyAttributes');
let hasDirtyAttributes = this.hasDirtyAttributes;
let state = post.getProperties('isDeleted', 'isSaving', 'hasDirtyAttributes', 'isNew');
let fromNewToEdit = this.get('router.currentRouteName') === 'editor.new'
@ -593,7 +593,7 @@ export default Controller.extend({
// called when the editor route is left or the post model is swapped
reset() {
let post = this.get('post');
let post = this.post;
// make sure the save tasks aren't still running in the background
// after leaving the edit route
@ -632,35 +632,35 @@ export default Controller.extend({
// save 3 seconds after the last edit
_autosave: task(function* () {
if (!this.get('_canAutosave')) {
if (!this._canAutosave) {
return;
}
// force an instant save on first body edit for new posts
if (this.get('post.isNew')) {
return this.get('autosave').perform();
return this.autosave.perform();
}
yield timeout(AUTOSAVE_TIMEOUT);
this.get('autosave').perform();
this.autosave.perform();
}).restartable(),
// save at 60 seconds even if the user doesn't stop typing
_timedSave: task(function* () {
if (!this.get('_canAutosave')) {
if (!this._canAutosave) {
return;
}
while (config.environment !== 'test' && true) {
yield timeout(TIMEDSAVE_TIMEOUT);
this.get('autosave').perform();
this.autosave.perform();
}
}).drop(),
/* Private methods -------------------------------------------------------*/
_hasDirtyAttributes() {
let post = this.get('post');
let post = this.post;
if (!post) {
return false;
@ -681,7 +681,7 @@ export default Controller.extend({
}
// titleScratch isn't an attr so needs a manual dirty check
if (this.get('titleScratch') !== this.get('title')) {
if (this.titleScratch !== this.title) {
return true;
}
@ -714,7 +714,7 @@ export default Controller.extend({
// add a .then in every instance we use model hooks to update our local
// values used for `hasDirtyAttributes`
_attachModelHooks() {
let post = this.get('post');
let post = this.post;
if (post) {
post.on('didCreate', this, this._postSaved);
post.on('didUpdate', this, this._postSaved);
@ -722,7 +722,7 @@ export default Controller.extend({
},
_detachModelHooks() {
let post = this.get('post');
let post = this.post;
if (post) {
post.off('didCreate', this, this._postSaved);
post.off('didUpdate', this, this._postSaved);
@ -730,14 +730,14 @@ export default Controller.extend({
},
_postSaved() {
let post = this.get('post');
let post = this.post;
// remove any unsaved tags
// NOTE: `updateTags` changes `hasDirtyAttributes => true`.
// For a saved post it would otherwise be false.
post.updateTags();
this._previousTagNames = this.get('_tagNames');
this._previousTagNames = this._tagNames;
// if the two "scratch" properties (title and content) match the post,
// then it's ok to set hasDirtyAttributes to false
@ -752,7 +752,7 @@ export default Controller.extend({
_showSaveNotification(prevStatus, status, delay) {
let message = messageMap.success.post[prevStatus][status];
let notifications = this.get('notifications');
let notifications = this.notifications;
let type, path;
if (status === 'published') {
@ -770,7 +770,7 @@ export default Controller.extend({
_showErrorAlert(prevStatus, status, error, delay) {
let message = messageMap.errors.post[prevStatus][status];
let notifications = this.get('notifications');
let notifications = this.notifications;
let errorMessage;
function isString(str) {

View File

@ -12,7 +12,7 @@ export default Controller.extend({
}),
message: computed('error.statusText', function () {
if (this.get('code') === 404) {
if (this.code === 404) {
return 'Page not found';
}

View File

@ -22,12 +22,12 @@ export default Controller.extend(ValidationEngine, {
email: computed('token', function () {
// The token base64 encodes the email (and some other stuff),
// each section is divided by a '|'. Email comes second.
return atob(this.get('token')).split('|')[1];
return atob(this.token).split('|')[1];
}),
actions: {
submit() {
return this.get('resetPassword').perform();
return this.resetPassword.perform();
}
},
@ -45,21 +45,21 @@ export default Controller.extend(ValidationEngine, {
let authUrl = this.get('ghostPaths.url').api('authentication', 'passwordreset');
this.set('flowErrors', '');
this.get('hasValidated').addObjects(['newPassword', 'ne2Password']);
this.hasValidated.addObjects(['newPassword', 'ne2Password']);
try {
yield this.validate();
try {
let resp = yield this.get('ajax').put(authUrl, {
let resp = yield this.ajax.put(authUrl, {
data: {
passwordreset: [credentials]
}
});
this.get('notifications').showAlert(resp.passwordreset[0].message, {type: 'warn', delayed: true, key: 'password.reset'});
this.get('session').authenticate('authenticator:cookie', this.get('email'), credentials.newPassword);
this.notifications.showAlert(resp.passwordreset[0].message, {type: 'warn', delayed: true, key: 'password.reset'});
this.session.authenticate('authenticator:cookie', this.email, credentials.newPassword);
return true;
} catch (error) {
this.get('notifications').showAPIError(error, {key: 'password.reset'});
this.notifications.showAPIError(error, {key: 'password.reset'});
}
} catch (error) {
if (this.get('errors.newPassword')) {

View File

@ -9,13 +9,13 @@ export default Controller.extend({
actions: {
save() {
this.get('save').perform();
this.save.perform();
},
toggleLeaveSettingsModal(transition) {
let leaveTransition = this.get('leaveSettingsTransition');
let leaveTransition = this.leaveSettingsTransition;
if (!transition && this.get('showLeaveSettingsModal')) {
if (!transition && this.showLeaveSettingsModal) {
this.set('leaveSettingsTransition', null);
this.set('showLeaveSettingsModal', false);
return;
@ -37,11 +37,11 @@ export default Controller.extend({
},
leaveSettings() {
let transition = this.get('leaveSettingsTransition');
let settings = this.get('settings');
let transition = this.leaveSettingsTransition;
let settings = this.settings;
if (!transition) {
this.get('notifications').showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
this.notifications.showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
return;
}
@ -54,10 +54,10 @@ export default Controller.extend({
},
save: task(function* () {
let notifications = this.get('notifications');
let notifications = this.notifications;
try {
return yield this.get('settings').save();
return yield this.settings.save();
} catch (error) {
notifications.showAPIError(error, {key: 'code-injection.save'});
throw error;

View File

@ -38,11 +38,11 @@ export default Controller.extend({
actions: {
save() {
this.get('save').perform();
this.save.perform();
},
addNavItem() {
let newNavItem = this.get('newNavItem');
let newNavItem = this.newNavItem;
// If the url sent through is blank (user never edited the url)
if (newNavItem.get('url') === '') {
@ -86,9 +86,9 @@ export default Controller.extend({
},
toggleLeaveSettingsModal(transition) {
let leaveTransition = this.get('leaveSettingsTransition');
let leaveTransition = this.leaveSettingsTransition;
if (!transition && this.get('showLeaveSettingsModal')) {
if (!transition && this.showLeaveSettingsModal) {
this.set('leaveSettingsTransition', null);
this.set('showLeaveSettingsModal', false);
return;
@ -110,11 +110,11 @@ export default Controller.extend({
},
leaveSettings() {
let transition = this.get('leaveSettingsTransition');
let settings = this.get('settings');
let transition = this.leaveSettingsTransition;
let settings = this.settings;
if (!transition) {
this.get('notifications').showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
this.notifications.showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
return;
}
@ -139,7 +139,7 @@ export default Controller.extend({
this.set('showThemeWarningsModal', true);
}
if (this.get('themeErrors') || this.get('themeWarnings')) {
if (this.themeErrors || this.themeWarnings) {
let message = `${themeName} activated successfully but some warnings/errors were detected.
You are still able to use and activate the theme. Here is your report...`;
this.set('message', message);
@ -210,8 +210,8 @@ export default Controller.extend({
save: task(function* () {
let navItems = this.get('settings.navigation');
let newNavItem = this.get('newNavItem');
let notifications = this.get('notifications');
let newNavItem = this.newNavItem;
let notifications = this.notifications;
let validationPromises = [];
if (!newNavItem.get('isBlank')) {
@ -225,7 +225,7 @@ export default Controller.extend({
try {
yield RSVP.all(validationPromises);
this.set('dirtyAttributes', false);
return yield this.get('settings').save();
return yield this.settings.save();
} catch (error) {
if (error) {
notifications.showAPIError(error);
@ -236,7 +236,7 @@ export default Controller.extend({
addNewNavItem() {
let navItems = this.get('settings.navigation');
let newNavItem = this.get('newNavItem');
let newNavItem = this.newNavItem;
newNavItem.set('isNew', false);
navItems.pushObject(newNavItem);
@ -246,7 +246,7 @@ export default Controller.extend({
},
_deleteTheme() {
let theme = this.get('store').peekRecord('theme', this.get('themeToDelete').name);
let theme = this.store.peekRecord('theme', this.themeToDelete.name);
if (!theme) {
return;
@ -258,7 +258,7 @@ export default Controller.extend({
// attempt to update the deleted record
theme.unloadRecord();
}).catch((error) => {
this.get('notifications').showAPIError(error);
this.notifications.showAPIError(error);
});
}
});

View File

@ -44,7 +44,7 @@ export default Controller.extend({
actions: {
save() {
this.get('save').perform();
this.save.perform();
},
setTimezone(timezone) {
@ -53,7 +53,7 @@ export default Controller.extend({
removeImage(image) {
// setting `null` here will error as the server treats it as "null"
this.get('settings').set(image, '');
this.settings.set(image, '');
},
/**
@ -79,12 +79,12 @@ export default Controller.extend({
*/
imageUploaded(property, results) {
if (results[0]) {
return this.get('settings').set(property, results[0].url);
return this.settings.set(property, results[0].url);
}
},
toggleIsPrivate(isPrivate) {
let settings = this.get('settings');
let settings = this.settings;
settings.set('isPrivate', isPrivate);
settings.get('errors').remove('password');
@ -102,9 +102,9 @@ export default Controller.extend({
},
toggleLeaveSettingsModal(transition) {
let leaveTransition = this.get('leaveSettingsTransition');
let leaveTransition = this.leaveSettingsTransition;
if (!transition && this.get('showLeaveSettingsModal')) {
if (!transition && this.showLeaveSettingsModal) {
this.set('leaveSettingsTransition', null);
this.set('showLeaveSettingsModal', false);
return;
@ -126,11 +126,11 @@ export default Controller.extend({
},
leaveSettings() {
let transition = this.get('leaveSettingsTransition');
let settings = this.get('settings');
let transition = this.leaveSettingsTransition;
let settings = this.settings;
if (!transition) {
this.get('notifications').showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
this.notifications.showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
return;
}
@ -141,7 +141,7 @@ export default Controller.extend({
},
validateFacebookUrl() {
let newUrl = this.get('_scratchFacebook');
let newUrl = this._scratchFacebook;
let oldUrl = this.get('settings.facebook');
let errMessage = '';
@ -197,7 +197,7 @@ export default Controller.extend({
},
validateTwitterUrl() {
let newUrl = this.get('_scratchTwitter');
let newUrl = this._scratchTwitter;
let oldUrl = this.get('settings.twitter');
let errMessage = '';
@ -253,23 +253,23 @@ export default Controller.extend({
},
_deleteTheme() {
let theme = this.get('store').peekRecord('theme', this.get('themeToDelete').name);
let theme = this.store.peekRecord('theme', this.themeToDelete.name);
if (!theme) {
return;
}
return theme.destroyRecord().catch((error) => {
this.get('notifications').showAPIError(error);
this.notifications.showAPIError(error);
});
},
save: task(function* () {
let notifications = this.get('notifications');
let config = this.get('config');
let notifications = this.notifications;
let config = this.config;
try {
let settings = yield this.get('settings').save();
let settings = yield this.settings.save();
config.set('blogTitle', settings.get('title'));
// this forces the document title to recompute after

View File

@ -18,13 +18,13 @@ export default Controller.extend({
},
save() {
this.get('save').perform();
this.save.perform();
},
toggleLeaveSettingsModal(transition) {
let leaveTransition = this.get('leaveSettingsTransition');
let leaveTransition = this.leaveSettingsTransition;
if (!transition && this.get('showLeaveSettingsModal')) {
if (!transition && this.showLeaveSettingsModal) {
this.set('leaveSettingsTransition', null);
this.set('showLeaveSettingsModal', false);
return;
@ -46,11 +46,11 @@ export default Controller.extend({
},
leaveSettings() {
let transition = this.get('leaveSettingsTransition');
let settings = this.get('settings');
let transition = this.leaveSettingsTransition;
let settings = this.settings;
if (!transition) {
this.get('notifications').showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
this.notifications.showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
return;
}
@ -62,15 +62,15 @@ export default Controller.extend({
},
save: task(function* () {
let amp = this.get('ampSettings');
let settings = this.get('settings');
let amp = this.ampSettings;
let settings = this.settings;
settings.set('amp', amp);
try {
return yield settings.save();
} catch (error) {
this.get('notifications').showAPIError(error);
this.notifications.showAPIError(error);
throw error;
}
}).drop()

View File

@ -25,7 +25,7 @@ export default Controller.extend({
actions: {
save() {
this.get('save').perform();
this.save.perform();
},
updateURL(value) {
@ -41,9 +41,9 @@ export default Controller.extend({
},
triggerDirtyState() {
let slack = this.get('slackSettings');
let slackArray = this.get('slackArray');
let settings = this.get('settings');
let slack = this.slackSettings;
let slackArray = this.slackArray;
let settings = this.settings;
// Hack to trigger the `isDirty` state on the settings model by setting a new Array
// for slack rather that replacing the existing one which would still point to the
@ -53,9 +53,9 @@ export default Controller.extend({
},
toggleLeaveSettingsModal(transition) {
let leaveTransition = this.get('leaveSettingsTransition');
let leaveTransition = this.leaveSettingsTransition;
if (!transition && this.get('showLeaveSettingsModal')) {
if (!transition && this.showLeaveSettingsModal) {
this.set('leaveSettingsTransition', null);
this.set('showLeaveSettingsModal', false);
return;
@ -77,12 +77,12 @@ export default Controller.extend({
},
leaveSettings() {
let transition = this.get('leaveSettingsTransition');
let settings = this.get('settings');
let slackArray = this.get('slackArray');
let transition = this.leaveSettingsTransition;
let settings = this.settings;
let slackArray = this.slackArray;
if (!transition) {
this.get('notifications').showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
this.notifications.showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
return;
}
@ -95,9 +95,9 @@ export default Controller.extend({
},
save: task(function* () {
let slack = this.get('slackSettings');
let settings = this.get('settings');
let slackArray = this.get('slackArray');
let slack = this.slackSettings;
let settings = this.settings;
let slackArray = this.slackArray;
try {
yield slack.validate();
@ -107,19 +107,19 @@ export default Controller.extend({
return yield settings.save();
} catch (error) {
if (error) {
this.get('notifications').showAPIError(error);
this.notifications.showAPIError(error);
throw error;
}
}
}).drop(),
sendTestNotification: task(function* () {
let notifications = this.get('notifications');
let notifications = this.notifications;
let slackApi = this.get('ghostPaths.url').api('slack', 'test');
try {
yield this.get('save').perform();
yield this.get('ajax').post(slackApi);
yield this.save.perform();
yield this.ajax.post(slackApi);
notifications.showNotification('Check your Slack channel for the test message!', {type: 'info', key: 'slack-test.send.success'});
return true;
} catch (error) {

View File

@ -16,11 +16,11 @@ export default Controller.extend({
actions: {
save() {
this.get('save').perform();
this.save.perform();
},
update(value) {
if (!this.get('dirtyAttributes')) {
if (!this.dirtyAttributes) {
this.set('rollbackValue', this.get('unsplashSettings.isActive'));
}
this.set('unsplashSettings.isActive', value);
@ -28,9 +28,9 @@ export default Controller.extend({
},
toggleLeaveSettingsModal(transition) {
let leaveTransition = this.get('leaveSettingsTransition');
let leaveTransition = this.leaveSettingsTransition;
if (!transition && this.get('showLeaveSettingsModal')) {
if (!transition && this.showLeaveSettingsModal) {
this.set('leaveSettingsTransition', null);
this.set('showLeaveSettingsModal', false);
return;
@ -52,15 +52,15 @@ export default Controller.extend({
},
leaveSettings() {
let transition = this.get('leaveSettingsTransition');
let transition = this.leaveSettingsTransition;
if (!transition) {
this.get('notifications').showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
this.notifications.showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
return;
}
// roll back changes on model props
this.set('unsplashSettings.isActive', this.get('rollbackValue'));
this.set('unsplashSettings.isActive', this.rollbackValue);
this.set('dirtyAttributes', false);
this.set('rollbackValue', null);
@ -69,8 +69,8 @@ export default Controller.extend({
},
save: task(function* () {
let unsplash = this.get('unsplashSettings');
let settings = this.get('settings');
let unsplash = this.unsplashSettings;
let settings = this.settings;
try {
settings.set('unsplash', unsplash);
@ -79,7 +79,7 @@ export default Controller.extend({
return yield settings.save();
} catch (error) {
if (error) {
this.get('notifications').showAPIError(error);
this.notifications.showAPIError(error);
throw error;
}
}

View File

@ -84,7 +84,7 @@ export default Controller.extend({
actions: {
onUpload(file) {
let formData = new FormData();
let notifications = this.get('notifications');
let notifications = this.notifications;
let currentUserId = this.get('session.user.id');
let dbUrl = this.get('ghostPaths.url').api('db');
@ -95,7 +95,7 @@ export default Controller.extend({
return this._validate(file).then(() => {
formData.append('importfile', file);
return this.get('ajax').post(dbUrl, {
return this.ajax.post(dbUrl, {
data: formData,
dataType: 'json',
cache: false,
@ -103,7 +103,7 @@ export default Controller.extend({
processData: false
});
}).then((response) => {
let store = this.get('store');
let store = this.store;
this.set('importSuccessful', true);
@ -126,9 +126,9 @@ export default Controller.extend({
notifications.showNotification('Import successful.', {key: 'import.upload.success'});
// reload settings
return this.get('settings').reload().then((settings) => {
this.get('feature').fetch();
this.get('config').set('blogTitle', settings.get('title'));
return this.settings.reload().then((settings) => {
this.feature.fetch();
this.config.set('blogTitle', settings.get('title'));
});
});
}).catch((response) => {
@ -187,7 +187,7 @@ export default Controller.extend({
});
let stripeConfig = stripeProcessor.config;
stripeConfig.product = {
name: this.get('settings').get('title')
name: this.settings.get('title')
};
if (key === 'isPaid') {
subscriptionSettings.isPaid = event;
@ -219,7 +219,7 @@ export default Controller.extend({
secret_token: '',
public_token: '',
product: {
name: this.get('settings').get('title')
name: this.settings.get('title')
},
plans: [
{
@ -273,7 +273,7 @@ export default Controller.extend({
});
}
let accept = this.get('importMimeType');
let accept = this.importMimeType;
if (!isBlank(accept) && file && accept.indexOf(file.type) === -1) {
return RSVP.reject(new UnsupportedMediaTypeError());
@ -283,11 +283,11 @@ export default Controller.extend({
},
sendTestEmail: task(function* () {
let notifications = this.get('notifications');
let notifications = this.notifications;
let emailUrl = this.get('ghostPaths.url').api('mail', 'test');
try {
yield this.get('ajax').post(emailUrl);
yield this.ajax.post(emailUrl);
notifications.showAlert('Check your email for the test message.', {type: 'info', key: 'test-email.send.success'});
return true;
} catch (error) {
@ -297,7 +297,7 @@ export default Controller.extend({
saveSettings: task(function* () {
try {
return yield this.get('settings').save();
return yield this.settings.save();
} catch (error) {
throw error;
}

View File

@ -28,7 +28,7 @@ export default Controller.extend({
},
_saveTagProperty(propKey, newValue) {
let tag = this.get('tag');
let tag = this.tag;
let isNewTag = tag.get('isNew');
let currentValue = tag.get(propKey);
@ -61,13 +61,13 @@ export default Controller.extend({
}
}).catch((error) => {
if (error) {
this.get('notifications').showAPIError(error, {key: 'tag.save'});
this.notifications.showAPIError(error, {key: 'tag.save'});
}
});
},
_deleteTag() {
let tag = this.get('tag');
let tag = this.tag;
return tag.destroyRecord().then(() => {
this._deleteTagSuccess();
@ -85,6 +85,6 @@ export default Controller.extend({
},
_deleteTagFailure(error) {
this.get('notifications').showAPIError(error, {key: 'tag.delete'});
this.notifications.showAPIError(error, {key: 'tag.delete'});
}
});

View File

@ -26,8 +26,8 @@ export default Controller.extend({
ownerEmail: alias('two.email'),
usersArray: computed('users', function () {
let errors = this.get('errors');
let users = this.get('users').split('\n').filter(function (email) {
let errors = this.errors;
let users = this.users.split('\n').filter(function (email) {
return email.trim().length > 0;
});
@ -42,23 +42,23 @@ export default Controller.extend({
}),
validUsersArray: computed('usersArray', 'ownerEmail', function () {
let ownerEmail = this.get('ownerEmail');
let ownerEmail = this.ownerEmail;
return this.get('usersArray').filter(function (user) {
return this.usersArray.filter(function (user) {
return validator.isEmail(user || '') && user !== ownerEmail;
});
}),
invalidUsersArray: computed('usersArray', 'ownerEmail', function () {
let ownerEmail = this.get('ownerEmail');
let ownerEmail = this.ownerEmail;
return this.get('usersArray').reject(user => validator.isEmail(user || '') || user === ownerEmail);
return this.usersArray.reject(user => validator.isEmail(user || '') || user === ownerEmail);
}),
validationResult: computed('invalidUsersArray', function () {
let errors = [];
this.get('invalidUsersArray').forEach((user) => {
this.invalidUsersArray.forEach((user) => {
errors.push({
user,
error: 'email'
@ -67,7 +67,7 @@ export default Controller.extend({
if (errors.length === 0) {
// ensure we aren't highlighting fields when everything is fine
this.get('errors').clear();
this.errors.clear();
return true;
} else {
return errors;
@ -76,8 +76,8 @@ export default Controller.extend({
buttonText: computed('errors.users', 'validUsersArray', 'invalidUsersArray', function () {
let usersError = this.get('errors.users.firstObject.message');
let validNum = this.get('validUsersArray').length;
let invalidNum = this.get('invalidUsersArray').length;
let validNum = this.validUsersArray.length;
let invalidNum = this.invalidUsersArray.length;
let userCount;
if (usersError && usersError.match(/no users/i)) {
@ -100,7 +100,7 @@ export default Controller.extend({
}),
buttonClass: computed('validationResult', 'usersArray.length', function () {
if (this.get('validationResult') === true && this.get('usersArray.length') > 0) {
if (this.validationResult === true && this.get('usersArray.length') > 0) {
return 'gh-btn-green';
} else {
return 'gh-btn-minor';
@ -117,7 +117,7 @@ export default Controller.extend({
},
invite() {
this.get('invite').perform();
this.invite.perform();
},
skipInvite() {
@ -127,14 +127,14 @@ export default Controller.extend({
},
validate() {
let errors = this.get('errors');
let validationResult = this.get('validationResult');
let errors = this.errors;
let validationResult = this.validationResult;
let property = 'users';
errors.clear();
// If property isn't in the `hasValidated` array, add it to mark that this field can show a validation result
this.get('hasValidated').addObject(property);
this.hasValidated.addObject(property);
if (validationResult === true) {
return true;
@ -159,17 +159,17 @@ export default Controller.extend({
},
invite: task(function* () {
let users = this.get('validUsersArray');
let users = this.validUsersArray;
if (this.validate() && users.length > 0) {
this._hasTransitioned = false;
this.get('_slowSubmissionTimeout').perform();
this._slowSubmissionTimeout.perform();
let authorRole = yield this.get('authorRole');
let authorRole = yield this.authorRole;
let invites = yield this._saveInvites(authorRole);
this.get('_slowSubmissionTimeout').cancelAll();
this._slowSubmissionTimeout.cancelAll();
this._showNotifications(invites);
@ -178,7 +178,7 @@ export default Controller.extend({
this._transitionAfterSubmission();
});
} else if (users.length === 0) {
this.get('errors').add('users', 'No users to invite');
this.errors.add('users', 'No users to invite');
}
}).drop(),
@ -188,7 +188,7 @@ export default Controller.extend({
}).drop(),
_saveInvites(authorRole) {
let users = this.get('validUsersArray');
let users = this.validUsersArray;
return RSVP.Promise.all(
users.map((user) => {
@ -210,7 +210,7 @@ export default Controller.extend({
},
_showNotifications(invites) {
let notifications = this.get('notifications');
let notifications = this.notifications;
let erroredEmails = [];
let successCount = 0;
let invitationsString, message;

View File

@ -30,7 +30,7 @@ export default Controller.extend(ValidationEngine, {
actions: {
setup() {
this.get('setup').perform();
this.setup.perform();
},
preValidate(model) {
@ -54,16 +54,16 @@ export default Controller.extend(ValidationEngine, {
this.set('session.skipAuthSuccessHandler', true);
try {
let authResult = yield this.get('session')
let authResult = yield this.session
.authenticate(authStrategy, ...authentication);
this.get('errors').remove('session');
this.errors.remove('session');
return authResult;
} catch (error) {
if (error && error.payload && error.payload.errors) {
if (isVersionMismatchError(error)) {
return this.get('notifications').showAPIError(error);
return this.notifications.showAPIError(error);
}
error.payload.errors.forEach((err) => {
@ -73,7 +73,7 @@ export default Controller.extend(ValidationEngine, {
this.set('flowErrors', error.payload.errors[0].message.string);
} else {
// Connection errors don't return proper status message, only req.body
this.get('notifications').showAlert('There was a problem on the server.', {type: 'error', key: 'session.authenticate.failed'});
this.notifications.showAlert('There was a problem on the server.', {type: 'error', key: 'session.authenticate.failed'});
}
}
}),
@ -85,13 +85,13 @@ export default Controller.extend(ValidationEngine, {
*/
_sendImage(user) {
let formData = new FormData();
let imageFile = this.get('profileImage');
let imageFile = this.profileImage;
let uploadUrl = this.get('ghostPaths.url').api('images', 'upload');
formData.append('file', imageFile, imageFile.name);
formData.append('purpose', 'profile_image');
return this.get('ajax').post(uploadUrl, {
return this.ajax.post(uploadUrl, {
data: formData,
processData: false,
contentType: false,
@ -102,7 +102,7 @@ export default Controller.extend(ValidationEngine, {
let usersUrl = this.get('ghostPaths.url').api('users', user.id.toString());
user.profile_image = imageUrl;
return this.get('ajax').put(usersUrl, {
return this.ajax.put(usersUrl, {
data: {
users: [user]
}
@ -113,17 +113,17 @@ export default Controller.extend(ValidationEngine, {
_passwordSetup() {
let setupProperties = ['blogTitle', 'name', 'email', 'password'];
let data = this.getProperties(setupProperties);
let config = this.get('config');
let method = this.get('blogCreated') ? 'put' : 'post';
let config = this.config;
let method = this.blogCreated ? 'put' : 'post';
this.set('flowErrors', '');
this.get('hasValidated').addObjects(setupProperties);
this.hasValidated.addObjects(setupProperties);
return this.validate().then(() => {
let authUrl = this.get('ghostPaths.url').api('authentication', 'setup');
return this.get('ajax')[method](authUrl, {
return this.ajax[method](authUrl, {
data: {
setup: [{
name: data.name,
@ -143,7 +143,7 @@ export default Controller.extend(ValidationEngine, {
// Don't call the success handler, otherwise we will be redirected to admin
this.set('session.skipAuthSuccessHandler', true);
return this.get('session').authenticate('authenticator:cookie', this.get('email'), this.get('password')).then(() => {
return this.session.authenticate('authenticator:cookie', this.email, this.password).then(() => {
this.set('blogCreated', true);
return this._afterAuthentication(result);
}).catch((error) => {
@ -163,7 +163,7 @@ export default Controller.extend(ValidationEngine, {
if (isInvalidError(resp)) {
this.set('flowErrors', resp.payload.errors[0].message);
} else {
this.get('notifications').showAPIError(resp, {key: 'setup.blog-details'});
this.notifications.showAPIError(resp, {key: 'setup.blog-details'});
}
},
@ -172,22 +172,22 @@ export default Controller.extend(ValidationEngine, {
this.set('flowErrors', error.payload.errors[0].message);
} else {
// Connection errors don't return proper status message, only req.body
this.get('notifications').showAlert('There was a problem on the server.', {type: 'error', key: 'setup.authenticate.failed'});
this.notifications.showAlert('There was a problem on the server.', {type: 'error', key: 'setup.authenticate.failed'});
}
},
_afterAuthentication(result) {
// fetch settings and private config for synchronous access before transitioning
let fetchSettingsAndConfig = RSVP.all([
this.get('settings').fetch()
this.settings.fetch()
]);
if (this.get('profileImage')) {
if (this.profileImage) {
return this._sendImage(result.users[0])
.then(() => (fetchSettingsAndConfig))
.then(() => (this.transitionToRoute('setup.three')))
.catch((resp) => {
this.get('notifications').showAPIError(resp, {key: 'setup.blog-details'});
this.notifications.showAPIError(resp, {key: 'setup.blog-details'});
});
} else {
return fetchSettingsAndConfig.then(() => this.transitionToRoute('setup.three'));

View File

@ -34,18 +34,18 @@ export default Controller.extend(ValidationEngine, {
actions: {
authenticate() {
this.get('validateAndAuthenticate').perform();
this.validateAndAuthenticate.perform();
}
},
authenticate: task(function* (authStrategy, authentication) {
try {
let authResult = yield this.get('session')
let authResult = yield this.session
.authenticate(authStrategy, ...authentication);
let promises = [];
promises.pushObject(this.get('settings').fetch());
promises.pushObject(this.get('config').fetchAuthenticated());
promises.pushObject(this.settings.fetch());
promises.pushObject(this.config.fetchAuthenticated());
// fetch settings and private config for synchronous access
yield RSVP.all(promises);
@ -53,7 +53,7 @@ export default Controller.extend(ValidationEngine, {
return authResult;
} catch (error) {
if (isVersionMismatchError(error)) {
return this.get('notifications').showAPIError(error);
return this.notifications.showAPIError(error);
}
if (error && error.payload && error.payload.errors) {
@ -73,7 +73,7 @@ export default Controller.extend(ValidationEngine, {
}
} else {
// Connection errors don't return proper status message, only req.body
this.get('notifications').showAlert(
this.notifications.showAlert(
'There was a problem on the server.',
{type: 'error', key: 'session.authenticate.failed'}
);
@ -82,7 +82,7 @@ export default Controller.extend(ValidationEngine, {
}).drop(),
validateAndAuthenticate: task(function* () {
let signin = this.get('signin');
let signin = this.signin;
let authStrategy = 'authenticator:cookie';
this.set('flowErrors', '');
@ -91,11 +91,11 @@ export default Controller.extend(ValidationEngine, {
$('#login').find('input').trigger('change');
// This is a bit dirty, but there's no other way to ensure the properties are set as well as 'signin'
this.get('hasValidated').addObjects(this.authProperties);
this.hasValidated.addObjects(this.authProperties);
try {
yield this.validate({property: 'signin'});
return yield this.get('authenticate')
return yield this.authenticate
.perform(authStrategy, [signin.get('identification'), signin.get('password')]);
} catch (error) {
this.set('flowErrors', 'Please fill out the form to sign in.');
@ -105,15 +105,15 @@ export default Controller.extend(ValidationEngine, {
forgotten: task(function* () {
let email = this.get('signin.identification');
let forgottenUrl = this.get('ghostPaths.url').api('authentication', 'passwordreset');
let notifications = this.get('notifications');
let notifications = this.notifications;
this.set('flowErrors', '');
// This is a bit dirty, but there's no other way to ensure the properties are set as well as 'forgotPassword'
this.get('hasValidated').addObject('identification');
this.hasValidated.addObject('identification');
try {
yield this.validate({property: 'forgotPassword'});
yield this.get('ajax').post(forgottenUrl, {data: {passwordreset: [{email}]}});
yield this.ajax.post(forgottenUrl, {data: {passwordreset: [{email}]}});
notifications.showAlert(
'Please check your email for instructions.',
{type: 'info', key: 'forgot-password.send.success'}

View File

@ -38,7 +38,7 @@ export default Controller.extend({
signup: task(function* () {
let setupProperties = ['name', 'email', 'password', 'token'];
let notifications = this.get('notifications');
let notifications = this.notifications;
this.set('flowErrors', '');
this.get('signupDetails.hasValidated').addObjects(setupProperties);
@ -73,9 +73,9 @@ export default Controller.extend({
_completeInvitation() {
let authUrl = this.get('ghostPaths.url').api('authentication', 'invitation');
let signupDetails = this.get('signupDetails');
let signupDetails = this.signupDetails;
return this.get('ajax').post(authUrl, {
return this.ajax.post(authUrl, {
dataType: 'json',
data: {
invitation: [{
@ -92,13 +92,13 @@ export default Controller.extend({
let email = this.get('signupDetails.email');
let password = this.get('signupDetails.password');
return this.get('session')
return this.session
.authenticate('authenticator:cookie', email, password);
},
_sendImage: task(function* () {
let formData = new FormData();
let imageFile = this.get('profileImage');
let imageFile = this.profileImage;
let uploadUrl = this.get('ghostPaths.url').api('images', 'upload');
if (imageFile) {
@ -106,7 +106,7 @@ export default Controller.extend({
formData.append('purpose', 'profile_image');
let user = yield this.get('session.user');
let response = yield this.get('ajax').post(uploadUrl, {
let response = yield this.ajax.post(uploadUrl, {
data: formData,
processData: false,
contentType: false,

View File

@ -53,8 +53,8 @@ export default Controller.extend({
}),
deleteUserActionIsVisible: computed('currentUser', 'canAssignRoles', 'user', function () {
if ((this.get('canAssignRoles') && this.get('isNotOwnProfile') && !this.get('user.isOwner'))
|| (this.get('currentUser.isEditor') && (this.get('isNotOwnProfile')
if ((this.canAssignRoles && this.isNotOwnProfile && !this.get('user.isOwner'))
|| (this.get('currentUser.isEditor') && (this.isNotOwnProfile
|| this.get('user.isAuthorOrContributor')))) {
return true;
}
@ -70,7 +70,7 @@ export default Controller.extend({
actions: {
changeRole(newRole) {
this.get('user').set('role', newRole);
this.user.set('role', newRole);
this.set('dirtyAttributes', true);
},
@ -83,35 +83,35 @@ export default Controller.extend({
},
toggleDeleteUserModal() {
if (this.get('deleteUserActionIsVisible')) {
if (this.deleteUserActionIsVisible) {
this.toggleProperty('showDeleteUserModal');
}
},
suspendUser() {
this.get('user').set('status', 'inactive');
return this.get('save').perform();
this.user.set('status', 'inactive');
return this.save.perform();
},
toggleSuspendUserModal() {
if (this.get('deleteUserActionIsVisible')) {
if (this.deleteUserActionIsVisible) {
this.toggleProperty('showSuspendUserModal');
}
},
unsuspendUser() {
this.get('user').set('status', 'active');
return this.get('save').perform();
this.user.set('status', 'active');
return this.save.perform();
},
toggleUnsuspendUserModal() {
if (this.get('deleteUserActionIsVisible')) {
if (this.deleteUserActionIsVisible) {
this.toggleProperty('showUnsuspendUserModal');
}
},
validateFacebookUrl() {
let newUrl = this.get('_scratchFacebook');
let newUrl = this._scratchFacebook;
let oldUrl = this.get('user.facebook');
let errMessage = '';
@ -167,7 +167,7 @@ export default Controller.extend({
},
validateTwitterUrl() {
let newUrl = this.get('_scratchTwitter');
let newUrl = this._scratchTwitter;
let oldUrl = this.get('user.twitter');
let errMessage = '';
@ -222,12 +222,12 @@ export default Controller.extend({
},
transferOwnership() {
let user = this.get('user');
let user = this.user;
let url = this.get('ghostPaths.url').api('users', 'owner');
this.get('dropdown').closeDropdowns();
this.dropdown.closeDropdowns();
return this.get('ajax').put(url, {
return this.ajax.put(url, {
data: {
owner: [{
id: user.get('id')
@ -245,16 +245,16 @@ export default Controller.extend({
});
}
this.get('notifications').showAlert(`Ownership successfully transferred to ${user.get('name')}`, {type: 'success', key: 'owner.transfer.success'});
this.notifications.showAlert(`Ownership successfully transferred to ${user.get('name')}`, {type: 'success', key: 'owner.transfer.success'});
}).catch((error) => {
this.get('notifications').showAPIError(error, {key: 'owner.transfer'});
this.notifications.showAPIError(error, {key: 'owner.transfer'});
});
},
toggleLeaveSettingsModal(transition) {
let leaveTransition = this.get('leaveSettingsTransition');
let leaveTransition = this.leaveSettingsTransition;
if (!transition && this.get('showLeaveSettingsModal')) {
if (!transition && this.showLeaveSettingsModal) {
this.set('leaveSettingsTransition', null);
this.set('showLeaveSettingsModal', false);
return;
@ -276,18 +276,18 @@ export default Controller.extend({
},
leaveSettings() {
let transition = this.get('leaveSettingsTransition');
let user = this.get('user');
let transition = this.leaveSettingsTransition;
let user = this.user;
if (!transition) {
this.get('notifications').showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
this.notifications.showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
return;
}
// roll back changes on user props
user.rollbackAttributes();
// roll back the slugValue property
if (this.get('dirtyAttributes')) {
if (this.dirtyAttributes) {
this.set('slugValue', user.get('slug'));
this.set('dirtyAttributes', false);
}
@ -296,7 +296,7 @@ export default Controller.extend({
},
toggleTransferOwnerModal() {
if (this.get('canMakeOwner')) {
if (this.canMakeOwner) {
this.toggleProperty('showTransferOwnerModal');
}
},
@ -331,20 +331,20 @@ export default Controller.extend({
},
_deleteUser() {
if (this.get('deleteUserActionIsVisible')) {
let user = this.get('user');
if (this.deleteUserActionIsVisible) {
let user = this.user;
return user.destroyRecord();
}
},
_deleteUserSuccess() {
this.get('notifications').closeAlerts('user.delete');
this.notifications.closeAlerts('user.delete');
this.store.unloadAll('post');
this.transitionToRoute('staff');
},
_deleteUserFailure() {
this.get('notifications').showAlert('The user could not be deleted. Please try again.', {type: 'error', key: 'user.delete.failed'});
this.notifications.showAlert('The user could not be deleted. Please try again.', {type: 'error', key: 'user.delete.failed'});
},
updateSlug: task(function* (newSlug) {
@ -360,7 +360,7 @@ export default Controller.extend({
return true;
}
let serverSlug = yield this.get('slugGenerator').generateSlug('user', newSlug);
let serverSlug = yield this.slugGenerator.generateSlug('user', newSlug);
// 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
@ -395,8 +395,8 @@ export default Controller.extend({
}).group('saveHandlers'),
save: task(function* () {
let user = this.get('user');
let slugValue = this.get('slugValue');
let user = this.user;
let slugValue = this.slugValue;
let slugChanged;
if (user.get('slug') !== slugValue) {
@ -420,14 +420,14 @@ export default Controller.extend({
}
this.set('dirtyAttributes', false);
this.get('notifications').closeAlerts('user.update');
this.notifications.closeAlerts('user.update');
return user;
} catch (error) {
// validation engine returns undefined so we have to check
// before treating the failure as an API error
if (error) {
this.get('notifications').showAPIError(error, {key: 'user.update'});
this.notifications.showAPIError(error, {key: 'user.update'});
}
}
}).group('saveHandlers')

View File

@ -25,8 +25,8 @@ export default Controller.extend(PaginationMixin, {
// getter/setter CP here so that we don't lose the dynamic order param
paginationSettings: computed('order', 'direction', {
get() {
let order = this.get('order');
let direction = this.get('direction');
let order = this.order;
let direction = this.direction;
let currentSettings = this._paginationSettings || {
limit: 30
@ -43,8 +43,8 @@ export default Controller.extend(PaginationMixin, {
}),
columns: computed('order', 'direction', function () {
let order = this.get('order');
let direction = this.get('direction');
let order = this.order;
let direction = this.direction;
return [{
label: 'Email Address',
@ -82,7 +82,7 @@ export default Controller.extend(PaginationMixin, {
actions: {
loadFirstPage() {
let table = this.get('table');
let table = this.table;
return this._super(...arguments).then((results) => {
table.addRows(results);
@ -91,7 +91,7 @@ export default Controller.extend(PaginationMixin, {
},
loadNextPage() {
let table = this.get('table');
let table = this.table;
return this._super(...arguments).then((results) => {
table.addRows(results);
@ -100,7 +100,7 @@ export default Controller.extend(PaginationMixin, {
},
sortByColumn(column) {
let table = this.get('table');
let table = this.table;
if (column.sorted) {
this.setProperties({
@ -113,7 +113,7 @@ export default Controller.extend(PaginationMixin, {
},
addSubscriber(subscriber) {
this.get('table').insertRowAt(0, subscriber);
this.table.insertRowAt(0, subscriber);
this.incrementProperty('total');
},
@ -122,11 +122,11 @@ export default Controller.extend(PaginationMixin, {
},
confirmDeleteSubscriber() {
let subscriber = this.get('subscriberToDelete');
let subscriber = this.subscriberToDelete;
return subscriber.destroyRecord().then(() => {
this.set('subscriberToDelete', null);
this.get('table').removeRow(subscriber);
this.table.removeRow(subscriber);
this.decrementProperty('total');
});
},
@ -136,7 +136,7 @@ export default Controller.extend(PaginationMixin, {
},
reset() {
this.get('table').setRows([]);
this.table.setRows([]);
this.send('loadFirstPage');
},
@ -155,7 +155,7 @@ export default Controller.extend(PaginationMixin, {
},
initializeTable() {
this.set('table', new Table(this.get('columns'), this.get('subscribers')));
this.set('table', new Table(this.columns, this.subscribers));
},
// capture the total from the server any time we fetch a new page

View File

@ -32,11 +32,11 @@ export default Mixin.create({
this._clickHandler = event => this.bodyClick(event);
return $(this.get('bodyElementSelector')).on('click', this._clickHandler);
return $(this.bodyElementSelector).on('click', this._clickHandler);
},
_removeDocumentHandlers() {
$(this.get('bodyElementSelector')).off('click', this._clickHandler);
$(this.bodyElementSelector).off('click', this._clickHandler);
this._clickHandler = null;
},

View File

@ -1,6 +1,6 @@
import Mixin from '@ember/object/mixin';
import RSVP from 'rsvp';
// import {assign} from '@ember/polyfills';
// import { assign } from '@ember/polyfills';
import {computed} from '@ember/object';
import {inject as service} from '@ember/service';
@ -51,18 +51,18 @@ export default Mixin.create({
},
reportLoadError(error) {
this.get('notifications').showAPIError(error, {key: 'pagination.load.failed'});
this.notifications.showAPIError(error, {key: 'pagination.load.failed'});
},
loadFirstPage(transition) {
let paginationSettings = this.get('paginationSettings');
let modelName = this.get('paginationModel');
let paginationSettings = this.paginationSettings;
let modelName = this.paginationModel;
this.set('paginationSettings.page', 1);
this.set('isLoading', true);
return this.get('store').query(modelName, paginationSettings).then((results) => {
return this.store.query(modelName, paginationSettings).then((results) => {
this.set('paginationMeta', results.meta);
return results;
}).catch((error) => {
@ -88,13 +88,13 @@ export default Mixin.create({
* @return
*/
loadNextPage() {
let store = this.get('store');
let modelName = this.get('paginationModel');
let metadata = this.get('paginationMeta');
let store = this.store;
let modelName = this.paginationModel;
let metadata = this.paginationMeta;
let nextPage = metadata.pagination && metadata.pagination.next;
let paginationSettings = this.get('paginationSettings');
let paginationSettings = this.paginationSettings;
if (nextPage && !this.get('isLoading')) {
if (nextPage && !this.isLoading) {
this.set('isLoading', true);
this.set('paginationSettings.page', nextPage);

View File

@ -10,7 +10,7 @@ export default Mixin.create({
},
set(key, value) {
// Not viewing a subview if we can't even see the PSM
if (!this.get('showSettingsMenu')) {
if (!this.showSettingsMenu) {
return false;
}
return value;

View File

@ -46,7 +46,7 @@ key.setScope('default');
export default Mixin.create({
registerShortcuts() {
let shortcuts = this.get('shortcuts');
let shortcuts = this.shortcuts;
Object.keys(shortcuts).forEach((shortcut) => {
let scope = shortcuts[shortcut].scope || 'default';
@ -69,7 +69,7 @@ export default Mixin.create({
},
removeShortcuts() {
let shortcuts = this.get('shortcuts');
let shortcuts = this.shortcuts;
Object.keys(shortcuts).forEach((shortcut) => {
let scope = shortcuts[shortcut].scope || 'default';

View File

@ -5,7 +5,7 @@ import {run} from '@ember/runloop';
// mixin used for routes that need to set a css className on the body tag
export default Mixin.create({
activate() {
let cssClasses = this.get('classNames');
let cssClasses = this.classNames;
this._super(...arguments);
@ -19,7 +19,7 @@ export default Mixin.create({
},
deactivate() {
let cssClasses = this.get('classNames');
let cssClasses = this.classNames;
this._super(...arguments);

View File

@ -17,7 +17,7 @@ export default Mixin.create({
stopEnterKeyDownPropagation: false,
autofocus: computed(function () {
if (this.get('shouldFocus')) {
if (this.shouldFocus) {
return (this.userAgent.os.isIOS) ? false : 'autofocus';
}
@ -30,7 +30,7 @@ export default Mixin.create({
},
click(event) {
if (this.get('selectOnClick')) {
if (this.selectOnClick) {
event.currentTarget.select();
}
},
@ -39,7 +39,7 @@ export default Mixin.create({
// stop event propagation when pressing "enter"
// most useful in the case when undesired (global) keyboard shortcuts
// are getting triggered while interacting with this particular input element.
if (event.keyCode === 13 && this.get('stopEnterKeyDownPropagation')) {
if (event.keyCode === 13 && this.stopEnterKeyDownPropagation) {
event.stopPropagation();
return true;
@ -75,7 +75,7 @@ export default Mixin.create({
_focus() {
// Until mobile safari has better support
// for focusing, we just ignore it
if (this.get('shouldFocus') && !this.userAgent.os.isIOS) {
if (this.shouldFocus && !this.userAgent.os.isIOS) {
this.element.focus();
}
},

View File

@ -13,7 +13,7 @@ export default Mixin.create({
let authUrl = this.get('ghostPaths.url').api('authentication', 'setup');
// check the state of the setup process via the API
return this.get('ajax').request(authUrl).then((result) => {
return this.ajax.request(authUrl).then((result) => {
let [setup] = result.setup;
if (setup.status !== true) {
@ -22,8 +22,8 @@ export default Mixin.create({
// NOTE: this is the same as ESA's UnauthenticatedRouteMixin,
// adding that mixin to this and calling _super wasn't calling
// the ESA mixin's beforeModel method
if (this.get('session').get('isAuthenticated')) {
let routeIfAlreadyAuthenticated = this.get('routeIfAlreadyAuthenticated');
if (this.session.get('isAuthenticated')) {
let routeIfAlreadyAuthenticated = this.routeIfAlreadyAuthenticated;
return this.transitionTo(routeIfAlreadyAuthenticated);
} else {

View File

@ -87,13 +87,13 @@ export default Mixin.create({
model = opts.model;
} else if (this instanceof Model) {
model = this;
} else if (this.get('model')) {
model = this.get('model');
} else if (this.model) {
model = this.model;
}
type = this.get('validationType') || model.get('validationType');
type = this.validationType || model.get('validationType');
validator = this.get(`validators.${type}`) || model.get(`validators.${type}`);
hasValidated = this.get('hasValidated');
hasValidated = this.hasValidated;
opts.validationType = type;
@ -132,7 +132,7 @@ export default Mixin.create({
// model.destroyRecord() calls model.save() behind the scenes.
// in that case, we don't need validation checks or error propagation,
// because the model itself is being destroyed.
if (this.get('isDeleted')) {
if (this.isDeleted) {
return this._super(...arguments);
}

View File

@ -13,9 +13,9 @@ export default Mixin.create({
hasError: false,
setHasError() {
let property = this.get('property');
let errors = this.get('errors');
let hasValidated = this.get('hasValidated');
let property = this.property;
let errors = this.errors;
let hasValidated = this.hasValidated;
// if we aren't looking at a specific property we always want an error class
if (!property && errors && !errors.get('isEmpty')) {

Some files were not shown because too many files have changed in this diff Show More