mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 10:53:34 +03:00
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:
parent
e161dd4180
commit
352c4af1d7
@ -30,7 +30,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
closeNotification() {
|
closeNotification() {
|
||||||
this.get('notifications').closeNotification(this.get('message'));
|
this.notifications.closeNotification(this.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -8,7 +8,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
let showSettingsMenu = this.get('showSettingsMenu');
|
let showSettingsMenu = this.showSettingsMenu;
|
||||||
|
|
||||||
$('body').toggleClass('settings-menu-expanded', showSettingsMenu);
|
$('body').toggleClass('settings-menu-expanded', showSettingsMenu);
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@ export default BasicDropdown.extend({
|
|||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
this.get('dropdown').on('close', this, this.close);
|
this.dropdown.on('close', this, this.close);
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
this.get('dropdown').off('close');
|
this.dropdown.off('close');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -30,14 +30,14 @@ const CmEditorComponent = Component.extend({
|
|||||||
_value: boundOneWay('value'), // make sure a value exists
|
_value: boundOneWay('value'), // make sure a value exists
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
if (this.get('_value') === null || undefined) {
|
if (this._value === null || undefined) {
|
||||||
this.set('_value', '');
|
this.set('_value', '');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
this.get('initCodeMirror').perform();
|
this.initCodeMirror.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
@ -60,7 +60,7 @@ const CmEditorComponent = Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
initCodeMirror: task(function* () {
|
initCodeMirror: task(function* () {
|
||||||
let loader = this.get('lazyLoader');
|
let loader = this.lazyLoader;
|
||||||
yield loader.loadScript('codemirror', 'assets/codemirror/codemirror.js');
|
yield loader.loadScript('codemirror', 'assets/codemirror/codemirror.js');
|
||||||
|
|
||||||
scheduleOnce('afterRender', this, this._initCodeMirror);
|
scheduleOnce('afterRender', this, this._initCodeMirror);
|
||||||
@ -68,7 +68,7 @@ const CmEditorComponent = Component.extend({
|
|||||||
|
|
||||||
_initCodeMirror() {
|
_initCodeMirror() {
|
||||||
let options = this.getProperties('lineNumbers', 'lineWrapping', 'indentUnit', 'mode', 'theme', 'autofocus');
|
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');
|
let textarea = this.element.querySelector('textarea');
|
||||||
if (textarea && textarea === document.activeElement) {
|
if (textarea && textarea === document.activeElement) {
|
||||||
@ -105,7 +105,7 @@ const CmEditorComponent = Component.extend({
|
|||||||
|
|
||||||
_focus(codeMirror, event) {
|
_focus(codeMirror, event) {
|
||||||
this.set('isFocused', true);
|
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 */) {
|
_blur(/* codeMirror, event */) {
|
||||||
|
@ -19,6 +19,6 @@ export default Component.extend({
|
|||||||
classNames: ['content-cover'],
|
classNames: ['content-cover'],
|
||||||
|
|
||||||
click() {
|
click() {
|
||||||
this.get('ui').closeMenus();
|
this.ui.closeMenus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -25,13 +25,13 @@ export default Component.extend({
|
|||||||
hasError: or('dateError', 'timeError'),
|
hasError: or('dateError', 'timeError'),
|
||||||
|
|
||||||
timezone: computed('blogTimezone', function () {
|
timezone: computed('blogTimezone', function () {
|
||||||
let blogTimezone = this.get('blogTimezone');
|
let blogTimezone = this.blogTimezone;
|
||||||
return moment.utc().tz(blogTimezone).format('z');
|
return moment.utc().tz(blogTimezone).format('z');
|
||||||
}),
|
}),
|
||||||
|
|
||||||
dateError: computed('errors.[]', 'dateErrorProperty', function () {
|
dateError: computed('errors.[]', 'dateErrorProperty', function () {
|
||||||
let errors = this.get('errors');
|
let errors = this.errors;
|
||||||
let property = this.get('dateErrorProperty');
|
let property = this.dateErrorProperty;
|
||||||
|
|
||||||
if (errors && !isEmpty(errors.errorsFor(property))) {
|
if (errors && !isEmpty(errors.errorsFor(property))) {
|
||||||
return errors.errorsFor(property).get('firstObject').message;
|
return errors.errorsFor(property).get('firstObject').message;
|
||||||
@ -39,8 +39,8 @@ export default Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
timeError: computed('errors.[]', 'timeErrorProperty', function () {
|
timeError: computed('errors.[]', 'timeErrorProperty', function () {
|
||||||
let errors = this.get('errors');
|
let errors = this.errors;
|
||||||
let property = this.get('timeErrorProperty');
|
let property = this.timeErrorProperty;
|
||||||
|
|
||||||
if (errors && !isEmpty(errors.errorsFor(property))) {
|
if (errors && !isEmpty(errors.errorsFor(property))) {
|
||||||
return errors.errorsFor(property).get('firstObject').message;
|
return errors.errorsFor(property).get('firstObject').message;
|
||||||
@ -48,11 +48,11 @@ export default Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
let date = this.get('date');
|
let date = this.date;
|
||||||
let time = this.get('time');
|
let time = this.time;
|
||||||
let minDate = this.get('minDate');
|
let minDate = this.minDate;
|
||||||
let maxDate = this.get('maxDate');
|
let maxDate = this.maxDate;
|
||||||
let blogTimezone = this.get('blogTimezone');
|
let blogTimezone = this.blogTimezone;
|
||||||
|
|
||||||
if (!isBlank(date)) {
|
if (!isBlank(date)) {
|
||||||
this.set('_date', moment(date));
|
this.set('_date', moment(date));
|
||||||
@ -61,11 +61,11 @@ export default Component.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isBlank(time)) {
|
if (isBlank(time)) {
|
||||||
this.set('_time', this.get('_date').format('HH:mm'));
|
this.set('_time', this._date.format('HH:mm'));
|
||||||
} else {
|
} 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
|
// unless min/max date is at midnight moment will diable that day
|
||||||
if (minDate === 'now') {
|
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
|
// 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
|
// so that we don't get "can't be blank" errors
|
||||||
setDate(date) {
|
setDate(date) {
|
||||||
if (date !== this.get('_date')) {
|
if (date !== this._date) {
|
||||||
this.get('setDate')(date);
|
this.setDate(date);
|
||||||
|
|
||||||
if (isBlank(this.get('time'))) {
|
if (isBlank(this.time)) {
|
||||||
this.get('setTime')(this.get('_time'));
|
this.setTime(this._time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -103,12 +103,12 @@ export default Component.extend({
|
|||||||
time = `0${time}`;
|
time = `0${time}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time !== this.get('_previousTime')) {
|
if (time !== this._previousTime) {
|
||||||
this.get('setTime')(time);
|
this.setTime(time);
|
||||||
this.set('_previousTime', time);
|
this.set('_previousTime', time);
|
||||||
|
|
||||||
if (isBlank(this.get('date'))) {
|
if (isBlank(this.date)) {
|
||||||
this.get('setDate')(this.get('_date'));
|
this.setDate(this._date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ export default Component.extend({
|
|||||||
count: '',
|
count: '',
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this.get('_poll').perform();
|
this._poll.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
_poll: task(function* () {
|
_poll: task(function* () {
|
||||||
@ -19,7 +19,7 @@ export default Component.extend({
|
|||||||
let pattern = /(-?\d+)(\d{3})/;
|
let pattern = /(-?\d+)(\d{3})/;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let data = yield this.get('ajax').request(url);
|
let data = yield this.ajax.request(url);
|
||||||
let count = data.count.toString();
|
let count = data.count.toString();
|
||||||
|
|
||||||
while (pattern.test(count)) {
|
while (pattern.test(count)) {
|
||||||
@ -30,7 +30,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
if (config.environment !== 'test') {
|
if (config.environment !== 'test') {
|
||||||
yield timeout(2000);
|
yield timeout(2000);
|
||||||
this.get('_poll').perform();
|
this._poll.perform();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// no-op - we don't want to create noise for a failed download count
|
// no-op - we don't want to create noise for a failed download count
|
||||||
|
@ -15,9 +15,9 @@ export default Component.extend(DropdownMixin, {
|
|||||||
// Notify dropdown service this dropdown should be toggled
|
// Notify dropdown service this dropdown should be toggled
|
||||||
click(event) {
|
click(event) {
|
||||||
this._super(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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,11 @@ export default Component.extend(DropdownMixin, {
|
|||||||
|
|
||||||
// Managed the toggle between the fade-in and fade-out classes
|
// Managed the toggle between the fade-in and fade-out classes
|
||||||
fadeIn: computed('isOpen', 'closing', function () {
|
fadeIn: computed('isOpen', 'closing', function () {
|
||||||
return this.get('isOpen') && !this.get('closing');
|
return this.isOpen && !this.closing;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
let dropdownService = this.get('dropdown');
|
let dropdownService = this.dropdown;
|
||||||
|
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ export default Component.extend(DropdownMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
let dropdownService = this.get('dropdown');
|
let dropdownService = this.dropdown;
|
||||||
|
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
@ -51,14 +51,14 @@ export default Component.extend(DropdownMixin, {
|
|||||||
close() {
|
close() {
|
||||||
this.set('closing', true);
|
this.set('closing', true);
|
||||||
|
|
||||||
if (this.get('button')) {
|
if (this.button) {
|
||||||
this.set('button.isOpen', false);
|
this.set('button.isOpen', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$().on('animationend webkitAnimationEnd oanimationend MSAnimationEnd', (event) => {
|
this.$().on('animationend webkitAnimationEnd oanimationend MSAnimationEnd', (event) => {
|
||||||
if (event.originalEvent.animationName === 'fade-out') {
|
if (event.originalEvent.animationName === 'fade-out') {
|
||||||
run(this, function () {
|
run(this, function () {
|
||||||
if (this.get('closing')) {
|
if (this.closing) {
|
||||||
this.set('isOpen', false);
|
this.set('isOpen', false);
|
||||||
this.set('closing', 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.
|
// Called by the dropdown service when any dropdown button is clicked.
|
||||||
toggle(options) {
|
toggle(options) {
|
||||||
let isClosing = this.get('closing');
|
let isClosing = this.closing;
|
||||||
let isOpen = this.get('isOpen');
|
let isOpen = this.isOpen;
|
||||||
let name = this.get('name');
|
let name = this.name;
|
||||||
let targetDropdownName = options.target;
|
let targetDropdownName = options.target;
|
||||||
let button = this.get('button');
|
let button = this.button;
|
||||||
|
|
||||||
if (name === targetDropdownName && (!isOpen || isClosing)) {
|
if (name === targetDropdownName && (!isOpen || isClosing)) {
|
||||||
if (!button) {
|
if (!button) {
|
||||||
@ -89,7 +89,7 @@ export default Component.extend(DropdownMixin, {
|
|||||||
click(event) {
|
click(event) {
|
||||||
this._super(event);
|
this._super(event);
|
||||||
|
|
||||||
if (this.get('closeOnClick')) {
|
if (this.closeOnClick) {
|
||||||
return this.close();
|
return this.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@ export default Component.extend({
|
|||||||
// we want to ensure that the "Saving..." message is shown for at least
|
// we want to ensure that the "Saving..." message is shown for at least
|
||||||
// a few seconds so that it's noticeable
|
// a few seconds so that it's noticeable
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
if (this.get('isSaving')) {
|
if (this.isSaving) {
|
||||||
this.get('showSavingMessage').perform();
|
this.showSavingMessage.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ export default Component.extend({
|
|||||||
actions: {
|
actions: {
|
||||||
toggleFullScreen(isFullScreen) {
|
toggleFullScreen(isFullScreen) {
|
||||||
this.set('isFullScreen', isFullScreen);
|
this.set('isFullScreen', isFullScreen);
|
||||||
this.get('ui').set('isFullScreen', isFullScreen);
|
this.ui.set('isFullScreen', isFullScreen);
|
||||||
run.scheduleOnce('afterRender', this, this._setHeaderClass);
|
run.scheduleOnce('afterRender', this, this._setHeaderClass);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
this._editorTitleElement = editorTitle;
|
this._editorTitleElement = editorTitle;
|
||||||
|
|
||||||
if (this.get('isSplitScreen')) {
|
if (this.isSplitScreen) {
|
||||||
this.set('headerClass', smallHeaderClass);
|
this.set('headerClass', smallHeaderClass);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ export default Component.extend({
|
|||||||
isVisible: notEmpty('errors'),
|
isVisible: notEmpty('errors'),
|
||||||
|
|
||||||
message: computed('errors.[]', 'property', function () {
|
message: computed('errors.[]', 'property', function () {
|
||||||
let property = this.get('property');
|
let property = this.property;
|
||||||
let errors = this.get('errors');
|
let errors = this.errors;
|
||||||
let messages = [];
|
let messages = [];
|
||||||
let index;
|
let index;
|
||||||
|
|
||||||
|
@ -10,36 +10,36 @@ const FeatureFlagComponent = Component.extend({
|
|||||||
classNames: 'checkbox',
|
classNames: 'checkbox',
|
||||||
attributeBindings: ['for', 'disabled'],
|
attributeBindings: ['for', 'disabled'],
|
||||||
disabled: computed('_disabled', function () {
|
disabled: computed('_disabled', function () {
|
||||||
if (this.get('_disabled')) {
|
if (this._disabled) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}),
|
}),
|
||||||
value: computed('_flagValue', {
|
value: computed('_flagValue', {
|
||||||
get() {
|
get() {
|
||||||
return this.get('_flagValue');
|
return this._flagValue;
|
||||||
},
|
},
|
||||||
set(key, value) {
|
set(key, value) {
|
||||||
if (this.get('flag') === 'members' && value === true) {
|
if (this.flag === 'members' && value === true) {
|
||||||
this.set(`feature.subscribers`, false);
|
this.set(`feature.subscribers`, false);
|
||||||
}
|
}
|
||||||
return this.set(`feature.${this.get('flag')}`, value);
|
return this.set(`feature.${this.flag}`, value);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
for: computed('flag', function () {
|
for: computed('flag', function () {
|
||||||
return `labs-${this.get('flag')}`;
|
return `labs-${this.flag}`;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
name: computed('flag', function () {
|
name: computed('flag', function () {
|
||||||
return `labs[${this.get('flag')}]`;
|
return `labs[${this.flag}]`;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
defineProperty(this, '_flagValue', readOnly(`feature.${this.get('flag')}`), function () {
|
defineProperty(this, '_flagValue', readOnly(`feature.${this.flag}`), function () {
|
||||||
return this.get(`feature.${this.get('flag')}`);
|
return this.get(`feature.${this.flag}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -5,7 +5,7 @@ import XFileInput from 'emberx-file-input/components/x-file-input';
|
|||||||
|
|
||||||
export default XFileInput.extend({
|
export default XFileInput.extend({
|
||||||
change(e) {
|
change(e) {
|
||||||
let action = this.get('action');
|
let action = this.action;
|
||||||
let files = this.files(e);
|
let files = this.files(e);
|
||||||
|
|
||||||
if (files.length && action) {
|
if (files.length && action) {
|
||||||
|
@ -15,7 +15,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
upload() {
|
upload() {
|
||||||
if (!this.get('uploadButtonDisabled') && this._file) {
|
if (!this.uploadButtonDisabled && this._file) {
|
||||||
this.onUpload(this._file);
|
this.onUpload(this._file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ export default Component.extend({
|
|||||||
this.set('uploadButtonDisabled', true);
|
this.set('uploadButtonDisabled', true);
|
||||||
|
|
||||||
// Reset form
|
// Reset form
|
||||||
if (this.get('shouldResetForm')) {
|
if (this.shouldResetForm) {
|
||||||
this.$().closest('form')[0].reset();
|
this.$().closest('form')[0].reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,8 @@ export default Component.extend({
|
|||||||
uploadFailed: () => {},
|
uploadFailed: () => {},
|
||||||
|
|
||||||
formData: computed('file', function () {
|
formData: computed('file', function () {
|
||||||
let paramName = this.get('paramName');
|
let paramName = this.paramName;
|
||||||
let file = this.get('file');
|
let file = this.file;
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
|
|
||||||
formData.append(paramName, file);
|
formData.append(paramName, file);
|
||||||
@ -58,7 +58,7 @@ export default Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
progressStyle: computed('uploadPercentage', function () {
|
progressStyle: computed('uploadPercentage', function () {
|
||||||
let percentage = this.get('uploadPercentage');
|
let percentage = this.uploadPercentage;
|
||||||
let width = '';
|
let width = '';
|
||||||
|
|
||||||
if (percentage > 0) {
|
if (percentage > 0) {
|
||||||
@ -74,13 +74,13 @@ export default Component.extend({
|
|||||||
// process can be triggered externally
|
// process can be triggered externally
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
let listenTo = this.get('listenTo');
|
let listenTo = this.listenTo;
|
||||||
|
|
||||||
this.accept = this.accept || DEFAULTS.accept;
|
this.accept = this.accept || DEFAULTS.accept;
|
||||||
this.extensions = this.extensions || DEFAULTS.extensions;
|
this.extensions = this.extensions || DEFAULTS.extensions;
|
||||||
|
|
||||||
if (listenTo) {
|
if (listenTo) {
|
||||||
this.get('eventBus').subscribe(`${listenTo}:upload`, this, function (file) {
|
this.eventBus.subscribe(`${listenTo}:upload`, this, function (file) {
|
||||||
if (file) {
|
if (file) {
|
||||||
this.set('file', file);
|
this.set('file', file);
|
||||||
}
|
}
|
||||||
@ -91,20 +91,20 @@ export default Component.extend({
|
|||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
let accept = this.get('accept');
|
let accept = this.accept;
|
||||||
let extensions = this.get('extensions');
|
let extensions = this.extensions;
|
||||||
|
|
||||||
this._accept = (!isBlank(accept) && !isEmberArray(accept)) ? accept.split(',') : accept;
|
this._accept = (!isBlank(accept) && !isEmberArray(accept)) ? accept.split(',') : accept;
|
||||||
this._extensions = (!isBlank(extensions) && !isEmberArray(extensions)) ? extensions.split(',') : extensions;
|
this._extensions = (!isBlank(extensions) && !isEmberArray(extensions)) ? extensions.split(',') : extensions;
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
let listenTo = this.get('listenTo');
|
let listenTo = this.listenTo;
|
||||||
|
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
if (listenTo) {
|
if (listenTo) {
|
||||||
this.get('eventBus').unsubscribe(`${listenTo}:upload`);
|
this.eventBus.unsubscribe(`${listenTo}:upload`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
upload() {
|
upload() {
|
||||||
if (this.get('file')) {
|
if (this.file) {
|
||||||
this.generateRequest();
|
this.generateRequest();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -178,9 +178,9 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
generateRequest() {
|
generateRequest() {
|
||||||
let ajax = this.get('ajax');
|
let ajax = this.ajax;
|
||||||
let formData = this.get('formData');
|
let formData = this.formData;
|
||||||
let url = this.get('url');
|
let url = this.url;
|
||||||
|
|
||||||
this.uploadStarted();
|
this.uploadStarted();
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ export default Component.extend({
|
|||||||
let message;
|
let message;
|
||||||
|
|
||||||
if (isVersionMismatchError(error)) {
|
if (isVersionMismatchError(error)) {
|
||||||
this.get('notifications').showAPIError(error);
|
this.notifications.showAPIError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUnsupportedMediaTypeError(error)) {
|
if (isUnsupportedMediaTypeError(error)) {
|
||||||
|
@ -13,12 +13,12 @@ const FullScreenModalComponent = Component.extend({
|
|||||||
modifier: null,
|
modifier: null,
|
||||||
|
|
||||||
modalPath: computed('modal', function () {
|
modalPath: computed('modal', function () {
|
||||||
return `modal-${this.get('modal') || 'unknown'}`;
|
return `modal-${this.modal || 'unknown'}`;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
modalClasses: computed('modifiers', function () {
|
modalClasses: computed('modifiers', function () {
|
||||||
let modalClass = 'fullscreen-modal';
|
let modalClass = 'fullscreen-modal';
|
||||||
let modifiers = (this.get('modifier') || '').split(' ');
|
let modifiers = (this.modifier || '').split(' ');
|
||||||
let modalClasses = emberA([modalClass]);
|
let modalClasses = emberA([modalClass]);
|
||||||
|
|
||||||
modifiers.forEach((modifier) => {
|
modifiers.forEach((modifier) => {
|
||||||
@ -33,7 +33,7 @@ const FullScreenModalComponent = Component.extend({
|
|||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
run.schedule('afterRender', this, function () {
|
run.schedule('afterRender', this, function () {
|
||||||
this.get('dropdown').closeDropdowns();
|
this.dropdown.closeDropdowns();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -6,28 +6,28 @@ export default Component.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
update() {
|
update() {
|
||||||
let action = this.get('update');
|
let action = this.update;
|
||||||
if (action) {
|
if (action) {
|
||||||
action(...arguments);
|
action(...arguments);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
uploadStarted() {
|
uploadStarted() {
|
||||||
let action = this.get('uploadStarted');
|
let action = this.uploadStarted;
|
||||||
if (action) {
|
if (action) {
|
||||||
action(...arguments);
|
action(...arguments);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
uploadFinished() {
|
uploadFinished() {
|
||||||
let action = this.get('uploadFinished');
|
let action = this.uploadFinished;
|
||||||
if (action) {
|
if (action) {
|
||||||
action(...arguments);
|
action(...arguments);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
remove() {
|
remove() {
|
||||||
let action = this.get('remove');
|
let action = this.remove;
|
||||||
if (action) {
|
if (action) {
|
||||||
action();
|
action();
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ export default Component.extend({
|
|||||||
// TODO: this wouldn't be necessary if the server could accept direct
|
// TODO: this wouldn't be necessary if the server could accept direct
|
||||||
// file uploads
|
// file uploads
|
||||||
formData: computed('file', function () {
|
formData: computed('file', function () {
|
||||||
let file = this.get('file');
|
let file = this.file;
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
|
|
||||||
formData.append(this.paramName, file);
|
formData.append(this.paramName, file);
|
||||||
@ -78,13 +78,13 @@ export default Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
description: computed('text', 'altText', function () {
|
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 () {
|
progressStyle: computed('uploadPercentage', function () {
|
||||||
let percentage = this.get('uploadPercentage');
|
let percentage = this.uploadPercentage;
|
||||||
let width = '';
|
let width = '';
|
||||||
|
|
||||||
if (percentage > 0) {
|
if (percentage > 0) {
|
||||||
@ -99,14 +99,14 @@ export default Component.extend({
|
|||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
if (!this.get('accept')) {
|
if (!this.accept) {
|
||||||
this.set('accept', this.get('_defaultAccept'));
|
this.set('accept', this._defaultAccept);
|
||||||
}
|
}
|
||||||
if (!this.get('extensions')) {
|
if (!this.extensions) {
|
||||||
this.set('extensions', this.get('_defaultExtensions'));
|
this.set('extensions', this._defaultExtensions);
|
||||||
}
|
}
|
||||||
if (!this.get('uploadUrl')) {
|
if (!this.uploadUrl) {
|
||||||
this.set('uploadUrl', this.get('_defaultUploadUrl'));
|
this.set('uploadUrl', this._defaultUploadUrl);
|
||||||
}
|
}
|
||||||
if (!this.paramsHash) {
|
if (!this.paramsHash) {
|
||||||
this.set('paramsHash', this._defaultParamsHash);
|
this.set('paramsHash', this._defaultParamsHash);
|
||||||
@ -114,7 +114,7 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
let image = this.get('image');
|
let image = this.image;
|
||||||
this.set('url', image);
|
this.set('url', image);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
saveUrl() {
|
saveUrl() {
|
||||||
let url = this.get('url');
|
let url = this.url;
|
||||||
this.update(url);
|
this.update(url);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -233,11 +233,11 @@ export default Component.extend({
|
|||||||
let message;
|
let message;
|
||||||
|
|
||||||
if (isVersionMismatchError(error)) {
|
if (isVersionMismatchError(error)) {
|
||||||
this.get('notifications').showAPIError(error);
|
this.notifications.showAPIError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUnsupportedMediaTypeError(error)) {
|
if (isUnsupportedMediaTypeError(error)) {
|
||||||
let validExtensions = this.get('extensions').join(', .').toUpperCase();
|
let validExtensions = this.extensions.join(', .').toUpperCase();
|
||||||
validExtensions = `.${validExtensions}`;
|
validExtensions = `.${validExtensions}`;
|
||||||
|
|
||||||
message = `The image type you uploaded is not supported. Please use ${validExtensions}`;
|
message = `The image type you uploaded is not supported. Please use ${validExtensions}`;
|
||||||
@ -254,9 +254,9 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
generateRequest() {
|
generateRequest() {
|
||||||
let ajax = this.get('ajax');
|
let ajax = this.ajax;
|
||||||
let formData = this.get('formData');
|
let formData = this.formData;
|
||||||
let uploadUrl = this.get('uploadUrl');
|
let uploadUrl = this.uploadUrl;
|
||||||
// CASE: we want to upload an icon and we have to POST it to a different endpoint, expecially for icons
|
// 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}`;
|
let url = `${ghostPaths().apiRoot}${uploadUrl}`;
|
||||||
|
|
||||||
@ -294,7 +294,7 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_defaultValidator(file) {
|
_defaultValidator(file) {
|
||||||
let extensions = this.get('extensions');
|
let extensions = this.extensions;
|
||||||
let [, extension] = (/(?:\.([^.]+))?$/).exec(file.name);
|
let [, extension] = (/(?:\.([^.]+))?$/).exec(file.name);
|
||||||
|
|
||||||
if (!isEmberArray(extensions)) {
|
if (!isEmberArray(extensions)) {
|
||||||
|
@ -10,11 +10,11 @@ export default Component.extend({
|
|||||||
slowLoadTimeout: 200,
|
slowLoadTimeout: 200,
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this.get('startSpinnerTimeout').perform();
|
this.startSpinnerTimeout.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
startSpinnerTimeout: task(function* () {
|
startSpinnerTimeout: task(function* () {
|
||||||
yield timeout(this.get('slowLoadTimeout'));
|
yield timeout(this.slowLoadTimeout);
|
||||||
this.set('showSpinner', true);
|
this.set('showSpinner', true);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -6,7 +6,7 @@ export default Component.extend({
|
|||||||
ariaRole: 'main',
|
ariaRole: 'main',
|
||||||
|
|
||||||
mouseEnter() {
|
mouseEnter() {
|
||||||
let action = this.get('onMouseEnter');
|
let action = this.onMouseEnter;
|
||||||
if (action) {
|
if (action) {
|
||||||
action();
|
action();
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ export default Component.extend(ShortcutsMixin, {
|
|||||||
onSplitScreenToggle() {},
|
onSplitScreenToggle() {},
|
||||||
|
|
||||||
simpleMDEOptions: computed('options', function () {
|
simpleMDEOptions: computed('options', function () {
|
||||||
let options = this.get('options') || {};
|
let options = this.options || {};
|
||||||
let defaultOptions = {
|
let defaultOptions = {
|
||||||
// use our Showdown config with sanitization for previews
|
// use our Showdown config with sanitization for previews
|
||||||
previewRender(markdown) {
|
previewRender(markdown) {
|
||||||
@ -142,19 +142,19 @@ export default Component.extend(ShortcutsMixin, {
|
|||||||
|
|
||||||
let toolbar = defaultOptions.toolbar;
|
let toolbar = defaultOptions.toolbar;
|
||||||
|
|
||||||
if (!this.get('enableSideBySide')) {
|
if (!this.enableSideBySide) {
|
||||||
let sideBySide = toolbar.findBy('name', 'side-by-side');
|
let sideBySide = toolbar.findBy('name', 'side-by-side');
|
||||||
let index = toolbar.indexOf(sideBySide);
|
let index = toolbar.indexOf(sideBySide);
|
||||||
toolbar.splice(index, 1);
|
toolbar.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.get('enablePreview')) {
|
if (!this.enablePreview) {
|
||||||
let preview = toolbar.findBy('name', 'preview');
|
let preview = toolbar.findBy('name', 'preview');
|
||||||
let index = toolbar.indexOf(preview);
|
let index = toolbar.indexOf(preview);
|
||||||
toolbar.splice(index, 1);
|
toolbar.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.get('enableHemingway')) {
|
if (!this.enableHemingway) {
|
||||||
let hemingway = toolbar.findBy('name', 'hemingway');
|
let hemingway = toolbar.findBy('name', 'hemingway');
|
||||||
let index = toolbar.indexOf(hemingway);
|
let index = toolbar.indexOf(hemingway);
|
||||||
toolbar.splice(index, 1);
|
toolbar.splice(index, 1);
|
||||||
@ -193,13 +193,13 @@ export default Component.extend(ShortcutsMixin, {
|
|||||||
shortcuts[`${ctrlOrCmd}+shift+i`] = {action: 'openImageFileDialog'};
|
shortcuts[`${ctrlOrCmd}+shift+i`] = {action: 'openImageFileDialog'};
|
||||||
shortcuts['ctrl+alt+s'] = {action: 'toggleSpellcheck'};
|
shortcuts['ctrl+alt+s'] = {action: 'toggleSpellcheck'};
|
||||||
|
|
||||||
if (this.get('enablePreview')) {
|
if (this.enablePreview) {
|
||||||
shortcuts['ctrl+alt+r'] = {action: 'togglePreview'};
|
shortcuts['ctrl+alt+r'] = {action: 'togglePreview'};
|
||||||
}
|
}
|
||||||
if (this.get('enableSideBySide')) {
|
if (this.enableSideBySide) {
|
||||||
shortcuts['ctrl+alt+p'] = {action: 'toggleSplitScreen'};
|
shortcuts['ctrl+alt+p'] = {action: 'toggleSplitScreen'};
|
||||||
}
|
}
|
||||||
if (this.get('enableHemingway')) {
|
if (this.enableHemingway) {
|
||||||
shortcuts['ctrl+alt+h'] = {action: 'toggleHemingway'};
|
shortcuts['ctrl+alt+h'] = {action: 'toggleHemingway'};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ export default Component.extend(ShortcutsMixin, {
|
|||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
let uploadedImageUrls = this.get('uploadedImageUrls');
|
let uploadedImageUrls = this.uploadedImageUrls;
|
||||||
if (!isEmpty(uploadedImageUrls) && uploadedImageUrls !== this._uploadedImageUrls) {
|
if (!isEmpty(uploadedImageUrls) && uploadedImageUrls !== this._uploadedImageUrls) {
|
||||||
this._uploadedImageUrls = uploadedImageUrls;
|
this._uploadedImageUrls = uploadedImageUrls;
|
||||||
|
|
||||||
@ -224,16 +224,16 @@ export default Component.extend(ShortcutsMixin, {
|
|||||||
// focus the editor when the markdown value changes, this is necessary
|
// focus the editor when the markdown value changes, this is necessary
|
||||||
// because both the autofocus and markdown values can change without a
|
// because both the autofocus and markdown values can change without a
|
||||||
// re-render, eg. navigating from edit->new
|
// 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');
|
this.send('focusEditor');
|
||||||
}
|
}
|
||||||
|
|
||||||
// use internal values to avoid updating bound values
|
// use internal values to avoid updating bound values
|
||||||
if (!isEmpty(this.get('isFullScreen'))) {
|
if (!isEmpty(this.isFullScreen)) {
|
||||||
this.set('_isFullScreen', this.get('isFullScreen'));
|
this.set('_isFullScreen', this.isFullScreen);
|
||||||
}
|
}
|
||||||
if (!isEmpty(this.get('isSplitScreen'))) {
|
if (!isEmpty(this.isSplitScreen)) {
|
||||||
this.set('_isSplitScreen', this.get('isSplitScreen'));
|
this.set('_isSplitScreen', this.isSplitScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._updateButtonState();
|
this._updateButtonState();
|
||||||
@ -258,7 +258,7 @@ export default Component.extend(ShortcutsMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
if (this.get('_isSplitScreen')) {
|
if (this._isSplitScreen) {
|
||||||
this._disconnectSplitPreview();
|
this._disconnectSplitPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +348,7 @@ export default Component.extend(ShortcutsMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
toggleUnsplash() {
|
toggleUnsplash() {
|
||||||
if (this.get('_showUnsplash')) {
|
if (this._showUnsplash) {
|
||||||
return this.toggleProperty('_showUnsplash');
|
return this.toggleProperty('_showUnsplash');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,20 +378,20 @@ export default Component.extend(ShortcutsMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
toggleFullScreen() {
|
toggleFullScreen() {
|
||||||
let isFullScreen = !this.get('_isFullScreen');
|
let isFullScreen = !this._isFullScreen;
|
||||||
|
|
||||||
this.set('_isFullScreen', isFullScreen);
|
this.set('_isFullScreen', isFullScreen);
|
||||||
this._updateButtonState();
|
this._updateButtonState();
|
||||||
this.onFullScreenToggle(isFullScreen);
|
this.onFullScreenToggle(isFullScreen);
|
||||||
|
|
||||||
// leave split screen when exiting full screen mode
|
// leave split screen when exiting full screen mode
|
||||||
if (!isFullScreen && this.get('_isSplitScreen')) {
|
if (!isFullScreen && this._isSplitScreen) {
|
||||||
this.send('toggleSplitScreen');
|
this.send('toggleSplitScreen');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleSplitScreen() {
|
toggleSplitScreen() {
|
||||||
let isSplitScreen = !this.get('_isSplitScreen');
|
let isSplitScreen = !this._isSplitScreen;
|
||||||
let previewButton = this._editor.toolbarElements.preview;
|
let previewButton = this._editor.toolbarElements.preview;
|
||||||
|
|
||||||
this.set('_isSplitScreen', isSplitScreen);
|
this.set('_isSplitScreen', isSplitScreen);
|
||||||
@ -536,7 +536,7 @@ export default Component.extend(ShortcutsMixin, {
|
|||||||
let hemingwayButton = this._editor.toolbarElements.hemingway;
|
let hemingwayButton = this._editor.toolbarElements.hemingway;
|
||||||
|
|
||||||
if (sideBySideButton) {
|
if (sideBySideButton) {
|
||||||
if (this.get('_isSplitScreen')) {
|
if (this._isSplitScreen) {
|
||||||
sideBySideButton.classList.add('active');
|
sideBySideButton.classList.add('active');
|
||||||
} else {
|
} else {
|
||||||
sideBySideButton.classList.remove('active');
|
sideBySideButton.classList.remove('active');
|
||||||
@ -679,7 +679,7 @@ export default Component.extend(ShortcutsMixin, {
|
|||||||
|
|
||||||
cm.focus();
|
cm.focus();
|
||||||
|
|
||||||
this.get('notifications').showNotification(
|
this.notifications.showNotification(
|
||||||
htmlSafe(notificationText),
|
htmlSafe(notificationText),
|
||||||
{key: 'editor.hemingwaymode'}
|
{key: 'editor.hemingwaymode'}
|
||||||
);
|
);
|
||||||
|
@ -54,7 +54,7 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_setIconStyle() {
|
_setIconStyle() {
|
||||||
let icon = this.get('icon');
|
let icon = this.icon;
|
||||||
|
|
||||||
if (icon === this._icon) {
|
if (icon === this._icon) {
|
||||||
return;
|
return;
|
||||||
|
@ -19,7 +19,7 @@ export default Component.extend(ValidationState, {
|
|||||||
errors: readOnly('navItem.errors'),
|
errors: readOnly('navItem.errors'),
|
||||||
|
|
||||||
errorClass: computed('hasError', function () {
|
errorClass: computed('hasError', function () {
|
||||||
if (this.get('hasError')) {
|
if (this.hasError) {
|
||||||
return 'gh-blognav-item--error';
|
return 'gh-blognav-item--error';
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
@ -34,7 +34,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
this.$().on('animationend webkitAnimationEnd oanimationend MSAnimationEnd', (event) => {
|
this.$().on('animationend webkitAnimationEnd oanimationend MSAnimationEnd', (event) => {
|
||||||
if (event.originalEvent.animationName === 'fade-out') {
|
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: {
|
actions: {
|
||||||
closeNotification() {
|
closeNotification() {
|
||||||
this.get('notifications').closeNotification(this.get('message'));
|
this.notifications.closeNotification(this.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -49,7 +49,7 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
seoDescription: computed('post.scratch', 'metaDescriptionScratch', function () {
|
seoDescription: computed('post.scratch', 'metaDescriptionScratch', function () {
|
||||||
let metaDescription = this.get('metaDescriptionScratch') || '';
|
let metaDescription = this.metaDescriptionScratch || '';
|
||||||
let mobiledoc = this.get('post.scratch');
|
let mobiledoc = this.get('post.scratch');
|
||||||
let [markdownCard] = mobiledoc.cards;
|
let [markdownCard] = mobiledoc.cards;
|
||||||
let markdown = markdownCard && markdownCard[1] && markdownCard[1].markdown;
|
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
|
// can add throbbers only when the animation has finished
|
||||||
// TODO: use liquid-fire to handle PSM slide-in and replace tabs manager
|
// TODO: use liquid-fire to handle PSM slide-in and replace tabs manager
|
||||||
// with something more ember-like
|
// with something more ember-like
|
||||||
if (this.get('showSettingsMenu') && !this._showSettingsMenu) {
|
if (this.showSettingsMenu && !this._showSettingsMenu) {
|
||||||
this.get('showThrobbers').perform();
|
this.showThrobbers.perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
// fired when menu is closed
|
// fired when menu is closed
|
||||||
if (!this.get('showSettingsMenu') && this._showSettingsMenu) {
|
if (!this.showSettingsMenu && this._showSettingsMenu) {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
let errors = post.get('errors');
|
let errors = post.get('errors');
|
||||||
|
|
||||||
// reset the publish date if it has an error
|
// reset the publish date if it has an error
|
||||||
@ -109,7 +109,7 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
this.set('_showThrobbers', false);
|
this.set('_showThrobbers', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._showSettingsMenu = this.get('showSettingsMenu');
|
this._showSettingsMenu = this.showSettingsMenu;
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
@ -130,7 +130,7 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
this.set('subview', null);
|
this.set('subview', null);
|
||||||
this.get('showThrobbers').perform();
|
this.showThrobbers.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
discardEnter() {
|
discardEnter() {
|
||||||
@ -146,9 +146,9 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get('savePost').perform().catch((error) => {
|
this.savePost.perform().catch((error) => {
|
||||||
this.showError(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
|
* triggered by user manually changing slug
|
||||||
*/
|
*/
|
||||||
updateSlug(newSlug) {
|
updateSlug(newSlug) {
|
||||||
return this.get('updateSlug')
|
return this.updateSlug
|
||||||
.perform(newSlug)
|
.perform(newSlug)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.showError(error);
|
this.showError(error);
|
||||||
this.get('post').rollbackAttributes();
|
this.post.rollbackAttributes();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setPublishedAtBlogDate(date) {
|
setPublishedAtBlogDate(date) {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
let dateString = moment(date).format('YYYY-MM-DD');
|
let dateString = moment(date).format('YYYY-MM-DD');
|
||||||
|
|
||||||
post.get('errors').remove('publishedAtBlogDate');
|
post.get('errors').remove('publishedAtBlogDate');
|
||||||
@ -174,12 +174,12 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
post.validate({property: 'publishedAtBlog'});
|
post.validate({property: 'publishedAtBlog'});
|
||||||
} else {
|
} else {
|
||||||
post.set('publishedAtBlogDate', dateString);
|
post.set('publishedAtBlogDate', dateString);
|
||||||
return this.get('savePost').perform();
|
return this.savePost.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setPublishedAtBlogTime(time) {
|
setPublishedAtBlogTime(time) {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
|
|
||||||
post.get('errors').remove('publishedAtBlogDate');
|
post.get('errors').remove('publishedAtBlogDate');
|
||||||
|
|
||||||
@ -187,12 +187,12 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
post.validate({property: 'publishedAtBlog'});
|
post.validate({property: 'publishedAtBlog'});
|
||||||
} else {
|
} else {
|
||||||
post.set('publishedAtBlogTime', time);
|
post.set('publishedAtBlogTime', time);
|
||||||
return this.get('savePost').perform();
|
return this.savePost.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setCustomExcerpt(excerpt) {
|
setCustomExcerpt(excerpt) {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
let currentExcerpt = post.get('customExcerpt');
|
let currentExcerpt = post.get('customExcerpt');
|
||||||
|
|
||||||
if (excerpt === currentExcerpt) {
|
if (excerpt === currentExcerpt) {
|
||||||
@ -201,11 +201,11 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
|
|
||||||
post.set('customExcerpt', excerpt);
|
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) {
|
setHeaderInjection(code) {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
let currentCode = post.get('codeinjectionHead');
|
let currentCode = post.get('codeinjectionHead');
|
||||||
|
|
||||||
if (code === currentCode) {
|
if (code === currentCode) {
|
||||||
@ -214,11 +214,11 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
|
|
||||||
post.set('codeinjectionHead', code);
|
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) {
|
setFooterInjection(code) {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
let currentCode = post.get('codeinjectionFoot');
|
let currentCode = post.get('codeinjectionFoot');
|
||||||
|
|
||||||
if (code === currentCode) {
|
if (code === currentCode) {
|
||||||
@ -227,12 +227,12 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
|
|
||||||
post.set('codeinjectionFoot', code);
|
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) {
|
setMetaTitle(metaTitle) {
|
||||||
// Grab the post and current stored meta title
|
// Grab the post and current stored meta title
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
let currentTitle = post.get('metaTitle');
|
let currentTitle = post.get('metaTitle');
|
||||||
|
|
||||||
// If the title entered matches the stored meta title, do nothing
|
// If the title entered matches the stored meta title, do nothing
|
||||||
@ -249,13 +249,13 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.get('savePost').perform();
|
return this.savePost.perform();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setMetaDescription(metaDescription) {
|
setMetaDescription(metaDescription) {
|
||||||
// Grab the post and current stored meta description
|
// Grab the post and current stored meta description
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
let currentDescription = post.get('metaDescription');
|
let currentDescription = post.get('metaDescription');
|
||||||
|
|
||||||
// If the title entered matches the stored meta title, do nothing
|
// If the title entered matches the stored meta title, do nothing
|
||||||
@ -272,13 +272,13 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.get('savePost').perform();
|
return this.savePost.perform();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setOgTitle(ogTitle) {
|
setOgTitle(ogTitle) {
|
||||||
// Grab the post and current stored facebook title
|
// Grab the post and current stored facebook title
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
let currentTitle = post.get('ogTitle');
|
let currentTitle = post.get('ogTitle');
|
||||||
|
|
||||||
// If the title entered matches the stored facebook title, do nothing
|
// If the title entered matches the stored facebook title, do nothing
|
||||||
@ -295,13 +295,13 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.get('savePost').perform();
|
return this.savePost.perform();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setOgDescription(ogDescription) {
|
setOgDescription(ogDescription) {
|
||||||
// Grab the post and current stored facebook description
|
// Grab the post and current stored facebook description
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
let currentDescription = post.get('ogDescription');
|
let currentDescription = post.get('ogDescription');
|
||||||
|
|
||||||
// If the title entered matches the stored facebook description, do nothing
|
// If the title entered matches the stored facebook description, do nothing
|
||||||
@ -318,13 +318,13 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.get('savePost').perform();
|
return this.savePost.perform();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setTwitterTitle(twitterTitle) {
|
setTwitterTitle(twitterTitle) {
|
||||||
// Grab the post and current stored twitter title
|
// Grab the post and current stored twitter title
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
let currentTitle = post.get('twitterTitle');
|
let currentTitle = post.get('twitterTitle');
|
||||||
|
|
||||||
// If the title entered matches the stored twitter title, do nothing
|
// If the title entered matches the stored twitter title, do nothing
|
||||||
@ -341,13 +341,13 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.get('savePost').perform();
|
return this.savePost.perform();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setTwitterDescription(twitterDescription) {
|
setTwitterDescription(twitterDescription) {
|
||||||
// Grab the post and current stored twitter description
|
// Grab the post and current stored twitter description
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
let currentDescription = post.get('twitterDescription');
|
let currentDescription = post.get('twitterDescription');
|
||||||
|
|
||||||
// If the description entered matches the stored twitter description, do nothing
|
// If the description entered matches the stored twitter description, do nothing
|
||||||
@ -364,7 +364,7 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.get('savePost').perform();
|
return this.savePost.perform();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -375,9 +375,9 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get('savePost').perform().catch((error) => {
|
this.savePost.perform().catch((error) => {
|
||||||
this.showError(error);
|
this.showError(error);
|
||||||
this.get('post').rollbackAttributes();
|
this.post.rollbackAttributes();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -388,9 +388,9 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get('savePost').perform().catch((error) => {
|
this.savePost.perform().catch((error) => {
|
||||||
this.showError(error);
|
this.showError(error);
|
||||||
this.get('post').rollbackAttributes();
|
this.post.rollbackAttributes();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -401,9 +401,9 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get('savePost').perform().catch((error) => {
|
this.savePost.perform().catch((error) => {
|
||||||
this.showError(error);
|
this.showError(error);
|
||||||
this.get('post').rollbackAttributes();
|
this.post.rollbackAttributes();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -414,9 +414,9 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get('savePost').perform().catch((error) => {
|
this.savePost.perform().catch((error) => {
|
||||||
this.showError(error);
|
this.showError(error);
|
||||||
this.get('post').rollbackAttributes();
|
this.post.rollbackAttributes();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -427,9 +427,9 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get('savePost').perform().catch((error) => {
|
this.savePost.perform().catch((error) => {
|
||||||
this.showError(error);
|
this.showError(error);
|
||||||
this.get('post').rollbackAttributes();
|
this.post.rollbackAttributes();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -440,14 +440,14 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get('savePost').perform().catch((error) => {
|
this.savePost.perform().catch((error) => {
|
||||||
this.showError(error);
|
this.showError(error);
|
||||||
this.get('post').rollbackAttributes();
|
this.post.rollbackAttributes();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
changeAuthors(newAuthors) {
|
changeAuthors(newAuthors) {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
|
|
||||||
// return if nothing changed
|
// return if nothing changed
|
||||||
if (newAuthors.mapBy('id').join() === post.get('authors').mapBy('id').join()) {
|
if (newAuthors.mapBy('id').join() === post.get('authors').mapBy('id').join()) {
|
||||||
@ -462,15 +462,15 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get('savePost').perform().catch((error) => {
|
this.savePost.perform().catch((error) => {
|
||||||
this.showError(error);
|
this.showError(error);
|
||||||
post.rollbackAttributes();
|
post.rollbackAttributes();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
deletePost() {
|
deletePost() {
|
||||||
if (this.get('deletePost')) {
|
if (this.deletePost) {
|
||||||
this.get('deletePost')();
|
this.deletePost();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -483,7 +483,7 @@ export default Component.extend(SettingsMenuMixin, {
|
|||||||
showError(error) {
|
showError(error) {
|
||||||
// TODO: remove null check once ValidationEngine has been removed
|
// TODO: remove null check once ValidationEngine has been removed
|
||||||
if (error) {
|
if (error) {
|
||||||
this.get('notifications').showAPIError(error);
|
this.notifications.showAPIError(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -46,17 +46,17 @@ export default Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
if (this.get('active')) {
|
if (this.active) {
|
||||||
this.scrollIntoView();
|
this.scrollIntoView();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
click() {
|
click() {
|
||||||
this.onClick(this.get('post'));
|
this.onClick(this.post);
|
||||||
},
|
},
|
||||||
|
|
||||||
doubleClick() {
|
doubleClick() {
|
||||||
this.onDoubleClick(this.get('post'));
|
this.onDoubleClick(this.post);
|
||||||
},
|
},
|
||||||
|
|
||||||
scrollIntoView() {
|
scrollIntoView() {
|
||||||
|
@ -54,7 +54,7 @@ export default Component.extend({
|
|||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
if (this.get('config.useGravatar')) {
|
if (this.get('config.useGravatar')) {
|
||||||
this.get('setGravatar').perform();
|
this.setGravatar.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -119,12 +119,12 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setGravatar: task(function* () {
|
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 || '')) {
|
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`;
|
let gravatarUrl = `//www.gravatar.com/avatar/${md5(email)}?s=${size}&d=404`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -158,7 +158,7 @@ export default Component.extend({
|
|||||||
let fileName = data.files[0].name;
|
let fileName = data.files[0].name;
|
||||||
|
|
||||||
if ((/\.(gif|jpe?g|png|svg?z)$/i).test(fileName)) {
|
if ((/\.(gif|jpe?g|png|svg?z)$/i).test(fileName)) {
|
||||||
let action = this.get('setImage');
|
let action = this.setImage;
|
||||||
if (action) {
|
if (action) {
|
||||||
action(data);
|
action(data);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ export default Component.extend({
|
|||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
let percentage = this.get('percentage');
|
let percentage = this.percentage;
|
||||||
let width = (percentage > 0) ? `${percentage}%` : '0';
|
let width = (percentage > 0) ? `${percentage}%` : '0';
|
||||||
|
|
||||||
this.set('progressStyle', htmlSafe(`width: ${width}`));
|
this.set('progressStyle', htmlSafe(`width: ${width}`));
|
||||||
|
@ -18,7 +18,7 @@ export default Component.extend({
|
|||||||
updateAuthors() {},
|
updateAuthors() {},
|
||||||
|
|
||||||
availableAuthorNames: computed('availableAuthors.@each.name', function () {
|
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() {
|
init() {
|
||||||
|
@ -38,7 +38,7 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
hideCreateOptionOnMatchingTag(term) {
|
hideCreateOptionOnMatchingTag(term) {
|
||||||
return !this.get('availableTagNames').includes(term.toLowerCase());
|
return !this.availableTagNames.includes(term.toLowerCase());
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTags(newTags) {
|
updateTags(newTags) {
|
||||||
|
@ -41,7 +41,7 @@ export default Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
selectedTemplate: computed('post.customTemplate', 'customTemplates.[]', function () {
|
selectedTemplate: computed('post.customTemplate', 'customTemplates.[]', function () {
|
||||||
let templates = this.get('customTemplates');
|
let templates = this.customTemplates;
|
||||||
let filename = this.get('post.customTemplate');
|
let filename = this.get('post.customTemplate');
|
||||||
|
|
||||||
return templates.findBy('filename', filename);
|
return templates.findBy('filename', filename);
|
||||||
@ -50,7 +50,7 @@ export default Component.extend({
|
|||||||
// hooks
|
// hooks
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
this.get('loadActiveTheme').perform();
|
this.loadActiveTheme.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
@ -61,7 +61,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
// tasks
|
// tasks
|
||||||
loadActiveTheme: task(function* () {
|
loadActiveTheme: task(function* () {
|
||||||
let store = this.get('store');
|
let store = this.store;
|
||||||
let themes = yield store.peekAll('theme');
|
let themes = yield store.peekAll('theme');
|
||||||
|
|
||||||
if (isEmpty(themes)) {
|
if (isEmpty(themes)) {
|
||||||
|
@ -14,19 +14,19 @@ export default Component.extend({
|
|||||||
'data-test-publishmenu-draft': true,
|
'data-test-publishmenu-draft': true,
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this.get('post').set('publishedAtBlogTZ', this.get('post.publishedAtUTC'));
|
this.post.set('publishedAtBlogTZ', this.get('post.publishedAtUTC'));
|
||||||
this.send('setSaveType', 'publish');
|
this.send('setSaveType', 'publish');
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
setSaveType(type) {
|
setSaveType(type) {
|
||||||
if (this.get('saveType') !== type) {
|
if (this.saveType !== type) {
|
||||||
let hasDateError = !isEmpty(this.get('post.errors').errorsFor('publishedAtBlogDate'));
|
let hasDateError = !isEmpty(this.get('post.errors').errorsFor('publishedAtBlogDate'));
|
||||||
let hasTimeError = !isEmpty(this.get('post.errors').errorsFor('publishedAtBlogTime'));
|
let hasTimeError = !isEmpty(this.get('post.errors').errorsFor('publishedAtBlogTime'));
|
||||||
let minDate = this._getMinDate();
|
let minDate = this._getMinDate();
|
||||||
|
|
||||||
this.set('_minDate', minDate);
|
this.set('_minDate', minDate);
|
||||||
this.get('setSaveType')(type);
|
this.setSaveType(type);
|
||||||
|
|
||||||
// when publish: switch to now to avoid validation errors
|
// when publish: switch to now to avoid validation errors
|
||||||
// when schedule: switch to last valid or new minimum scheduled date
|
// 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._publishedAtBlogTZ = this.get('post.publishedAtUTC');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get('post').set('publishedAtBlogTZ', this.get('post.publishedAtUTC'));
|
this.post.set('publishedAtBlogTZ', this.get('post.publishedAtUTC'));
|
||||||
} else {
|
} else {
|
||||||
if (!this._publishedAtBlogTZ || moment(this._publishedAtBlogTZ).isBefore(minDate)) {
|
if (!this._publishedAtBlogTZ || moment(this._publishedAtBlogTZ).isBefore(minDate)) {
|
||||||
this.get('post').set('publishedAtBlogTZ', minDate);
|
this.post.set('publishedAtBlogTZ', minDate);
|
||||||
} else {
|
} else {
|
||||||
this.get('post').set('publishedAtBlogTZ', this._publishedAtBlogTZ);
|
this.post.set('publishedAtBlogTZ', this._publishedAtBlogTZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get('post').validate();
|
this.post.validate();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setDate(date) {
|
setDate(date) {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
let dateString = moment(date).format('YYYY-MM-DD');
|
let dateString = moment(date).format('YYYY-MM-DD');
|
||||||
|
|
||||||
post.set('publishedAtBlogDate', dateString);
|
post.set('publishedAtBlogDate', dateString);
|
||||||
@ -59,7 +59,7 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setTime(time) {
|
setTime(time) {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
|
|
||||||
post.set('publishedAtBlogTime', time);
|
post.set('publishedAtBlogTime', time);
|
||||||
return post.validate();
|
return post.validate();
|
||||||
|
@ -5,6 +5,6 @@ export default Component.extend({
|
|||||||
'data-test-publishmenu-published': true,
|
'data-test-publishmenu-published': true,
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this.get('setSaveType')('publish');
|
this.setSaveType('publish');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -29,29 +29,29 @@ export default Component.extend({
|
|||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this.set('_minDate', new Date());
|
this.set('_minDate', new Date());
|
||||||
this.get('setSaveType')('schedule');
|
this.setSaveType('schedule');
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
setSaveType(type) {
|
setSaveType(type) {
|
||||||
if (this.get('saveType') !== type) {
|
if (this.saveType !== type) {
|
||||||
this.set('_minDate', new Date());
|
this.set('_minDate', new Date());
|
||||||
this.get('setSaveType')(type);
|
this.setSaveType(type);
|
||||||
|
|
||||||
// when draft switch to now to avoid validation errors
|
// when draft switch to now to avoid validation errors
|
||||||
// when schedule switch back to saved date to avoid unnecessary re-scheduling
|
// when schedule switch back to saved date to avoid unnecessary re-scheduling
|
||||||
if (type === 'draft') {
|
if (type === 'draft') {
|
||||||
this.get('post').set('publishedAtBlogTZ', new Date());
|
this.post.set('publishedAtBlogTZ', new Date());
|
||||||
} else {
|
} 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) {
|
setDate(date) {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
let dateString = moment(date).format('YYYY-MM-DD');
|
let dateString = moment(date).format('YYYY-MM-DD');
|
||||||
|
|
||||||
post.set('publishedAtBlogDate', dateString);
|
post.set('publishedAtBlogDate', dateString);
|
||||||
@ -59,9 +59,9 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setTime(time) {
|
setTime(time) {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
|
|
||||||
if (!this.get('isClosing')) {
|
if (!this.isClosing) {
|
||||||
post.set('publishedAtBlogTime', time);
|
post.set('publishedAtBlogTime', time);
|
||||||
return post.validate();
|
return post.validate();
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ export default Component.extend({
|
|||||||
forcePublishedMenu: reads('post.pastScheduledTime'),
|
forcePublishedMenu: reads('post.pastScheduledTime'),
|
||||||
|
|
||||||
postState: computed('post.{isPublished,isScheduled}', 'forcePublishedMenu', function () {
|
postState: computed('post.{isPublished,isScheduled}', 'forcePublishedMenu', function () {
|
||||||
if (this.get('forcePublishedMenu') || this.get('post.isPublished')) {
|
if (this.forcePublishedMenu || this.get('post.isPublished')) {
|
||||||
return 'published';
|
return 'published';
|
||||||
} else if (this.get('post.isScheduled')) {
|
} else if (this.get('post.isScheduled')) {
|
||||||
return 'scheduled';
|
return 'scheduled';
|
||||||
@ -33,7 +33,7 @@ export default Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
triggerText: computed('postState', function () {
|
triggerText: computed('postState', function () {
|
||||||
let state = this.get('postState');
|
let state = this.postState;
|
||||||
|
|
||||||
if (state === 'published') {
|
if (state === 'published') {
|
||||||
return 'Update';
|
return 'Update';
|
||||||
@ -45,8 +45,8 @@ export default Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
_runningText: computed('postState', 'saveType', function () {
|
_runningText: computed('postState', 'saveType', function () {
|
||||||
let saveType = this.get('saveType');
|
let saveType = this.saveType;
|
||||||
let postState = this.get('postState');
|
let postState = this.postState;
|
||||||
let runningText;
|
let runningText;
|
||||||
|
|
||||||
if (postState === 'draft') {
|
if (postState === 'draft') {
|
||||||
@ -65,8 +65,8 @@ export default Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
buttonText: computed('postState', 'saveType', function () {
|
buttonText: computed('postState', 'saveType', function () {
|
||||||
let saveType = this.get('saveType');
|
let saveType = this.saveType;
|
||||||
let postState = this.get('postState');
|
let postState = this.postState;
|
||||||
let buttonText;
|
let buttonText;
|
||||||
|
|
||||||
if (postState === 'draft') {
|
if (postState === 'draft') {
|
||||||
@ -85,8 +85,8 @@ export default Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
successText: computed('_previousStatus', 'postState', function () {
|
successText: computed('_previousStatus', 'postState', function () {
|
||||||
let postState = this.get('postState');
|
let postState = this.postState;
|
||||||
let previousStatus = this.get('_previousStatus');
|
let previousStatus = this._previousStatus;
|
||||||
let buttonText;
|
let buttonText;
|
||||||
|
|
||||||
if (previousStatus === 'draft') {
|
if (previousStatus === 'draft') {
|
||||||
@ -112,7 +112,7 @@ export default Component.extend({
|
|||||||
// calls to `setSaveType` due to the component re-rendering
|
// calls to `setSaveType` due to the component re-rendering
|
||||||
// TODO: we should have a better way of dealing with this where we don't
|
// 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
|
// rely on the side-effect of component rendering calling setSaveType
|
||||||
let postStatus = this.get('postStatus');
|
let postStatus = this.postStatus;
|
||||||
if (postStatus !== this._postStatus) {
|
if (postStatus !== this._postStatus) {
|
||||||
if (this.get('saveTask.isRunning')) {
|
if (this.get('saveTask.isRunning')) {
|
||||||
this.get('saveTask.last').then(() => {
|
this.get('saveTask.last').then(() => {
|
||||||
@ -123,12 +123,12 @@ export default Component.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._postStatus = this.get('postStatus');
|
this._postStatus = this.postStatus;
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
setSaveType(saveType) {
|
setSaveType(saveType) {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
|
|
||||||
this.set('saveType', saveType);
|
this.set('saveType', saveType);
|
||||||
|
|
||||||
@ -145,13 +145,13 @@ export default Component.extend({
|
|||||||
this._cachePublishedAtBlogTZ();
|
this._cachePublishedAtBlogTZ();
|
||||||
this.set('isClosing', false);
|
this.set('isClosing', false);
|
||||||
this.get('post.errors').clear();
|
this.get('post.errors').clear();
|
||||||
if (this.get('onOpen')) {
|
if (this.onOpen) {
|
||||||
this.get('onOpen')();
|
this.onOpen();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
close(dropdown, e) {
|
close(dropdown, e) {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
|
|
||||||
// don't close the menu if the datepicker popup is clicked
|
// don't close the menu if the datepicker popup is clicked
|
||||||
if (e && $(e.target).closest('.ember-power-datepicker-content').length) {
|
if (e && $(e.target).closest('.ember-power-datepicker-content').length) {
|
||||||
@ -163,8 +163,8 @@ export default Component.extend({
|
|||||||
post.set('statusScratch', null);
|
post.set('statusScratch', null);
|
||||||
post.validate();
|
post.validate();
|
||||||
|
|
||||||
if (this.get('onClose')) {
|
if (this.onClose) {
|
||||||
this.get('onClose')();
|
this.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set('isClosing', true);
|
this.set('isClosing', true);
|
||||||
@ -176,16 +176,16 @@ export default Component.extend({
|
|||||||
save: task(function* () {
|
save: task(function* () {
|
||||||
// runningText needs to be declared before the other states change during the
|
// runningText needs to be declared before the other states change during the
|
||||||
// save action.
|
// save action.
|
||||||
this.set('runningText', this.get('_runningText'));
|
this.set('runningText', this._runningText);
|
||||||
this.set('_previousStatus', this.get('post.status'));
|
this.set('_previousStatus', this.get('post.status'));
|
||||||
this.get('setSaveType')(this.get('saveType'));
|
this.setSaveType(this.saveType);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// validate publishedAtBlog first to avoid an alert for displayed errors
|
// 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
|
// actual save will show alert for other failed validations
|
||||||
let post = yield this.get('saveTask').perform();
|
let post = yield this.saveTask.perform();
|
||||||
|
|
||||||
this._cachePublishedAtBlogTZ();
|
this._cachePublishedAtBlogTZ();
|
||||||
return post;
|
return post;
|
||||||
@ -204,6 +204,6 @@ export default Component.extend({
|
|||||||
// when closing the menu we reset the publishedAtBlogTZ date so that the
|
// 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
|
// unsaved changes made to the scheduled date aren't reflected in the PSM
|
||||||
_resetPublishedAtBlogTZ() {
|
_resetPublishedAtBlogTZ() {
|
||||||
this.get('post').set('publishedAtBlogTZ', this._publishedAtBlogTZ);
|
this.post.set('publishedAtBlogTZ', this._publishedAtBlogTZ);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -8,7 +8,7 @@ export default Component.extend(InViewportMixin, {
|
|||||||
registerElement() {},
|
registerElement() {},
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
let offset = this.get('triggerOffset') || {};
|
let offset = this.triggerOffset || {};
|
||||||
|
|
||||||
// if triggerOffset is a number we use it for all dimensions
|
// if triggerOffset is a number we use it for all dimensions
|
||||||
if (typeof offset === 'number') {
|
if (typeof offset === 'number') {
|
||||||
|
@ -19,7 +19,7 @@ export default Component.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get('select').actions.search(term);
|
this.select.actions.search(term);
|
||||||
},
|
},
|
||||||
|
|
||||||
focusInput() {
|
focusInput() {
|
||||||
@ -31,7 +31,7 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleKeydown(e) {
|
handleKeydown(e) {
|
||||||
let select = this.get('select');
|
let select = this.select;
|
||||||
|
|
||||||
// TODO: remove keycode check once EPS is updated to 1.0
|
// TODO: remove keycode check once EPS is updated to 1.0
|
||||||
if (!select.isOpen || e.keyCode === 32) {
|
if (!select.isOpen || e.keyCode === 32) {
|
||||||
|
@ -9,12 +9,12 @@ import {task, timeout, waitForProperty} from 'ember-concurrency';
|
|||||||
|
|
||||||
export function computedGroup(category) {
|
export function computedGroup(category) {
|
||||||
return computed('content', 'currentSearch', function () {
|
return computed('content', 'currentSearch', function () {
|
||||||
if (!this.get('currentSearch') || !this.get('content')) {
|
if (!this.currentSearch || !this.content) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.get('content').filter((item) => {
|
return this.content.filter((item) => {
|
||||||
let search = this.get('currentSearch').toString().toLowerCase();
|
let search = this.currentSearch.toString().toLowerCase();
|
||||||
|
|
||||||
return (item.category === category) && (item.title.toString().toLowerCase().indexOf(search) >= 0);
|
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 () {
|
groupedContent: computed('posts', 'pages', 'users', 'tags', function () {
|
||||||
let groups = [];
|
let groups = [];
|
||||||
|
|
||||||
if (!isEmpty(this.get('posts'))) {
|
if (!isEmpty(this.posts)) {
|
||||||
groups.pushObject({groupName: 'Posts', options: this.get('posts')});
|
groups.pushObject({groupName: 'Posts', options: this.posts});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEmpty(this.get('pages'))) {
|
if (!isEmpty(this.pages)) {
|
||||||
groups.pushObject({groupName: 'Pages', options: this.get('pages')});
|
groups.pushObject({groupName: 'Pages', options: this.pages});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEmpty(this.get('users'))) {
|
if (!isEmpty(this.users)) {
|
||||||
groups.pushObject({groupName: 'Users', options: this.get('users')});
|
groups.pushObject({groupName: 'Users', options: this.users});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEmpty(this.get('tags'))) {
|
if (!isEmpty(this.tags)) {
|
||||||
groups.pushObject({groupName: 'Tags', options: this.get('tags')});
|
groups.pushObject({groupName: 'Tags', options: this.tags});
|
||||||
}
|
}
|
||||||
|
|
||||||
return groups;
|
return groups;
|
||||||
@ -73,22 +73,22 @@ export default Component.extend({
|
|||||||
|
|
||||||
if (selected.category === 'Posts') {
|
if (selected.category === 'Posts') {
|
||||||
let id = selected.id.replace('post.', '');
|
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') {
|
if (selected.category === 'Pages') {
|
||||||
let id = selected.id.replace('page.', '');
|
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') {
|
if (selected.category === 'Users') {
|
||||||
let id = selected.id.replace('user.', '');
|
let id = selected.id.replace('user.', '');
|
||||||
this.get('router').transitionTo('staff.user', id);
|
this.router.transitionTo('staff.user', id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selected.category === 'Tags') {
|
if (selected.category === 'Tags') {
|
||||||
let id = selected.id.replace('tag.', '');
|
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
|
// set dependent CP term and re-calculate CP
|
||||||
this.set('currentSearch', term);
|
this.set('currentSearch', term);
|
||||||
return this.get('groupedContent');
|
return this.groupedContent;
|
||||||
}).restartable(),
|
}).restartable(),
|
||||||
|
|
||||||
refreshContent: task(function* () {
|
refreshContent: task(function* () {
|
||||||
let promises = [];
|
let promises = [];
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
let contentExpiresAt = this.get('contentExpiresAt');
|
let contentExpiresAt = this.contentExpiresAt;
|
||||||
|
|
||||||
if (contentExpiresAt > now) {
|
if (contentExpiresAt > now) {
|
||||||
return true;
|
return true;
|
||||||
@ -148,75 +148,75 @@ export default Component.extend({
|
|||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
let contentExpiry = this.get('contentExpiry');
|
let contentExpiry = this.contentExpiry;
|
||||||
this.set('contentExpiresAt', new Date(now.getTime() + contentExpiry));
|
this.set('contentExpiresAt', new Date(now.getTime() + contentExpiry));
|
||||||
}).drop(),
|
}).drop(),
|
||||||
|
|
||||||
_loadPosts() {
|
_loadPosts() {
|
||||||
let store = this.get('store');
|
let store = this.store;
|
||||||
let postsUrl = `${store.adapterFor('post').urlForQuery({}, 'post')}/`;
|
let postsUrl = `${store.adapterFor('post').urlForQuery({}, 'post')}/`;
|
||||||
let postsQuery = {fields: 'id,title,page', limit: 'all', status: 'all'};
|
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 => ({
|
content.pushObjects(posts.posts.map(post => ({
|
||||||
id: `post.${post.id}`,
|
id: `post.${post.id}`,
|
||||||
title: post.title,
|
title: post.title,
|
||||||
category: 'Posts'
|
category: 'Posts'
|
||||||
})));
|
})));
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.get('notifications').showAPIError(error, {key: 'search.loadPosts.error'});
|
this.notifications.showAPIError(error, {key: 'search.loadPosts.error'});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_loadPages() {
|
_loadPages() {
|
||||||
let store = this.get('store');
|
let store = this.store;
|
||||||
let pagesUrl = `${store.adapterFor('page').urlForQuery({}, 'page')}/`;
|
let pagesUrl = `${store.adapterFor('page').urlForQuery({}, 'page')}/`;
|
||||||
let pagesQuery = {fields: 'id,title,page', limit: 'all', status: 'all'};
|
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 => ({
|
content.pushObjects(pages.pages.map(page => ({
|
||||||
id: `page.${page.id}`,
|
id: `page.${page.id}`,
|
||||||
title: page.title,
|
title: page.title,
|
||||||
category: 'Pages'
|
category: 'Pages'
|
||||||
})));
|
})));
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.get('notifications').showAPIError(error, {key: 'search.loadPosts.error'});
|
this.notifications.showAPIError(error, {key: 'search.loadPosts.error'});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_loadUsers() {
|
_loadUsers() {
|
||||||
let store = this.get('store');
|
let store = this.store;
|
||||||
let usersUrl = `${store.adapterFor('user').urlForQuery({}, 'user')}/`;
|
let usersUrl = `${store.adapterFor('user').urlForQuery({}, 'user')}/`;
|
||||||
let usersQuery = {fields: 'name,slug', limit: 'all'};
|
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 => ({
|
content.pushObjects(users.users.map(user => ({
|
||||||
id: `user.${user.slug}`,
|
id: `user.${user.slug}`,
|
||||||
title: user.name,
|
title: user.name,
|
||||||
category: 'Users'
|
category: 'Users'
|
||||||
})));
|
})));
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.get('notifications').showAPIError(error, {key: 'search.loadUsers.error'});
|
this.notifications.showAPIError(error, {key: 'search.loadUsers.error'});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_loadTags() {
|
_loadTags() {
|
||||||
let store = this.get('store');
|
let store = this.store;
|
||||||
let tagsUrl = `${store.adapterFor('tag').urlForQuery({}, 'tag')}/`;
|
let tagsUrl = `${store.adapterFor('tag').urlForQuery({}, 'tag')}/`;
|
||||||
let tagsQuery = {fields: 'name,slug', limit: 'all'};
|
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 => ({
|
content.pushObjects(tags.tags.map(tag => ({
|
||||||
id: `tag.${tag.slug}`,
|
id: `tag.${tag.slug}`,
|
||||||
title: tag.name,
|
title: tag.name,
|
||||||
category: 'Tags'
|
category: 'Tags'
|
||||||
})));
|
})));
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.get('notifications').showAPIError(error, {key: 'search.loadTags.error'});
|
this.notifications.showAPIError(error, {key: 'search.loadTags.error'});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@ export default TextArea.extend({
|
|||||||
// https://github.com/sparksuite/simplemde-markdown-editor#configuration
|
// https://github.com/sparksuite/simplemde-markdown-editor#configuration
|
||||||
defaultOptions: computed(function () {
|
defaultOptions: computed(function () {
|
||||||
return {
|
return {
|
||||||
autofocus: this.get('autofocus'),
|
autofocus: this.autofocus,
|
||||||
indentWithTabs: false,
|
indentWithTabs: false,
|
||||||
placeholder: this.get('placeholder'),
|
placeholder: this.placeholder,
|
||||||
tabSize: 4
|
tabSize: 4
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
@ -38,7 +38,7 @@ export default TextArea.extend({
|
|||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
if (isEmpty(this.get('options'))) {
|
if (isEmpty(this.options)) {
|
||||||
this.set('options', {});
|
this.set('options', {});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -53,9 +53,9 @@ export default TextArea.extend({
|
|||||||
|
|
||||||
// compare values before forcing a content reset to avoid clobbering
|
// compare values before forcing a content reset to avoid clobbering
|
||||||
// the undo behaviour
|
// the undo behaviour
|
||||||
if (this.get('value') !== this._editor.value()) {
|
if (this.value !== this._editor.value()) {
|
||||||
let cursor = this._editor.codemirror.getDoc().getCursor();
|
let cursor = this._editor.codemirror.getDoc().getCursor();
|
||||||
this._editor.value(this.get('value'));
|
this._editor.value(this.value);
|
||||||
this._editor.codemirror.getDoc().setCursor(cursor);
|
this._editor.codemirror.getDoc().setCursor(cursor);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -78,8 +78,8 @@ export default TextArea.extend({
|
|||||||
|
|
||||||
let editorOptions = assign(
|
let editorOptions = assign(
|
||||||
{element: document.getElementById(this.elementId)},
|
{element: document.getElementById(this.elementId)},
|
||||||
this.get('defaultOptions'),
|
this.defaultOptions,
|
||||||
this.get('options')
|
this.options
|
||||||
);
|
);
|
||||||
|
|
||||||
// disable spellchecker when testing so that the exterally loaded plugin
|
// 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 = new SimpleMDE(editorOptions);
|
||||||
this._editor.value(this.get('value') || '');
|
this._editor.value(this.value || '');
|
||||||
|
|
||||||
this._editor.codemirror.on('change', (instance, changeObj) => {
|
this._editor.codemirror.on('change', (instance, changeObj) => {
|
||||||
// avoid a "modified x twice in a single render" error that occurs
|
// avoid a "modified x twice in a single render" error that occurs
|
||||||
@ -107,7 +107,7 @@ export default TextArea.extend({
|
|||||||
this.onBlur();
|
this.onBlur();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.get('autofocus')) {
|
if (this.autofocus) {
|
||||||
this._editor.codemirror.execCommand('goDocEnd');
|
this._editor.codemirror.execCommand('goDocEnd');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ export default Component.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
onScrolledToBottom() {
|
onScrolledToBottom() {
|
||||||
let loadNextPage = this.get('loadNextPage');
|
let loadNextPage = this.loadNextPage;
|
||||||
|
|
||||||
if (!this.get('isLoading')) {
|
if (!this.isLoading) {
|
||||||
loadNextPage();
|
loadNextPage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,9 @@ export default Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
seoTitle: computed('scratchName', 'scratchMetaTitle', function () {
|
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) {
|
if (metaTitle && metaTitle.length > 70) {
|
||||||
metaTitle = metaTitle.substring(0, 70).trim();
|
metaTitle = metaTitle.substring(0, 70).trim();
|
||||||
@ -54,7 +54,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
seoURL: computed('scratchSlug', function () {
|
seoURL: computed('scratchSlug', function () {
|
||||||
let blogUrl = this.get('config.blogUrl');
|
let blogUrl = this.get('config.blogUrl');
|
||||||
let seoSlug = this.get('scratchSlug') || '';
|
let seoSlug = this.scratchSlug || '';
|
||||||
|
|
||||||
let seoURL = `${blogUrl}/tag/${seoSlug}`;
|
let seoURL = `${blogUrl}/tag/${seoSlug}`;
|
||||||
|
|
||||||
@ -73,9 +73,9 @@ export default Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
seoDescription: computed('scratchDescription', 'scratchMetaDescription', function () {
|
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) {
|
if (metaDescription && metaDescription.length > 156) {
|
||||||
metaDescription = metaDescription.substring(0, 156).trim();
|
metaDescription = metaDescription.substring(0, 156).trim();
|
||||||
|
@ -17,9 +17,9 @@ export default Component.extend({
|
|||||||
isEmpty: equal('tags.length', 0),
|
isEmpty: equal('tags.length', 0),
|
||||||
|
|
||||||
displaySettingsPane: computed('isEmpty', 'selectedTag', 'isMobile', function () {
|
displaySettingsPane: computed('isEmpty', 'selectedTag', 'isMobile', function () {
|
||||||
let isEmpty = this.get('isEmpty');
|
let isEmpty = this.isEmpty;
|
||||||
let selectedTag = this.get('selectedTag');
|
let selectedTag = this.selectedTag;
|
||||||
let isMobile = this.get('isMobile');
|
let isMobile = this.isMobile;
|
||||||
|
|
||||||
// always display settings pane for blank-slate on mobile
|
// always display settings pane for blank-slate on mobile
|
||||||
if (isMobile && isEmpty) {
|
if (isMobile && isEmpty) {
|
||||||
@ -37,17 +37,17 @@ export default Component.extend({
|
|||||||
|
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
this.get('mediaQueries').on('change', this, this._fireMobileChangeActions);
|
this.mediaQueries.on('change', this, this._fireMobileChangeActions);
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
this.get('mediaQueries').off('change', this, this._fireMobileChangeActions);
|
this.mediaQueries.off('change', this, this._fireMobileChangeActions);
|
||||||
},
|
},
|
||||||
|
|
||||||
_fireMobileChangeActions(key, value) {
|
_fireMobileChangeActions(key, value) {
|
||||||
if (key === 'maxWidth600') {
|
if (key === 'maxWidth600') {
|
||||||
let leftMobileAction = this.get('leftMobile');
|
let leftMobileAction = this.leftMobile;
|
||||||
|
|
||||||
this.set('isMobile', value);
|
this.set('isMobile', value);
|
||||||
|
|
||||||
|
@ -50,19 +50,19 @@ const GhTaskButton = Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
isIdleClass: computed('isIdle', function () {
|
isIdleClass: computed('isIdle', function () {
|
||||||
if (this.get('isIdle')) {
|
if (this.isIdle) {
|
||||||
return this.get('idleClass');
|
return this.idleClass;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
isRunningClass: computed('isRunning', function () {
|
isRunningClass: computed('isRunning', function () {
|
||||||
if (this.get('isRunning')) {
|
if (this.isRunning) {
|
||||||
return this.get('runningClass') || this.get('idleClass');
|
return this.runningClass || this.idleClass;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
isSuccess: computed('hasRun', 'isRunning', 'task.last.value', function () {
|
isSuccess: computed('hasRun', 'isRunning', 'task.last.value', function () {
|
||||||
if (!this.get('hasRun') || this.get('isRunning')) {
|
if (!this.hasRun || this.isRunning) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,13 +71,13 @@ const GhTaskButton = Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
isSuccessClass: computed('isSuccess', function () {
|
isSuccessClass: computed('isSuccess', function () {
|
||||||
if (this.get('isSuccess')) {
|
if (this.isSuccess) {
|
||||||
return this.get('successClass');
|
return this.successClass;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
isFailure: computed('hasRun', 'isRunning', 'isSuccess', 'task.last.error', function () {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,13 +85,13 @@ const GhTaskButton = Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
isFailureClass: computed('isFailure', function () {
|
isFailureClass: computed('isFailure', function () {
|
||||||
if (this.get('isFailure')) {
|
if (this.isFailure) {
|
||||||
return this.get('failureClass');
|
return this.failureClass;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
isIdle: computed('isRunning', 'isSuccess', 'isFailure', function () {
|
isIdle: computed('isRunning', 'isSuccess', 'isFailure', function () {
|
||||||
return !this.get('isRunning') && !this.get('isSuccess') && !this.get('isFailure');
|
return !this.isRunning && !this.isSuccess && !this.isFailure;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@ -105,31 +105,31 @@ const GhTaskButton = Component.extend({
|
|||||||
// task directly
|
// task directly
|
||||||
if (this.defaultClick) {
|
if (this.defaultClick) {
|
||||||
if (!this.isRunning) {
|
if (!this.isRunning) {
|
||||||
this.get('_restartAnimation').perform();
|
this._restartAnimation.perform();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do nothing if disabled externally
|
// do nothing if disabled externally
|
||||||
if (this.get('disabled')) {
|
if (this.disabled) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let task = this.get('task');
|
let task = this.task;
|
||||||
let taskName = this.get('task.name');
|
let taskName = this.get('task.name');
|
||||||
let lastTaskName = this.get('task.last.task.name');
|
let lastTaskName = this.get('task.last.task.name');
|
||||||
|
|
||||||
// task-buttons are never disabled whilst running so that clicks when a
|
// 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
|
// taskGroup is running don't get dropped BUT that means we need to check
|
||||||
// here to avoid spamming actions from multiple clicks
|
// here to avoid spamming actions from multiple clicks
|
||||||
if (this.get('isRunning') && taskName === lastTaskName) {
|
if (this.isRunning && taskName === lastTaskName) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.action();
|
this.action();
|
||||||
task.perform();
|
task.perform();
|
||||||
|
|
||||||
this.get('_restartAnimation').perform();
|
this._restartAnimation.perform();
|
||||||
|
|
||||||
// prevent the click from bubbling and triggering form actions
|
// prevent the click from bubbling and triggering form actions
|
||||||
return false;
|
return false;
|
||||||
|
@ -14,7 +14,7 @@ export default TextArea.extend(TextInputMixin, {
|
|||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
// trigger auto-expand any time the value changes
|
// trigger auto-expand any time the value changes
|
||||||
if (this.get('autoExpand')) {
|
if (this.autoExpand) {
|
||||||
run.scheduleOnce('afterRender', this, this._autoExpand);
|
run.scheduleOnce('afterRender', this, this._autoExpand);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -23,7 +23,7 @@ export default TextArea.extend(TextInputMixin, {
|
|||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
// disable the draggable resize element that browsers add to textareas
|
// disable the draggable resize element that browsers add to textareas
|
||||||
if (this.get('autoExpand')) {
|
if (this.autoExpand) {
|
||||||
this.element.style.resize = 'none';
|
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
|
// set up resize handler on element insert so that we can autoexpand
|
||||||
// when the element container changes size
|
// when the element container changes size
|
||||||
if (this.get('autoExpand')) {
|
if (this.autoExpand) {
|
||||||
run.scheduleOnce('afterRender', this, this._setupAutoExpand);
|
run.scheduleOnce('afterRender', this, this._setupAutoExpand);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.get('didCreateTextarea')) {
|
if (this.didCreateTextarea) {
|
||||||
this.get('didCreateTextarea')(this.element);
|
this.didCreateTextarea(this.element);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ export default TextArea.extend(TextInputMixin, {
|
|||||||
|
|
||||||
_setupAutoExpand() {
|
_setupAutoExpand() {
|
||||||
this._resizeCallback = run.bind(this, this._onResize);
|
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();
|
this._autoExpand();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -69,6 +69,6 @@ export default TextArea.extend(TextInputMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_teardownAutoExpand() {
|
_teardownAutoExpand() {
|
||||||
this.get('resizeDetector').teardown(this.get('autoExpand'), this._resizeCallback);
|
this.resizeDetector.teardown(this.autoExpand, this._resizeCallback);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -7,7 +7,7 @@ export default Component.extend({
|
|||||||
themes: null,
|
themes: null,
|
||||||
|
|
||||||
sortedThemes: computed('themes.@each.active', function () {
|
sortedThemes: computed('themes.@each.active', function () {
|
||||||
let themes = get(this, 'themes').map((t) => {
|
let themes = this.themes.map((t) => {
|
||||||
let theme = {};
|
let theme = {};
|
||||||
let themePackage = get(t, 'package');
|
let themePackage = get(t, 'package');
|
||||||
|
|
||||||
|
@ -18,16 +18,16 @@ export default Component.extend({
|
|||||||
availableTimezoneNames: mapBy('availableTimezones', 'name'),
|
availableTimezoneNames: mapBy('availableTimezones', 'name'),
|
||||||
|
|
||||||
hasTimezoneOverride: computed('activeTimezone', 'availableTimezoneNames', function () {
|
hasTimezoneOverride: computed('activeTimezone', 'availableTimezoneNames', function () {
|
||||||
let activeTimezone = this.get('activeTimezone');
|
let activeTimezone = this.activeTimezone;
|
||||||
let availableTimezoneNames = this.get('availableTimezoneNames');
|
let availableTimezoneNames = this.availableTimezoneNames;
|
||||||
|
|
||||||
return !availableTimezoneNames.includes(activeTimezone);
|
return !availableTimezoneNames.includes(activeTimezone);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
selectedTimezone: computed('activeTimezone', 'availableTimezones', 'hasTimezoneOverride', function () {
|
selectedTimezone: computed('activeTimezone', 'availableTimezones', 'hasTimezoneOverride', function () {
|
||||||
let hasTimezoneOverride = this.get('hasTimezoneOverride');
|
let hasTimezoneOverride = this.hasTimezoneOverride;
|
||||||
let activeTimezone = this.get('activeTimezone');
|
let activeTimezone = this.activeTimezone;
|
||||||
let availableTimezones = this.get('availableTimezones');
|
let availableTimezones = this.availableTimezones;
|
||||||
|
|
||||||
if (hasTimezoneOverride) {
|
if (hasTimezoneOverride) {
|
||||||
return {name: '', label: ''};
|
return {name: '', label: ''};
|
||||||
@ -39,8 +39,8 @@ export default Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
selectableTimezones: computed('availableTimezones', 'hasTimezoneOverride', function () {
|
selectableTimezones: computed('availableTimezones', 'hasTimezoneOverride', function () {
|
||||||
let hasTimezoneOverride = this.get('hasTimezoneOverride');
|
let hasTimezoneOverride = this.hasTimezoneOverride;
|
||||||
let availableTimezones = this.get('availableTimezones');
|
let availableTimezones = this.availableTimezones;
|
||||||
|
|
||||||
if (hasTimezoneOverride) {
|
if (hasTimezoneOverride) {
|
||||||
return [{name: '', label: ''}, ...availableTimezones];
|
return [{name: '', label: ''}, ...availableTimezones];
|
||||||
@ -50,8 +50,8 @@ export default Component.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
localTime: computed('hasTimezoneOverride', 'activeTimezone', 'selectedTimezone', 'clock.second', function () {
|
localTime: computed('hasTimezoneOverride', 'activeTimezone', 'selectedTimezone', 'clock.second', function () {
|
||||||
let hasTimezoneOverride = this.get('hasTimezoneOverride');
|
let hasTimezoneOverride = this.hasTimezoneOverride;
|
||||||
let timezone = hasTimezoneOverride ? this.get('activeTimezone') : this.get('selectedTimezone.name');
|
let timezone = hasTimezoneOverride ? this.activeTimezone : this.get('selectedTimezone.name');
|
||||||
|
|
||||||
this.get('clock.second');
|
this.get('clock.second');
|
||||||
return timezone ? moment().tz(timezone).format('HH:mm:ss') : moment().utc().format('HH:mm:ss');
|
return timezone ? moment().tz(timezone).format('HH:mm:ss') : moment().utc().format('HH:mm:ss');
|
||||||
|
@ -30,7 +30,7 @@ export default Component.extend({
|
|||||||
triggerComponent: 'gh-token-input/trigger',
|
triggerComponent: 'gh-token-input/trigger',
|
||||||
|
|
||||||
optionsWithoutSelected: computed('options.[]', 'selected.[]', function () {
|
optionsWithoutSelected: computed('options.[]', 'selected.[]', function () {
|
||||||
return this.get('optionsWithoutSelectedTask').perform();
|
return this.optionsWithoutSelectedTask.perform();
|
||||||
}),
|
}),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
@ -41,7 +41,7 @@ export default Component.extend({
|
|||||||
let lastSelection = select.selected[select.selected.length - 1];
|
let lastSelection = select.selected[select.selected.length - 1];
|
||||||
|
|
||||||
if (lastSelection) {
|
if (lastSelection) {
|
||||||
this.get('onchange')(select.selected.slice(0, -1), select);
|
this.onchange(select.selected.slice(0, -1), select);
|
||||||
select.actions.search('');
|
select.actions.search('');
|
||||||
select.actions.open(event);
|
select.actions.open(event);
|
||||||
}
|
}
|
||||||
@ -65,40 +65,40 @@ export default Component.extend({
|
|||||||
onfocus() {
|
onfocus() {
|
||||||
key.setScope('gh-token-input');
|
key.setScope('gh-token-input');
|
||||||
|
|
||||||
if (this.get('onfocus')) {
|
if (this.onfocus) {
|
||||||
this.get('onfocus')(...arguments);
|
this.onfocus(...arguments);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onblur() {
|
onblur() {
|
||||||
key.setScope('default');
|
key.setScope('default');
|
||||||
|
|
||||||
if (this.get('onblur')) {
|
if (this.onblur) {
|
||||||
this.get('onblur')(...arguments);
|
this.onblur(...arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
optionsWithoutSelectedTask: task(function* () {
|
optionsWithoutSelectedTask: task(function* () {
|
||||||
let options = yield this.get('options');
|
let options = yield this.options;
|
||||||
let selected = yield this.get('selected');
|
let selected = yield this.selected;
|
||||||
return options.filter(o => !selected.includes(o));
|
return options.filter(o => !selected.includes(o));
|
||||||
}),
|
}),
|
||||||
|
|
||||||
shouldShowCreateOption(term, options) {
|
shouldShowCreateOption(term, options) {
|
||||||
if (!this.get('allowCreation')) {
|
if (!this.allowCreation) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.get('showCreateWhen')) {
|
if (this.showCreateWhen) {
|
||||||
return this.get('showCreateWhen')(term, options);
|
return this.showCreateWhen(term, options);
|
||||||
} else {
|
} else {
|
||||||
return this.hideCreateOptionOnSameTerm(term, options);
|
return this.hideCreateOptionOnSameTerm(term, options);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
hideCreateOptionOnSameTerm(term, options) {
|
hideCreateOptionOnSameTerm(term, options) {
|
||||||
let searchField = this.get('searchField');
|
let searchField = this.searchField;
|
||||||
let existingOption = options.findBy(searchField, term);
|
let existingOption = options.findBy(searchField, term);
|
||||||
return !existingOption;
|
return !existingOption;
|
||||||
},
|
},
|
||||||
@ -110,17 +110,17 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
searchAndSuggest(term, select) {
|
searchAndSuggest(term, select) {
|
||||||
return this.get('searchAndSuggestTask').perform(term, select);
|
return this.searchAndSuggestTask.perform(term, select);
|
||||||
},
|
},
|
||||||
|
|
||||||
searchAndSuggestTask: task(function* (term, select) {
|
searchAndSuggestTask: task(function* (term, select) {
|
||||||
let newOptions = (yield this.get('optionsWithoutSelected')).toArray();
|
let newOptions = (yield this.optionsWithoutSelected).toArray();
|
||||||
|
|
||||||
if (term.length === 0) {
|
if (term.length === 0) {
|
||||||
return newOptions;
|
return newOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
let searchAction = this.get('search');
|
let searchAction = this.search;
|
||||||
if (searchAction) {
|
if (searchAction) {
|
||||||
let results = yield searchAction(term, select);
|
let results = yield searchAction(term, select);
|
||||||
|
|
||||||
@ -153,9 +153,9 @@ export default Component.extend({
|
|||||||
let suggestion = selection.find(option => option.__isSuggestion__);
|
let suggestion = selection.find(option => option.__isSuggestion__);
|
||||||
|
|
||||||
if (suggestion) {
|
if (suggestion) {
|
||||||
this.get('oncreate')(suggestion.__value__, select);
|
this.oncreate(suggestion.__value__, select);
|
||||||
} else {
|
} else {
|
||||||
this.get('onchange')(selection, select);
|
this.onchange(selection, select);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear select search
|
// clear select search
|
||||||
@ -164,8 +164,8 @@ export default Component.extend({
|
|||||||
|
|
||||||
filter(options, searchText) {
|
filter(options, searchText) {
|
||||||
let matcher;
|
let matcher;
|
||||||
if (this.get('searchField')) {
|
if (this.searchField) {
|
||||||
matcher = (option, text) => this.matcher(get(option, this.get('searchField')), text);
|
matcher = (option, text) => this.matcher(get(option, this.searchField), text);
|
||||||
} else {
|
} else {
|
||||||
matcher = (option, text) => this.matcher(option, text);
|
matcher = (option, text) => this.matcher(option, text);
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
buildSuggestionLabel(term) {
|
buildSuggestionLabel(term) {
|
||||||
let buildSuggestion = this.get('buildSuggestion');
|
let buildSuggestion = this.buildSuggestion;
|
||||||
if (buildSuggestion) {
|
if (buildSuggestion) {
|
||||||
return buildSuggestion(term);
|
return buildSuggestion(term);
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@ export default DraggableObject.extend({
|
|||||||
internal: readOnly('content.isInternal'),
|
internal: readOnly('content.isInternal'),
|
||||||
|
|
||||||
primary: computed('idx', 'internal', function () {
|
primary: computed('idx', 'internal', function () {
|
||||||
return !this.get('internal') && this.get('idx') === 0;
|
return !this.internal && this.idx === 0;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
title: computed('internal', function () {
|
title: computed('internal', function () {
|
||||||
if (this.get('internal')) {
|
if (this.internal) {
|
||||||
return `Internal tag`;
|
return `Internal tag`;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -7,7 +7,7 @@ export default EmberPowerSelectMultipleTrigger.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
chooseOption(option) {
|
chooseOption(option) {
|
||||||
this.get('select').actions.choose(option);
|
this.select.actions.choose(option);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleOptionMouseDown(event) {
|
handleOptionMouseDown(event) {
|
||||||
@ -31,13 +31,13 @@ export default EmberPowerSelectMultipleTrigger.extend({
|
|||||||
// update EPS' selected value directly. We have to create a copy
|
// update EPS' selected value directly. We have to create a copy
|
||||||
// after sorting in order to force the onchange action to be triggered
|
// after sorting in order to force the onchange action to be triggered
|
||||||
let selectedCopy = this.select.selected.slice();
|
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
|
// copied directly from EPS, the default behaviour of stopping propagation
|
||||||
// of keydown events prevents our shortcuts from being triggered
|
// of keydown events prevents our shortcuts from being triggered
|
||||||
onKeydown(e) {
|
onKeydown(e) {
|
||||||
let {onKeydown, select} = this.getProperties('onKeydown', 'select');
|
let {onKeydown, select} = this;
|
||||||
if (onKeydown && onKeydown(e) === false) {
|
if (onKeydown && onKeydown(e) === false) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
return false;
|
return false;
|
||||||
@ -47,11 +47,11 @@ export default EmberPowerSelectMultipleTrigger.extend({
|
|||||||
if (isBlank(e.target.value)) {
|
if (isBlank(e.target.value)) {
|
||||||
let lastSelection = select.selected[select.selected.length - 1];
|
let lastSelection = select.selected[select.selected.length - 1];
|
||||||
if (lastSelection) {
|
if (lastSelection) {
|
||||||
select.actions.select(this.get('buildSelection')(lastSelection, select), e);
|
select.actions.select(this.buildSelection(lastSelection, select), e);
|
||||||
if (typeof lastSelection === 'string') {
|
if (typeof lastSelection === 'string') {
|
||||||
select.actions.search(lastSelection);
|
select.actions.search(lastSelection);
|
||||||
} else {
|
} 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);
|
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));
|
select.actions.search(get(lastSelection, searchField));
|
||||||
}
|
}
|
||||||
|
@ -89,8 +89,8 @@ const GhTourItemComponent = Component.extend({
|
|||||||
|
|
||||||
isMobile: reads('mediaQueries.isMobile'),
|
isMobile: reads('mediaQueries.isMobile'),
|
||||||
isVisible: computed('isMobile', '_throbber', function () {
|
isVisible: computed('isMobile', '_throbber', function () {
|
||||||
let isMobile = this.get('isMobile');
|
let isMobile = this.isMobile;
|
||||||
let hasThrobber = !isBlank(this.get('_throbber'));
|
let hasThrobber = !isBlank(this._throbber);
|
||||||
|
|
||||||
return !isMobile && hasThrobber;
|
return !isMobile && hasThrobber;
|
||||||
}),
|
}),
|
||||||
@ -105,14 +105,14 @@ const GhTourItemComponent = Component.extend({
|
|||||||
this._handleOptOut = run.bind(this, this._remove);
|
this._handleOptOut = run.bind(this, this._remove);
|
||||||
this._handleViewed = run.bind(this, this._removeIfViewed);
|
this._handleViewed = run.bind(this, this._removeIfViewed);
|
||||||
|
|
||||||
this.get('tour').on('optOut', this._handleOptOut);
|
this.tour.on('optOut', this._handleOptOut);
|
||||||
this.get('tour').on('viewed', this._handleViewed);
|
this.tour.on('viewed', this._handleViewed);
|
||||||
},
|
},
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
let throbberId = this.get('throbberId');
|
let throbberId = this.throbberId;
|
||||||
let throbber = this.get('tour').activeThrobber(throbberId);
|
let throbber = this.tour.activeThrobber(throbberId);
|
||||||
let triangleClass = this.get('popoverTriangleClass');
|
let triangleClass = this.popoverTriangleClass;
|
||||||
let popoverPositions = triangleClassPositions[triangleClass];
|
let popoverPositions = triangleClassPositions[triangleClass];
|
||||||
|
|
||||||
this._throbber = throbber;
|
this._throbber = throbber;
|
||||||
@ -122,8 +122,8 @@ const GhTourItemComponent = Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this.get('tour').off('optOut', this._handleOptOut);
|
this.tour.off('optOut', this._handleOptOut);
|
||||||
this.get('tour').off('viewed', this._handleViewed);
|
this.tour.off('viewed', this._handleViewed);
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -137,21 +137,21 @@ const GhTourItemComponent = Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
markAsViewed() {
|
markAsViewed() {
|
||||||
let throbberId = this.get('throbberId');
|
let throbberId = this.throbberId;
|
||||||
this.get('tour').markThrobberAsViewed(throbberId);
|
this.tour.markThrobberAsViewed(throbberId);
|
||||||
this.set('_throbber', null);
|
this.set('_throbber', null);
|
||||||
this._close();
|
this._close();
|
||||||
},
|
},
|
||||||
|
|
||||||
optOut() {
|
optOut() {
|
||||||
this.get('tour').optOut();
|
this.tour.optOut();
|
||||||
this.set('_throbber', null);
|
this.set('_throbber', null);
|
||||||
this._close();
|
this._close();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_removeIfViewed(id) {
|
_removeIfViewed(id) {
|
||||||
if (id === this.get('throbberId')) {
|
if (id === this.throbberId) {
|
||||||
this._remove();
|
this._remove();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -23,7 +23,7 @@ const TrimFocusInputComponent = GhostTextInput.extend({
|
|||||||
this.element.value = value;
|
this.element.value = value;
|
||||||
this._elementValueDidChange(event);
|
this._elementValueDidChange(event);
|
||||||
|
|
||||||
let inputMethod = this.get('input');
|
let inputMethod = this.input;
|
||||||
if (inputMethod) {
|
if (inputMethod) {
|
||||||
inputMethod(event);
|
inputMethod(event);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ export default Component.extend({
|
|||||||
containerStyle: computed('photo.color', 'zoomed', function () {
|
containerStyle: computed('photo.color', 'zoomed', function () {
|
||||||
let styles = [];
|
let styles = [];
|
||||||
let ratio = this.get('photo.ratio');
|
let ratio = this.get('photo.ratio');
|
||||||
let zoomed = this.get('zoomed');
|
let zoomed = this.zoomed;
|
||||||
|
|
||||||
styles.push(`background-color: ${this.get('photo.color')}`);
|
styles.push(`background-color: ${this.get('photo.color')}`);
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ export default Component.extend({
|
|||||||
select(event) {
|
select(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
this.select(this.get('photo'));
|
this.select(this.photo);
|
||||||
},
|
},
|
||||||
|
|
||||||
zoom(event) {
|
zoom(event) {
|
||||||
@ -90,7 +90,7 @@ export default Component.extend({
|
|||||||
// only zoom when it wasn't one of the child links clicked
|
// only zoom when it wasn't one of the child links clicked
|
||||||
if (!$target.is('a') && $target.closest('a').hasClass('gh-unsplash-photo')) {
|
if (!$target.is('a') && $target.closest('a').hasClass('gh-unsplash-photo')) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.zoom(this.get('photo'));
|
this.zoom(this.photo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't propagate otherwise we can trigger the closeZoom action on the overlay
|
// don't propagate otherwise we can trigger the closeZoom action on the overlay
|
||||||
|
@ -45,12 +45,12 @@ export default Component.extend(ShortcutsMixin, {
|
|||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
this._resizeCallback = bind(this, this._handleResize);
|
this._resizeCallback = bind(this, this._handleResize);
|
||||||
this.get('resizeDetector').setup('[data-unsplash]', this._resizeCallback);
|
this.resizeDetector.setup('[data-unsplash]', this._resizeCallback);
|
||||||
this.registerShortcuts();
|
this.registerShortcuts();
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this.get('resizeDetector').teardown('[data-unsplash]', this._resizeCallback);
|
this.resizeDetector.teardown('[data-unsplash]', this._resizeCallback);
|
||||||
this.removeShortcuts();
|
this.removeShortcuts();
|
||||||
this.send('resetKeyScope');
|
this.send('resetKeyScope');
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
@ -58,7 +58,7 @@ export default Component.extend(ShortcutsMixin, {
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
loadNextPage() {
|
loadNextPage() {
|
||||||
this.get('unsplash').loadNextPage();
|
this.unsplash.loadNextPage();
|
||||||
},
|
},
|
||||||
|
|
||||||
search(term) {
|
search(term) {
|
||||||
@ -75,7 +75,7 @@ export default Component.extend(ShortcutsMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
select(photo) {
|
select(photo) {
|
||||||
this.get('unsplash').triggerDownload(photo);
|
this.unsplash.triggerDownload(photo);
|
||||||
|
|
||||||
let selectParams = {
|
let selectParams = {
|
||||||
src: photo.urls.regular,
|
src: photo.urls.regular,
|
||||||
@ -92,7 +92,7 @@ export default Component.extend(ShortcutsMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
retry() {
|
retry() {
|
||||||
this.get('unsplash').retryLastRequest();
|
this.unsplash.retryLastRequest();
|
||||||
},
|
},
|
||||||
|
|
||||||
setKeyScope() {
|
setKeyScope() {
|
||||||
@ -104,7 +104,7 @@ export default Component.extend(ShortcutsMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleEscape() {
|
handleEscape() {
|
||||||
if (this.get('zoomedPhoto')) {
|
if (this.zoomedPhoto) {
|
||||||
return this.send('closeZoom');
|
return this.send('closeZoom');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +122,6 @@ export default Component.extend(ShortcutsMixin, {
|
|||||||
columns = 2;
|
columns = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get('unsplash').changeColumnCount(columns);
|
this.unsplash.changeColumnCount(columns);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -95,12 +95,12 @@ export default Component.extend({
|
|||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
// set up any defaults
|
// set up any defaults
|
||||||
if (!this.get('uploadUrl')) {
|
if (!this.uploadUrl) {
|
||||||
this.set('uploadUrl', this._defaultUploadUrl);
|
this.set('uploadUrl', this._defaultUploadUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we have new files, validate and start an upload
|
// if we have new files, validate and start an upload
|
||||||
let files = this.get('files');
|
let files = this.files;
|
||||||
this._setFiles(files);
|
this._setFiles(files);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -132,14 +132,14 @@ export default Component.extend({
|
|||||||
|
|
||||||
// we cancel early if any file fails client-side validation
|
// we cancel early if any file fails client-side validation
|
||||||
if (this._validate()) {
|
if (this._validate()) {
|
||||||
this.get('_uploadFiles').perform(files);
|
this._uploadFiles.perform(files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_validate() {
|
_validate() {
|
||||||
let files = this.get('files');
|
let files = this.files;
|
||||||
let validate = this.get('validate') || this._defaultValidator.bind(this);
|
let validate = this.validate || this._defaultValidator.bind(this);
|
||||||
let ok = [];
|
let ok = [];
|
||||||
let errors = [];
|
let errors = [];
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ export default Component.extend({
|
|||||||
// we only check the file extension by default because IE doesn't always
|
// 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
|
// expose the mime-type, we'll rely on the API for final validation
|
||||||
_defaultValidator(file) {
|
_defaultValidator(file) {
|
||||||
let extensions = this.get('extensions');
|
let extensions = this.extensions;
|
||||||
let [, extension] = (/(?:\.([^.]+))?$/).exec(file.name);
|
let [, extension] = (/(?:\.([^.]+))?$/).exec(file.name);
|
||||||
|
|
||||||
// if extensions is falsy exit early and accept all files
|
// if extensions is falsy exit early and accept all files
|
||||||
@ -199,25 +199,25 @@ export default Component.extend({
|
|||||||
let file = files[i];
|
let file = files[i];
|
||||||
let tracker = new UploadTracker({file});
|
let tracker = new UploadTracker({file});
|
||||||
|
|
||||||
this.get('_uploadTrackers').pushObject(tracker);
|
this._uploadTrackers.pushObject(tracker);
|
||||||
uploads.push(this.get('_uploadFile').perform(tracker, file, i));
|
uploads.push(this._uploadFile.perform(tracker, file, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
// populates this.errors and this.uploadUrls
|
// populates this.errors and this.uploadUrls
|
||||||
yield all(uploads);
|
yield all(uploads);
|
||||||
|
|
||||||
if (!isEmpty(this.get('errors'))) {
|
if (!isEmpty(this.errors)) {
|
||||||
this.onFailed(this.get('errors'));
|
this.onFailed(this.errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onComplete(this.get('uploadUrls'));
|
this.onComplete(this.uploadUrls);
|
||||||
}).drop(),
|
}).drop(),
|
||||||
|
|
||||||
// eslint-disable-next-line ghost/ember/order-in-components
|
// eslint-disable-next-line ghost/ember/order-in-components
|
||||||
_uploadFile: task(function* (tracker, file, index) {
|
_uploadFile: task(function* (tracker, file, index) {
|
||||||
let ajax = this.get('ajax');
|
let ajax = this.ajax;
|
||||||
let formData = this._getFormData(file);
|
let formData = this._getFormData(file);
|
||||||
let url = `${ghostPaths().apiRoot}${this.get('uploadUrl')}`;
|
let url = `${ghostPaths().apiRoot}${this.uploadUrl}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.onUploadStart(file);
|
this.onUploadStart(file);
|
||||||
@ -269,7 +269,7 @@ export default Component.extend({
|
|||||||
fileName: file.name
|
fileName: file.name
|
||||||
};
|
};
|
||||||
|
|
||||||
this.get('uploadUrls')[index] = result;
|
this.uploadUrls[index] = result;
|
||||||
this.onUploadSuccess(result);
|
this.onUploadSuccess(result);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -288,7 +288,7 @@ export default Component.extend({
|
|||||||
};
|
};
|
||||||
|
|
||||||
// TODO: check for or expose known error types?
|
// TODO: check for or expose known error types?
|
||||||
this.get('errors').pushObject(result);
|
this.errors.pushObject(result);
|
||||||
this.onUploadFailure(result);
|
this.onUploadFailure(result);
|
||||||
}
|
}
|
||||||
}).maxConcurrency(MAX_SIMULTANEOUS_UPLOADS).enqueue(),
|
}).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
|
// NOTE: this is necessary because the API doesn't accept direct file uploads
|
||||||
_getFormData(file) {
|
_getFormData(file) {
|
||||||
let formData = new FormData();
|
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) => {
|
Object.keys(this.paramsHash || {}).forEach((key) => {
|
||||||
formData.append(key, this.paramsHash[key]);
|
formData.append(key, this.paramsHash[key]);
|
||||||
|
@ -20,8 +20,8 @@ export default Component.extend({
|
|||||||
let noSchemeBlogUrl = blogUrl.substr(blogUrl.indexOf('://') + 3);
|
let noSchemeBlogUrl = blogUrl.substr(blogUrl.indexOf('://') + 3);
|
||||||
|
|
||||||
// Get the prefix and slug values
|
// Get the prefix and slug values
|
||||||
let prefix = this.get('prefix') ? `${this.get('prefix')}/` : '';
|
let prefix = this.prefix ? `${this.prefix}/` : '';
|
||||||
let slug = this.get('slug') ? `${this.get('slug')}/` : '';
|
let slug = this.slug ? `${this.slug}/` : '';
|
||||||
|
|
||||||
// Join parts of the URL together with slashes
|
// Join parts of the URL together with slashes
|
||||||
let theUrl = `${noSchemeBlogUrl}/${prefix}${slug}`;
|
let theUrl = `${noSchemeBlogUrl}/${prefix}${slug}`;
|
||||||
|
@ -34,8 +34,8 @@ export default Component.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
resend() {
|
resend() {
|
||||||
let invite = this.get('invite');
|
let invite = this.invite;
|
||||||
let notifications = this.get('notifications');
|
let notifications = this.notifications;
|
||||||
|
|
||||||
this.set('isSending', true);
|
this.set('isSending', true);
|
||||||
invite.resend().then((result) => {
|
invite.resend().then((result) => {
|
||||||
@ -44,7 +44,7 @@ export default Component.extend({
|
|||||||
// the server deletes the old record and creates a new one when
|
// the server deletes the old record and creates a new one when
|
||||||
// resending so we need to update the store accordingly
|
// resending so we need to update the store accordingly
|
||||||
invite.unloadRecord();
|
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
|
// 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'.
|
// but the invite's status in the response object will be 'invited-pending'.
|
||||||
@ -61,9 +61,9 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
revoke() {
|
revoke() {
|
||||||
let invite = this.get('invite');
|
let invite = this.invite;
|
||||||
let email = invite.get('email');
|
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
|
// reload the invite to get the most up-to-date information
|
||||||
invite.reload().then(() => {
|
invite.reload().then(() => {
|
||||||
@ -76,7 +76,7 @@ export default Component.extend({
|
|||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
if (isNotFoundError(error)) {
|
if (isNotFoundError(error)) {
|
||||||
// if the invite no longer exists, then show a warning and reload the route
|
// 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) {
|
if (action) {
|
||||||
action();
|
action();
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@ export default Component.extend(ValidationStateMixin, {
|
|||||||
classNameBindings: ['errorClass'],
|
classNameBindings: ['errorClass'],
|
||||||
|
|
||||||
errorClass: computed('property', 'hasError', 'hasValidated.[]', function () {
|
errorClass: computed('property', 'hasError', 'hasValidated.[]', function () {
|
||||||
let hasValidated = this.get('hasValidated');
|
let hasValidated = this.hasValidated;
|
||||||
let property = this.get('property');
|
let property = this.property;
|
||||||
|
|
||||||
if (hasValidated && hasValidated.includes(property)) {
|
if (hasValidated && hasValidated.includes(property)) {
|
||||||
return this.get('hasError') ? 'error' : 'success';
|
return this.hasError ? 'error' : 'success';
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -11,26 +11,26 @@ export default ModalComponent.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
confirm() {
|
confirm() {
|
||||||
this.get('deleteAll').perform();
|
this.deleteAll.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_deleteAll() {
|
_deleteAll() {
|
||||||
let deleteUrl = this.get('ghostPaths.url').api('db');
|
let deleteUrl = this.get('ghostPaths.url').api('db');
|
||||||
return this.get('ajax').del(deleteUrl);
|
return this.ajax.del(deleteUrl);
|
||||||
},
|
},
|
||||||
|
|
||||||
_unloadData() {
|
_unloadData() {
|
||||||
this.get('store').unloadAll('post');
|
this.store.unloadAll('post');
|
||||||
this.get('store').unloadAll('tag');
|
this.store.unloadAll('tag');
|
||||||
},
|
},
|
||||||
|
|
||||||
_showSuccess() {
|
_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) {
|
_showFailure(error) {
|
||||||
this.get('notifications').showAPIError(error, {key: 'all-content.delete'});
|
this.notifications.showAPIError(error, {key: 'all-content.delete'});
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteAll: task(function* () {
|
deleteAll: task(function* () {
|
||||||
|
@ -11,12 +11,12 @@ export default ModalComponent.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
confirm() {
|
confirm() {
|
||||||
this.get('deletePost').perform();
|
this.deletePost.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_deletePost() {
|
_deletePost() {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
|
|
||||||
// definitely want to clear the data store and post of any unsaved,
|
// definitely want to clear the data store and post of any unsaved,
|
||||||
// client-generated tags
|
// client-generated tags
|
||||||
@ -27,16 +27,16 @@ export default ModalComponent.extend({
|
|||||||
|
|
||||||
_success() {
|
_success() {
|
||||||
// clear any previous error messages
|
// clear any previous error messages
|
||||||
this.get('notifications').closeAlerts('post.delete');
|
this.notifications.closeAlerts('post.delete');
|
||||||
|
|
||||||
// trigger the success action
|
// trigger the success action
|
||||||
if (this.get('onSuccess')) {
|
if (this.onSuccess) {
|
||||||
this.get('onSuccess')();
|
this.onSuccess();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_failure(error) {
|
_failure(error) {
|
||||||
this.get('notifications').showAPIError(error, {key: 'post.delete.failed'});
|
this.notifications.showAPIError(error, {key: 'post.delete.failed'});
|
||||||
},
|
},
|
||||||
|
|
||||||
deletePost: task(function* () {
|
deletePost: task(function* () {
|
||||||
|
@ -10,7 +10,7 @@ export default ModalComponent.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
confirm() {
|
confirm() {
|
||||||
this.get('deleteSubscriber').perform();
|
this.deleteSubscriber.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ export default ModalComponent.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
confirm() {
|
confirm() {
|
||||||
this.get('deleteTag').perform();
|
this.deleteTag.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ export default ModalComponent.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
confirm() {
|
confirm() {
|
||||||
this.get('deleteTheme').perform();
|
this.deleteTheme.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ export default ModalComponent.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
confirm() {
|
confirm() {
|
||||||
this.get('deleteUser').perform();
|
this.deleteUser.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ export default ModalComponent.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
closeModal() {
|
closeModal() {
|
||||||
if (!this.get('closeDisabled')) {
|
if (!this.closeDisabled) {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ export default ModalComponent.extend(ValidationEngine, {
|
|||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
// TODO: this should not be needed, ValidationEngine acts as a
|
// TODO: this should not be needed, ValidationEngine acts as a
|
||||||
// singleton and so it's errors and hasValidated state stick around
|
// singleton and so it's errors and hasValidated state stick around
|
||||||
this.get('errors').clear();
|
this.errors.clear();
|
||||||
this.set('hasValidated', emberA());
|
this.set('hasValidated', emberA());
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -43,33 +43,33 @@ export default ModalComponent.extend(ValidationEngine, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
confirm() {
|
confirm() {
|
||||||
this.get('sendInvitation').perform();
|
this.sendInvitation.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
validate() {
|
validate() {
|
||||||
let email = this.get('email');
|
let email = this.email;
|
||||||
|
|
||||||
// TODO: either the validator should check the email's existence or
|
// TODO: either the validator should check the email's existence or
|
||||||
// the API should return an appropriate error when attempting to save
|
// the API should return an appropriate error when attempting to save
|
||||||
return new Promise((resolve, reject) => this._super().then(() => RSVP.hash({
|
return new Promise((resolve, reject) => this._super().then(() => RSVP.hash({
|
||||||
users: this.get('store').findAll('user', {reload: true}),
|
users: this.store.findAll('user', {reload: true}),
|
||||||
invites: this.get('store').findAll('invite', {reload: true})
|
invites: this.store.findAll('invite', {reload: true})
|
||||||
}).then((data) => {
|
}).then((data) => {
|
||||||
let existingUser = data.users.findBy('email', email);
|
let existingUser = data.users.findBy('email', email);
|
||||||
let existingInvite = data.invites.findBy('email', email);
|
let existingInvite = data.invites.findBy('email', email);
|
||||||
|
|
||||||
if (existingUser || existingInvite) {
|
if (existingUser || existingInvite) {
|
||||||
this.get('errors').clear('email');
|
this.errors.clear('email');
|
||||||
if (existingUser) {
|
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 {
|
} 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
|
// TODO: this shouldn't be needed, ValidationEngine doesn't mark
|
||||||
// properties as validated when validating an entire object
|
// properties as validated when validating an entire object
|
||||||
this.get('hasValidated').addObject('email');
|
this.hasValidated.addObject('email');
|
||||||
reject();
|
reject();
|
||||||
} else {
|
} else {
|
||||||
resolve();
|
resolve();
|
||||||
@ -77,34 +77,34 @@ export default ModalComponent.extend(ValidationEngine, {
|
|||||||
}), () => {
|
}), () => {
|
||||||
// TODO: this shouldn't be needed, ValidationEngine doesn't mark
|
// TODO: this shouldn't be needed, ValidationEngine doesn't mark
|
||||||
// properties as validated when validating an entire object
|
// properties as validated when validating an entire object
|
||||||
this.get('hasValidated').addObject('email');
|
this.hasValidated.addObject('email');
|
||||||
reject();
|
reject();
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchRoles: task(function * () {
|
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');
|
let authorRole = roles.findBy('name', 'Author');
|
||||||
|
|
||||||
this.set('roles', roles);
|
this.set('roles', roles);
|
||||||
this.set('authorRole', authorRole);
|
this.set('authorRole', authorRole);
|
||||||
|
|
||||||
if (!this.get('role')) {
|
if (!this.role) {
|
||||||
this.set('role', authorRole);
|
this.set('role', authorRole);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
sendInvitation: task(function* () {
|
sendInvitation: task(function* () {
|
||||||
let email = this.get('email');
|
let email = this.email;
|
||||||
let role = this.get('role');
|
let role = this.role;
|
||||||
let notifications = this.get('notifications');
|
let notifications = this.notifications;
|
||||||
let notificationText = `Invitation sent! (${email})`;
|
let notificationText = `Invitation sent! (${email})`;
|
||||||
let invite;
|
let invite;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
yield this.validate();
|
yield this.validate();
|
||||||
|
|
||||||
invite = this.get('store').createRecord('invite', {
|
invite = this.store.createRecord('invite', {
|
||||||
email,
|
email,
|
||||||
role
|
role
|
||||||
});
|
});
|
||||||
|
@ -16,13 +16,13 @@ export default ModalComponent.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
confirm() {
|
confirm() {
|
||||||
this.get('addSubscriber').perform();
|
this.addSubscriber.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addSubscriber: task(function* () {
|
addSubscriber: task(function* () {
|
||||||
try {
|
try {
|
||||||
yield this.get('confirm')();
|
yield this.confirm();
|
||||||
this.send('closeModal');
|
this.send('closeModal');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// TODO: server-side validation errors should be serialized
|
// TODO: server-side validation errors should be serialized
|
||||||
|
@ -22,15 +22,15 @@ export default ModalComponent.extend(ValidationEngine, {
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
confirm() {
|
confirm() {
|
||||||
this.get('reauthenticate').perform();
|
this.reauthenticate.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_authenticate() {
|
_authenticate() {
|
||||||
let session = this.get('session');
|
let session = this.session;
|
||||||
let authStrategy = 'authenticator:cookie';
|
let authStrategy = 'authenticator:cookie';
|
||||||
let identification = this.get('identification');
|
let identification = this.identification;
|
||||||
let password = this.get('password');
|
let password = this.password;
|
||||||
|
|
||||||
session.set('skipAuthSuccessHandler', true);
|
session.set('skipAuthSuccessHandler', true);
|
||||||
|
|
||||||
@ -50,24 +50,24 @@ export default ModalComponent.extend(ValidationEngine, {
|
|||||||
this.set('authenticationError', null);
|
this.set('authenticationError', null);
|
||||||
|
|
||||||
return this.validate({property: 'signin'}).then(() => this._authenticate().then(() => {
|
return this.validate({property: 'signin'}).then(() => this._authenticate().then(() => {
|
||||||
this.get('notifications').closeAlerts();
|
this.notifications.closeAlerts();
|
||||||
this.send('closeModal');
|
this.send('closeModal');
|
||||||
return true;
|
return true;
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
if (error && error.payload && error.payload.errors) {
|
if (error && error.payload && error.payload.errors) {
|
||||||
error.payload.errors.forEach((err) => {
|
error.payload.errors.forEach((err) => {
|
||||||
if (isVersionMismatchError(err)) {
|
if (isVersionMismatchError(err)) {
|
||||||
return this.get('notifications').showAPIError(error);
|
return this.notifications.showAPIError(error);
|
||||||
}
|
}
|
||||||
err.message = htmlSafe(err.context || err.message);
|
err.message = htmlSafe(err.context || err.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get('errors').add('password', 'Incorrect password');
|
this.errors.add('password', 'Incorrect password');
|
||||||
this.get('hasValidated').pushObject('password');
|
this.hasValidated.pushObject('password');
|
||||||
this.set('authenticationError', error.payload.errors[0].message);
|
this.set('authenticationError', error.payload.errors[0].message);
|
||||||
}
|
}
|
||||||
}), () => {
|
}), () => {
|
||||||
this.get('hasValidated').pushObject('password');
|
this.hasValidated.pushObject('password');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -10,7 +10,7 @@ export default ModalComponent.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
confirm() {
|
confirm() {
|
||||||
return this.get('suspendUser').perform();
|
return this.suspendUser.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ export default ModalComponent.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
confirm() {
|
confirm() {
|
||||||
this.get('transferOwnership').perform();
|
this.transferOwnership.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ export default ModalComponent.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
confirm() {
|
confirm() {
|
||||||
return this.get('unsuspendUser').perform();
|
return this.unsuspendUser.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ export default ModalComponent.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
let image = this.get('image');
|
let image = this.image;
|
||||||
this.set('url', image);
|
this.set('url', image);
|
||||||
this.set('newUrl', image);
|
this.set('newUrl', image);
|
||||||
},
|
},
|
||||||
@ -48,7 +48,7 @@ export default ModalComponent.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
confirm() {
|
confirm() {
|
||||||
this.get('uploadImage').perform();
|
this.uploadImage.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
isUploading() {
|
isUploading() {
|
||||||
@ -88,9 +88,9 @@ export default ModalComponent.extend({
|
|||||||
|
|
||||||
uploadImage: task(function* () {
|
uploadImage: task(function* () {
|
||||||
let model = this.get('model.model');
|
let model = this.get('model.model');
|
||||||
let newUrl = this.get('newUrl');
|
let newUrl = this.newUrl;
|
||||||
let result = this._validateUrl(newUrl);
|
let result = this._validateUrl(newUrl);
|
||||||
let notifications = this.get('notifications');
|
let notifications = this.notifications;
|
||||||
|
|
||||||
if (result === true) {
|
if (result === true) {
|
||||||
this.set('image', newUrl);
|
this.set('image', newUrl);
|
||||||
|
@ -42,12 +42,12 @@ export default ModalComponent.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
fileThemeName: computed('file', function () {
|
fileThemeName: computed('file', function () {
|
||||||
let file = this.get('file');
|
let file = this.file;
|
||||||
return file.name.replace(/\.zip$/, '');
|
return file.name.replace(/\.zip$/, '');
|
||||||
}),
|
}),
|
||||||
|
|
||||||
canActivateTheme: computed('theme', function () {
|
canActivateTheme: computed('theme', function () {
|
||||||
let theme = this.get('theme');
|
let theme = this.theme;
|
||||||
return theme && !theme.get('active');
|
return theme && !theme.get('active');
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@ -62,12 +62,12 @@ export default ModalComponent.extend({
|
|||||||
validateTheme(file) {
|
validateTheme(file) {
|
||||||
let themeName = file.name.replace(/\.zip$/, '').replace(/[^\w@.]/gi, '-').toLowerCase();
|
let themeName = file.name.replace(/\.zip$/, '').replace(/[^\w@.]/gi, '-').toLowerCase();
|
||||||
|
|
||||||
let currentThemeNames = this.get('currentThemeNames');
|
let currentThemeNames = this.currentThemeNames;
|
||||||
|
|
||||||
this.set('file', file);
|
this.set('file', file);
|
||||||
|
|
||||||
let [, extension] = (/(?:\.([^.]+))?$/).exec(file.name);
|
let [, extension] = (/(?:\.([^.]+))?$/).exec(file.name);
|
||||||
let extensions = this.get('extensions');
|
let extensions = this.extensions;
|
||||||
|
|
||||||
if (!extension || extensions.indexOf(extension.toLowerCase()) === -1) {
|
if (!extension || extensions.indexOf(extension.toLowerCase()) === -1) {
|
||||||
return new UnsupportedMediaTypeError();
|
return new UnsupportedMediaTypeError();
|
||||||
@ -92,7 +92,7 @@ export default ModalComponent.extend({
|
|||||||
// we need to schedule afterRender so that the upload component is
|
// we need to schedule afterRender so that the upload component is
|
||||||
// displayed again in order to subscribe/respond to the event bus
|
// displayed again in order to subscribe/respond to the event bus
|
||||||
run.schedule('afterRender', this, function () {
|
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) {
|
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);
|
this.set('theme', theme);
|
||||||
|
|
||||||
@ -155,12 +155,12 @@ export default ModalComponent.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
activate() {
|
activate() {
|
||||||
this.get('model.activate')(this.get('theme'));
|
this.get('model.activate')(this.theme);
|
||||||
this.closeModal();
|
this.closeModal();
|
||||||
},
|
},
|
||||||
|
|
||||||
closeModal() {
|
closeModal() {
|
||||||
if (!this.get('closeDisabled')) {
|
if (!this.closeDisabled) {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -21,7 +21,7 @@ export default Controller.extend({
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (this.get('currentPath') !== 'error404' || this.get('session.isAuthenticated'))
|
return (this.currentPath !== 'error404' || this.get('session.isAuthenticated'))
|
||||||
&& !this.get('currentPath').match(/(signin|signup|setup|reset)/);
|
&& !this.currentPath.match(/(signin|signup|setup|reset)/);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -152,9 +152,9 @@ export default Controller.extend({
|
|||||||
this.set('post.scratch', mobiledoc);
|
this.set('post.scratch', mobiledoc);
|
||||||
|
|
||||||
// save 3 seconds after last edit
|
// save 3 seconds after last edit
|
||||||
this.get('_autosave').perform();
|
this._autosave.perform();
|
||||||
// force save at 60 seconds
|
// force save at 60 seconds
|
||||||
this.get('_timedSave').perform();
|
this._timedSave.perform();
|
||||||
},
|
},
|
||||||
updateTitleScratch(title) {
|
updateTitleScratch(title) {
|
||||||
this.set('post.titleScratch', title);
|
this.set('post.titleScratch', title);
|
||||||
@ -176,22 +176,22 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
save(options) {
|
save(options) {
|
||||||
return this.get('save').perform(options);
|
return this.save.perform(options);
|
||||||
},
|
},
|
||||||
|
|
||||||
// used to prevent unexpected background saves. Triggered when opening
|
// used to prevent unexpected background saves. Triggered when opening
|
||||||
// publish menu, starting a manual save, and when leaving the editor
|
// publish menu, starting a manual save, and when leaving the editor
|
||||||
cancelAutosave() {
|
cancelAutosave() {
|
||||||
this.get('_autosave').cancelAll();
|
this._autosave.cancelAll();
|
||||||
this.get('_timedSave').cancelAll();
|
this._timedSave.cancelAll();
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleLeaveEditorModal(transition) {
|
toggleLeaveEditorModal(transition) {
|
||||||
let leaveTransition = this.get('leaveEditorTransition');
|
let leaveTransition = this.leaveEditorTransition;
|
||||||
|
|
||||||
// "cancel" was clicked in the "are you sure?" modal so we just
|
// "cancel" was clicked in the "are you sure?" modal so we just
|
||||||
// reset the saved transition and remove the modal
|
// reset the saved transition and remove the modal
|
||||||
if (!transition && this.get('showLeaveEditorModal')) {
|
if (!transition && this.showLeaveEditorModal) {
|
||||||
this.set('leaveEditorTransition', null);
|
this.set('leaveEditorTransition', null);
|
||||||
this.set('showLeaveEditorModal', false);
|
this.set('showLeaveEditorModal', false);
|
||||||
return;
|
return;
|
||||||
@ -208,11 +208,11 @@ export default Controller.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if an autosave is scheduled, cancel it, save then transition
|
// if an autosave is scheduled, cancel it, save then transition
|
||||||
if (this.get('_autosaveRunning')) {
|
if (this._autosaveRunning) {
|
||||||
this.send('cancelAutosave');
|
this.send('cancelAutosave');
|
||||||
this.get('autosave').cancelAll();
|
this.autosave.cancelAll();
|
||||||
|
|
||||||
return this.get('autosave').perform().then(() => {
|
return this.autosave.perform().then(() => {
|
||||||
transition.retry();
|
transition.retry();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -224,10 +224,10 @@ export default Controller.extend({
|
|||||||
|
|
||||||
// called by the "are you sure?" modal
|
// called by the "are you sure?" modal
|
||||||
leaveEditor() {
|
leaveEditor() {
|
||||||
let transition = this.get('leaveEditorTransition');
|
let transition = this.leaveEditorTransition;
|
||||||
|
|
||||||
if (!transition) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ export default Controller.extend({
|
|||||||
// separate task for autosave so that it doesn't override a manual save
|
// separate task for autosave so that it doesn't override a manual save
|
||||||
autosave: task(function* () {
|
autosave: task(function* () {
|
||||||
if (!this.get('save.isRunning')) {
|
if (!this.get('save.isRunning')) {
|
||||||
return yield this.get('save').perform({
|
return yield this.save.perform({
|
||||||
silent: true,
|
silent: true,
|
||||||
backgroundSave: true
|
backgroundSave: true
|
||||||
});
|
});
|
||||||
@ -285,7 +285,7 @@ export default Controller.extend({
|
|||||||
|
|
||||||
this.send('cancelAutosave');
|
this.send('cancelAutosave');
|
||||||
|
|
||||||
if (options.backgroundSave && !this.get('hasDirtyAttributes')) {
|
if (options.backgroundSave && !this.hasDirtyAttributes) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,11 +294,11 @@ export default Controller.extend({
|
|||||||
status = 'draft';
|
status = 'draft';
|
||||||
} else {
|
} else {
|
||||||
if (this.get('post.pastScheduledTime')) {
|
if (this.get('post.pastScheduledTime')) {
|
||||||
status = (!this.get('willSchedule') && !this.get('willPublish')) ? 'draft' : 'published';
|
status = (!this.willSchedule && !this.willPublish) ? 'draft' : 'published';
|
||||||
} else {
|
} else {
|
||||||
if (this.get('willPublish') && !this.get('post.isScheduled')) {
|
if (this.willPublish && !this.get('post.isScheduled')) {
|
||||||
status = 'published';
|
status = 'published';
|
||||||
} else if (this.get('willSchedule') && !this.get('post.isPublished')) {
|
} else if (this.willSchedule && !this.get('post.isPublished')) {
|
||||||
status = 'scheduled';
|
status = 'scheduled';
|
||||||
} else {
|
} else {
|
||||||
status = 'draft';
|
status = 'draft';
|
||||||
@ -338,23 +338,23 @@ export default Controller.extend({
|
|||||||
this.set('post.twitterDescription', this.get('post.twitterDescriptionScratch'));
|
this.set('post.twitterDescription', this.get('post.twitterDescriptionScratch'));
|
||||||
|
|
||||||
if (!this.get('post.slug')) {
|
if (!this.get('post.slug')) {
|
||||||
this.get('saveTitle').cancelAll();
|
this.saveTitle.cancelAll();
|
||||||
|
|
||||||
yield this.get('generateSlug').perform();
|
yield this.generateSlug.perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let post = yield this.get('post').save(options);
|
let post = yield this.post.save(options);
|
||||||
|
|
||||||
if (!options.silent) {
|
if (!options.silent) {
|
||||||
this._showSaveNotification(prevStatus, post.get('status'), isNew ? true : false);
|
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
|
// redirect to edit route if saving a new record
|
||||||
if (isNew && post.get('id')) {
|
if (isNew && post.get('id')) {
|
||||||
if (!this.get('leaveEditorTransition')) {
|
if (!this.leaveEditorTransition) {
|
||||||
this.replaceRoute('editor.edit', post);
|
this.replaceRoute('editor.edit', post);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -377,7 +377,7 @@ export default Controller.extend({
|
|||||||
throw undefined;
|
throw undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.get('post');
|
return this.post;
|
||||||
}
|
}
|
||||||
}).group('saveTasks'),
|
}).group('saveTasks'),
|
||||||
|
|
||||||
@ -398,7 +398,7 @@ export default Controller.extend({
|
|||||||
return;
|
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
|
// 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
|
// we end up with a slug that matches the existing slug, abort the change
|
||||||
@ -434,14 +434,14 @@ export default Controller.extend({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return yield this.get('post').save();
|
return yield this.post.save();
|
||||||
}).group('saveTasks'),
|
}).group('saveTasks'),
|
||||||
|
|
||||||
// used in the PSM so that saves are sequential and don't trigger collision
|
// used in the PSM so that saves are sequential and don't trigger collision
|
||||||
// detection errors
|
// detection errors
|
||||||
savePost: task(function* () {
|
savePost: task(function* () {
|
||||||
try {
|
try {
|
||||||
return yield this.get('post').save();
|
return yield this.post.save();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
let status = this.get('post.status');
|
let status = this.get('post.status');
|
||||||
@ -453,7 +453,7 @@ export default Controller.extend({
|
|||||||
}).group('saveTasks'),
|
}).group('saveTasks'),
|
||||||
|
|
||||||
saveTitle: task(function* () {
|
saveTitle: task(function* () {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
let currentTitle = post.get('title');
|
let currentTitle = post.get('title');
|
||||||
let newTitle = post.get('titleScratch').trim();
|
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
|
// generate a slug if a post is new and doesn't have a title yet or
|
||||||
// if the title is still '(Untitled)'
|
// if the title is still '(Untitled)'
|
||||||
if ((post.get('isNew') && !currentTitle) || currentTitle === DEFAULT_TITLE) {
|
if ((post.get('isNew') && !currentTitle) || currentTitle === DEFAULT_TITLE) {
|
||||||
yield this.get('generateSlug').perform();
|
yield this.generateSlug.perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.get('post.isDraft')) {
|
if (this.get('post.isDraft')) {
|
||||||
yield this.get('autosave').perform();
|
yield this.autosave.perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.send('updateDocumentTitle');
|
this.send('updateDocumentTitle');
|
||||||
@ -486,7 +486,7 @@ export default Controller.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let slug = yield this.get('slugGenerator').generateSlug('post', title);
|
let slug = yield this.slugGenerator.generateSlug('post', title);
|
||||||
|
|
||||||
if (!isBlank(slug)) {
|
if (!isBlank(slug)) {
|
||||||
this.set('post.slug', 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
|
// but a rejected promise needs to be handled here so that a resolved
|
||||||
// promise is returned.
|
// promise is returned.
|
||||||
if (isVersionMismatchError(error)) {
|
if (isVersionMismatchError(error)) {
|
||||||
this.get('notifications').showAPIError(error);
|
this.notifications.showAPIError(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).enqueue(),
|
}).enqueue(),
|
||||||
@ -506,7 +506,7 @@ export default Controller.extend({
|
|||||||
// called by the new/edit routes to change the post model
|
// called by the new/edit routes to change the post model
|
||||||
setPost(post) {
|
setPost(post) {
|
||||||
// don't do anything else if we're setting the same 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
|
// set autofocus as change signal to the persistent editor on new->edit
|
||||||
this.set('shouldFocusEditor', post.get('isNew'));
|
this.set('shouldFocusEditor', post.get('isNew'));
|
||||||
return;
|
return;
|
||||||
@ -526,13 +526,13 @@ export default Controller.extend({
|
|||||||
post.set('titleScratch', post.get('title'));
|
post.set('titleScratch', post.get('title'));
|
||||||
post.set('scratch', post.get('mobiledoc'));
|
post.set('scratch', post.get('mobiledoc'));
|
||||||
|
|
||||||
this._previousTagNames = this.get('_tagNames');
|
this._previousTagNames = this._tagNames;
|
||||||
this._attachModelHooks();
|
this._attachModelHooks();
|
||||||
|
|
||||||
// triggered any time the admin tab is closed, we need to use a native
|
// triggered any time the admin tab is closed, we need to use a native
|
||||||
// dialog here instead of our custom modal
|
// dialog here instead of our custom modal
|
||||||
window.onbeforeunload = () => {
|
window.onbeforeunload = () => {
|
||||||
if (this.get('hasDirtyAttributes')) {
|
if (this.hasDirtyAttributes) {
|
||||||
return '==============================\n\n'
|
return '==============================\n\n'
|
||||||
+ 'Hey there! It looks like you\'re in the middle of writing'
|
+ 'Hey there! It looks like you\'re in the middle of writing'
|
||||||
+ ' something and you haven\'t saved all of your content.'
|
+ ' 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
|
// which will either finish autosave then retry transition or abort and show
|
||||||
// the "are you sure?" modal
|
// the "are you sure?" modal
|
||||||
willTransition(transition) {
|
willTransition(transition) {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
|
|
||||||
// exit early and allow transition if we have no post, occurs if reset
|
// exit early and allow transition if we have no post, occurs if reset
|
||||||
// has already been called as in the `leaveEditor` action
|
// has already been called as in the `leaveEditor` action
|
||||||
@ -563,7 +563,7 @@ export default Controller.extend({
|
|||||||
this._koenig.cleanup();
|
this._koenig.cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
let hasDirtyAttributes = this.get('hasDirtyAttributes');
|
let hasDirtyAttributes = this.hasDirtyAttributes;
|
||||||
let state = post.getProperties('isDeleted', 'isSaving', 'hasDirtyAttributes', 'isNew');
|
let state = post.getProperties('isDeleted', 'isSaving', 'hasDirtyAttributes', 'isNew');
|
||||||
|
|
||||||
let fromNewToEdit = this.get('router.currentRouteName') === 'editor.new'
|
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
|
// called when the editor route is left or the post model is swapped
|
||||||
reset() {
|
reset() {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
|
|
||||||
// make sure the save tasks aren't still running in the background
|
// make sure the save tasks aren't still running in the background
|
||||||
// after leaving the edit route
|
// after leaving the edit route
|
||||||
@ -632,35 +632,35 @@ export default Controller.extend({
|
|||||||
|
|
||||||
// save 3 seconds after the last edit
|
// save 3 seconds after the last edit
|
||||||
_autosave: task(function* () {
|
_autosave: task(function* () {
|
||||||
if (!this.get('_canAutosave')) {
|
if (!this._canAutosave) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// force an instant save on first body edit for new posts
|
// force an instant save on first body edit for new posts
|
||||||
if (this.get('post.isNew')) {
|
if (this.get('post.isNew')) {
|
||||||
return this.get('autosave').perform();
|
return this.autosave.perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
yield timeout(AUTOSAVE_TIMEOUT);
|
yield timeout(AUTOSAVE_TIMEOUT);
|
||||||
this.get('autosave').perform();
|
this.autosave.perform();
|
||||||
}).restartable(),
|
}).restartable(),
|
||||||
|
|
||||||
// save at 60 seconds even if the user doesn't stop typing
|
// save at 60 seconds even if the user doesn't stop typing
|
||||||
_timedSave: task(function* () {
|
_timedSave: task(function* () {
|
||||||
if (!this.get('_canAutosave')) {
|
if (!this._canAutosave) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (config.environment !== 'test' && true) {
|
while (config.environment !== 'test' && true) {
|
||||||
yield timeout(TIMEDSAVE_TIMEOUT);
|
yield timeout(TIMEDSAVE_TIMEOUT);
|
||||||
this.get('autosave').perform();
|
this.autosave.perform();
|
||||||
}
|
}
|
||||||
}).drop(),
|
}).drop(),
|
||||||
|
|
||||||
/* Private methods -------------------------------------------------------*/
|
/* Private methods -------------------------------------------------------*/
|
||||||
|
|
||||||
_hasDirtyAttributes() {
|
_hasDirtyAttributes() {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
|
|
||||||
if (!post) {
|
if (!post) {
|
||||||
return false;
|
return false;
|
||||||
@ -681,7 +681,7 @@ export default Controller.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// titleScratch isn't an attr so needs a manual dirty check
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -714,7 +714,7 @@ export default Controller.extend({
|
|||||||
// add a .then in every instance we use model hooks to update our local
|
// add a .then in every instance we use model hooks to update our local
|
||||||
// values used for `hasDirtyAttributes`
|
// values used for `hasDirtyAttributes`
|
||||||
_attachModelHooks() {
|
_attachModelHooks() {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
if (post) {
|
if (post) {
|
||||||
post.on('didCreate', this, this._postSaved);
|
post.on('didCreate', this, this._postSaved);
|
||||||
post.on('didUpdate', this, this._postSaved);
|
post.on('didUpdate', this, this._postSaved);
|
||||||
@ -722,7 +722,7 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_detachModelHooks() {
|
_detachModelHooks() {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
if (post) {
|
if (post) {
|
||||||
post.off('didCreate', this, this._postSaved);
|
post.off('didCreate', this, this._postSaved);
|
||||||
post.off('didUpdate', this, this._postSaved);
|
post.off('didUpdate', this, this._postSaved);
|
||||||
@ -730,14 +730,14 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_postSaved() {
|
_postSaved() {
|
||||||
let post = this.get('post');
|
let post = this.post;
|
||||||
|
|
||||||
// remove any unsaved tags
|
// remove any unsaved tags
|
||||||
// NOTE: `updateTags` changes `hasDirtyAttributes => true`.
|
// NOTE: `updateTags` changes `hasDirtyAttributes => true`.
|
||||||
// For a saved post it would otherwise be false.
|
// For a saved post it would otherwise be false.
|
||||||
post.updateTags();
|
post.updateTags();
|
||||||
|
|
||||||
this._previousTagNames = this.get('_tagNames');
|
this._previousTagNames = this._tagNames;
|
||||||
|
|
||||||
// if the two "scratch" properties (title and content) match the post,
|
// if the two "scratch" properties (title and content) match the post,
|
||||||
// then it's ok to set hasDirtyAttributes to false
|
// then it's ok to set hasDirtyAttributes to false
|
||||||
@ -752,7 +752,7 @@ export default Controller.extend({
|
|||||||
|
|
||||||
_showSaveNotification(prevStatus, status, delay) {
|
_showSaveNotification(prevStatus, status, delay) {
|
||||||
let message = messageMap.success.post[prevStatus][status];
|
let message = messageMap.success.post[prevStatus][status];
|
||||||
let notifications = this.get('notifications');
|
let notifications = this.notifications;
|
||||||
let type, path;
|
let type, path;
|
||||||
|
|
||||||
if (status === 'published') {
|
if (status === 'published') {
|
||||||
@ -770,7 +770,7 @@ export default Controller.extend({
|
|||||||
|
|
||||||
_showErrorAlert(prevStatus, status, error, delay) {
|
_showErrorAlert(prevStatus, status, error, delay) {
|
||||||
let message = messageMap.errors.post[prevStatus][status];
|
let message = messageMap.errors.post[prevStatus][status];
|
||||||
let notifications = this.get('notifications');
|
let notifications = this.notifications;
|
||||||
let errorMessage;
|
let errorMessage;
|
||||||
|
|
||||||
function isString(str) {
|
function isString(str) {
|
||||||
|
@ -12,7 +12,7 @@ export default Controller.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
message: computed('error.statusText', function () {
|
message: computed('error.statusText', function () {
|
||||||
if (this.get('code') === 404) {
|
if (this.code === 404) {
|
||||||
return 'Page not found';
|
return 'Page not found';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@ export default Controller.extend(ValidationEngine, {
|
|||||||
email: computed('token', function () {
|
email: computed('token', function () {
|
||||||
// The token base64 encodes the email (and some other stuff),
|
// The token base64 encodes the email (and some other stuff),
|
||||||
// each section is divided by a '|'. Email comes second.
|
// each section is divided by a '|'. Email comes second.
|
||||||
return atob(this.get('token')).split('|')[1];
|
return atob(this.token).split('|')[1];
|
||||||
}),
|
}),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
submit() {
|
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');
|
let authUrl = this.get('ghostPaths.url').api('authentication', 'passwordreset');
|
||||||
|
|
||||||
this.set('flowErrors', '');
|
this.set('flowErrors', '');
|
||||||
this.get('hasValidated').addObjects(['newPassword', 'ne2Password']);
|
this.hasValidated.addObjects(['newPassword', 'ne2Password']);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
yield this.validate();
|
yield this.validate();
|
||||||
try {
|
try {
|
||||||
let resp = yield this.get('ajax').put(authUrl, {
|
let resp = yield this.ajax.put(authUrl, {
|
||||||
data: {
|
data: {
|
||||||
passwordreset: [credentials]
|
passwordreset: [credentials]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.get('notifications').showAlert(resp.passwordreset[0].message, {type: 'warn', delayed: true, key: 'password.reset'});
|
this.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.session.authenticate('authenticator:cookie', this.email, credentials.newPassword);
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.get('notifications').showAPIError(error, {key: 'password.reset'});
|
this.notifications.showAPIError(error, {key: 'password.reset'});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (this.get('errors.newPassword')) {
|
if (this.get('errors.newPassword')) {
|
||||||
|
@ -9,13 +9,13 @@ export default Controller.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
save() {
|
save() {
|
||||||
this.get('save').perform();
|
this.save.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleLeaveSettingsModal(transition) {
|
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('leaveSettingsTransition', null);
|
||||||
this.set('showLeaveSettingsModal', false);
|
this.set('showLeaveSettingsModal', false);
|
||||||
return;
|
return;
|
||||||
@ -37,11 +37,11 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
leaveSettings() {
|
leaveSettings() {
|
||||||
let transition = this.get('leaveSettingsTransition');
|
let transition = this.leaveSettingsTransition;
|
||||||
let settings = this.get('settings');
|
let settings = this.settings;
|
||||||
|
|
||||||
if (!transition) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,10 +54,10 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
save: task(function* () {
|
save: task(function* () {
|
||||||
let notifications = this.get('notifications');
|
let notifications = this.notifications;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return yield this.get('settings').save();
|
return yield this.settings.save();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.showAPIError(error, {key: 'code-injection.save'});
|
notifications.showAPIError(error, {key: 'code-injection.save'});
|
||||||
throw error;
|
throw error;
|
||||||
|
@ -38,11 +38,11 @@ export default Controller.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
save() {
|
save() {
|
||||||
this.get('save').perform();
|
this.save.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
addNavItem() {
|
addNavItem() {
|
||||||
let newNavItem = this.get('newNavItem');
|
let newNavItem = this.newNavItem;
|
||||||
|
|
||||||
// If the url sent through is blank (user never edited the url)
|
// If the url sent through is blank (user never edited the url)
|
||||||
if (newNavItem.get('url') === '') {
|
if (newNavItem.get('url') === '') {
|
||||||
@ -86,9 +86,9 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
toggleLeaveSettingsModal(transition) {
|
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('leaveSettingsTransition', null);
|
||||||
this.set('showLeaveSettingsModal', false);
|
this.set('showLeaveSettingsModal', false);
|
||||||
return;
|
return;
|
||||||
@ -110,11 +110,11 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
leaveSettings() {
|
leaveSettings() {
|
||||||
let transition = this.get('leaveSettingsTransition');
|
let transition = this.leaveSettingsTransition;
|
||||||
let settings = this.get('settings');
|
let settings = this.settings;
|
||||||
|
|
||||||
if (!transition) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ export default Controller.extend({
|
|||||||
this.set('showThemeWarningsModal', true);
|
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.
|
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...`;
|
You are still able to use and activate the theme. Here is your report...`;
|
||||||
this.set('message', message);
|
this.set('message', message);
|
||||||
@ -210,8 +210,8 @@ export default Controller.extend({
|
|||||||
|
|
||||||
save: task(function* () {
|
save: task(function* () {
|
||||||
let navItems = this.get('settings.navigation');
|
let navItems = this.get('settings.navigation');
|
||||||
let newNavItem = this.get('newNavItem');
|
let newNavItem = this.newNavItem;
|
||||||
let notifications = this.get('notifications');
|
let notifications = this.notifications;
|
||||||
let validationPromises = [];
|
let validationPromises = [];
|
||||||
|
|
||||||
if (!newNavItem.get('isBlank')) {
|
if (!newNavItem.get('isBlank')) {
|
||||||
@ -225,7 +225,7 @@ export default Controller.extend({
|
|||||||
try {
|
try {
|
||||||
yield RSVP.all(validationPromises);
|
yield RSVP.all(validationPromises);
|
||||||
this.set('dirtyAttributes', false);
|
this.set('dirtyAttributes', false);
|
||||||
return yield this.get('settings').save();
|
return yield this.settings.save();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
notifications.showAPIError(error);
|
notifications.showAPIError(error);
|
||||||
@ -236,7 +236,7 @@ export default Controller.extend({
|
|||||||
|
|
||||||
addNewNavItem() {
|
addNewNavItem() {
|
||||||
let navItems = this.get('settings.navigation');
|
let navItems = this.get('settings.navigation');
|
||||||
let newNavItem = this.get('newNavItem');
|
let newNavItem = this.newNavItem;
|
||||||
|
|
||||||
newNavItem.set('isNew', false);
|
newNavItem.set('isNew', false);
|
||||||
navItems.pushObject(newNavItem);
|
navItems.pushObject(newNavItem);
|
||||||
@ -246,7 +246,7 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_deleteTheme() {
|
_deleteTheme() {
|
||||||
let theme = this.get('store').peekRecord('theme', this.get('themeToDelete').name);
|
let theme = this.store.peekRecord('theme', this.themeToDelete.name);
|
||||||
|
|
||||||
if (!theme) {
|
if (!theme) {
|
||||||
return;
|
return;
|
||||||
@ -258,7 +258,7 @@ export default Controller.extend({
|
|||||||
// attempt to update the deleted record
|
// attempt to update the deleted record
|
||||||
theme.unloadRecord();
|
theme.unloadRecord();
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.get('notifications').showAPIError(error);
|
this.notifications.showAPIError(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -44,7 +44,7 @@ export default Controller.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
save() {
|
save() {
|
||||||
this.get('save').perform();
|
this.save.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
setTimezone(timezone) {
|
setTimezone(timezone) {
|
||||||
@ -53,7 +53,7 @@ export default Controller.extend({
|
|||||||
|
|
||||||
removeImage(image) {
|
removeImage(image) {
|
||||||
// setting `null` here will error as the server treats it as "null"
|
// 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) {
|
imageUploaded(property, results) {
|
||||||
if (results[0]) {
|
if (results[0]) {
|
||||||
return this.get('settings').set(property, results[0].url);
|
return this.settings.set(property, results[0].url);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleIsPrivate(isPrivate) {
|
toggleIsPrivate(isPrivate) {
|
||||||
let settings = this.get('settings');
|
let settings = this.settings;
|
||||||
|
|
||||||
settings.set('isPrivate', isPrivate);
|
settings.set('isPrivate', isPrivate);
|
||||||
settings.get('errors').remove('password');
|
settings.get('errors').remove('password');
|
||||||
@ -102,9 +102,9 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
toggleLeaveSettingsModal(transition) {
|
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('leaveSettingsTransition', null);
|
||||||
this.set('showLeaveSettingsModal', false);
|
this.set('showLeaveSettingsModal', false);
|
||||||
return;
|
return;
|
||||||
@ -126,11 +126,11 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
leaveSettings() {
|
leaveSettings() {
|
||||||
let transition = this.get('leaveSettingsTransition');
|
let transition = this.leaveSettingsTransition;
|
||||||
let settings = this.get('settings');
|
let settings = this.settings;
|
||||||
|
|
||||||
if (!transition) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
validateFacebookUrl() {
|
validateFacebookUrl() {
|
||||||
let newUrl = this.get('_scratchFacebook');
|
let newUrl = this._scratchFacebook;
|
||||||
let oldUrl = this.get('settings.facebook');
|
let oldUrl = this.get('settings.facebook');
|
||||||
let errMessage = '';
|
let errMessage = '';
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
validateTwitterUrl() {
|
validateTwitterUrl() {
|
||||||
let newUrl = this.get('_scratchTwitter');
|
let newUrl = this._scratchTwitter;
|
||||||
let oldUrl = this.get('settings.twitter');
|
let oldUrl = this.get('settings.twitter');
|
||||||
let errMessage = '';
|
let errMessage = '';
|
||||||
|
|
||||||
@ -253,23 +253,23 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_deleteTheme() {
|
_deleteTheme() {
|
||||||
let theme = this.get('store').peekRecord('theme', this.get('themeToDelete').name);
|
let theme = this.store.peekRecord('theme', this.themeToDelete.name);
|
||||||
|
|
||||||
if (!theme) {
|
if (!theme) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return theme.destroyRecord().catch((error) => {
|
return theme.destroyRecord().catch((error) => {
|
||||||
this.get('notifications').showAPIError(error);
|
this.notifications.showAPIError(error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
save: task(function* () {
|
save: task(function* () {
|
||||||
let notifications = this.get('notifications');
|
let notifications = this.notifications;
|
||||||
let config = this.get('config');
|
let config = this.config;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let settings = yield this.get('settings').save();
|
let settings = yield this.settings.save();
|
||||||
config.set('blogTitle', settings.get('title'));
|
config.set('blogTitle', settings.get('title'));
|
||||||
|
|
||||||
// this forces the document title to recompute after
|
// this forces the document title to recompute after
|
||||||
|
@ -18,13 +18,13 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
this.get('save').perform();
|
this.save.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleLeaveSettingsModal(transition) {
|
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('leaveSettingsTransition', null);
|
||||||
this.set('showLeaveSettingsModal', false);
|
this.set('showLeaveSettingsModal', false);
|
||||||
return;
|
return;
|
||||||
@ -46,11 +46,11 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
leaveSettings() {
|
leaveSettings() {
|
||||||
let transition = this.get('leaveSettingsTransition');
|
let transition = this.leaveSettingsTransition;
|
||||||
let settings = this.get('settings');
|
let settings = this.settings;
|
||||||
|
|
||||||
if (!transition) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,15 +62,15 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
save: task(function* () {
|
save: task(function* () {
|
||||||
let amp = this.get('ampSettings');
|
let amp = this.ampSettings;
|
||||||
let settings = this.get('settings');
|
let settings = this.settings;
|
||||||
|
|
||||||
settings.set('amp', amp);
|
settings.set('amp', amp);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return yield settings.save();
|
return yield settings.save();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.get('notifications').showAPIError(error);
|
this.notifications.showAPIError(error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}).drop()
|
}).drop()
|
||||||
|
@ -25,7 +25,7 @@ export default Controller.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
save() {
|
save() {
|
||||||
this.get('save').perform();
|
this.save.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
updateURL(value) {
|
updateURL(value) {
|
||||||
@ -41,9 +41,9 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
triggerDirtyState() {
|
triggerDirtyState() {
|
||||||
let slack = this.get('slackSettings');
|
let slack = this.slackSettings;
|
||||||
let slackArray = this.get('slackArray');
|
let slackArray = this.slackArray;
|
||||||
let settings = this.get('settings');
|
let settings = this.settings;
|
||||||
|
|
||||||
// Hack to trigger the `isDirty` state on the settings model by setting a new Array
|
// 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
|
// for slack rather that replacing the existing one which would still point to the
|
||||||
@ -53,9 +53,9 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
toggleLeaveSettingsModal(transition) {
|
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('leaveSettingsTransition', null);
|
||||||
this.set('showLeaveSettingsModal', false);
|
this.set('showLeaveSettingsModal', false);
|
||||||
return;
|
return;
|
||||||
@ -77,12 +77,12 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
leaveSettings() {
|
leaveSettings() {
|
||||||
let transition = this.get('leaveSettingsTransition');
|
let transition = this.leaveSettingsTransition;
|
||||||
let settings = this.get('settings');
|
let settings = this.settings;
|
||||||
let slackArray = this.get('slackArray');
|
let slackArray = this.slackArray;
|
||||||
|
|
||||||
if (!transition) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,9 +95,9 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
save: task(function* () {
|
save: task(function* () {
|
||||||
let slack = this.get('slackSettings');
|
let slack = this.slackSettings;
|
||||||
let settings = this.get('settings');
|
let settings = this.settings;
|
||||||
let slackArray = this.get('slackArray');
|
let slackArray = this.slackArray;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
yield slack.validate();
|
yield slack.validate();
|
||||||
@ -107,19 +107,19 @@ export default Controller.extend({
|
|||||||
return yield settings.save();
|
return yield settings.save();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
this.get('notifications').showAPIError(error);
|
this.notifications.showAPIError(error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).drop(),
|
}).drop(),
|
||||||
|
|
||||||
sendTestNotification: task(function* () {
|
sendTestNotification: task(function* () {
|
||||||
let notifications = this.get('notifications');
|
let notifications = this.notifications;
|
||||||
let slackApi = this.get('ghostPaths.url').api('slack', 'test');
|
let slackApi = this.get('ghostPaths.url').api('slack', 'test');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
yield this.get('save').perform();
|
yield this.save.perform();
|
||||||
yield this.get('ajax').post(slackApi);
|
yield this.ajax.post(slackApi);
|
||||||
notifications.showNotification('Check your Slack channel for the test message!', {type: 'info', key: 'slack-test.send.success'});
|
notifications.showNotification('Check your Slack channel for the test message!', {type: 'info', key: 'slack-test.send.success'});
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -16,11 +16,11 @@ export default Controller.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
save() {
|
save() {
|
||||||
this.get('save').perform();
|
this.save.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
update(value) {
|
update(value) {
|
||||||
if (!this.get('dirtyAttributes')) {
|
if (!this.dirtyAttributes) {
|
||||||
this.set('rollbackValue', this.get('unsplashSettings.isActive'));
|
this.set('rollbackValue', this.get('unsplashSettings.isActive'));
|
||||||
}
|
}
|
||||||
this.set('unsplashSettings.isActive', value);
|
this.set('unsplashSettings.isActive', value);
|
||||||
@ -28,9 +28,9 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
toggleLeaveSettingsModal(transition) {
|
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('leaveSettingsTransition', null);
|
||||||
this.set('showLeaveSettingsModal', false);
|
this.set('showLeaveSettingsModal', false);
|
||||||
return;
|
return;
|
||||||
@ -52,15 +52,15 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
leaveSettings() {
|
leaveSettings() {
|
||||||
let transition = this.get('leaveSettingsTransition');
|
let transition = this.leaveSettingsTransition;
|
||||||
|
|
||||||
if (!transition) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// roll back changes on model props
|
// 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('dirtyAttributes', false);
|
||||||
this.set('rollbackValue', null);
|
this.set('rollbackValue', null);
|
||||||
|
|
||||||
@ -69,8 +69,8 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
save: task(function* () {
|
save: task(function* () {
|
||||||
let unsplash = this.get('unsplashSettings');
|
let unsplash = this.unsplashSettings;
|
||||||
let settings = this.get('settings');
|
let settings = this.settings;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
settings.set('unsplash', unsplash);
|
settings.set('unsplash', unsplash);
|
||||||
@ -79,7 +79,7 @@ export default Controller.extend({
|
|||||||
return yield settings.save();
|
return yield settings.save();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
this.get('notifications').showAPIError(error);
|
this.notifications.showAPIError(error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ export default Controller.extend({
|
|||||||
actions: {
|
actions: {
|
||||||
onUpload(file) {
|
onUpload(file) {
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
let notifications = this.get('notifications');
|
let notifications = this.notifications;
|
||||||
let currentUserId = this.get('session.user.id');
|
let currentUserId = this.get('session.user.id');
|
||||||
let dbUrl = this.get('ghostPaths.url').api('db');
|
let dbUrl = this.get('ghostPaths.url').api('db');
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ export default Controller.extend({
|
|||||||
return this._validate(file).then(() => {
|
return this._validate(file).then(() => {
|
||||||
formData.append('importfile', file);
|
formData.append('importfile', file);
|
||||||
|
|
||||||
return this.get('ajax').post(dbUrl, {
|
return this.ajax.post(dbUrl, {
|
||||||
data: formData,
|
data: formData,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
cache: false,
|
cache: false,
|
||||||
@ -103,7 +103,7 @@ export default Controller.extend({
|
|||||||
processData: false
|
processData: false
|
||||||
});
|
});
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
let store = this.get('store');
|
let store = this.store;
|
||||||
|
|
||||||
this.set('importSuccessful', true);
|
this.set('importSuccessful', true);
|
||||||
|
|
||||||
@ -126,9 +126,9 @@ export default Controller.extend({
|
|||||||
notifications.showNotification('Import successful.', {key: 'import.upload.success'});
|
notifications.showNotification('Import successful.', {key: 'import.upload.success'});
|
||||||
|
|
||||||
// reload settings
|
// reload settings
|
||||||
return this.get('settings').reload().then((settings) => {
|
return this.settings.reload().then((settings) => {
|
||||||
this.get('feature').fetch();
|
this.feature.fetch();
|
||||||
this.get('config').set('blogTitle', settings.get('title'));
|
this.config.set('blogTitle', settings.get('title'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).catch((response) => {
|
}).catch((response) => {
|
||||||
@ -187,7 +187,7 @@ export default Controller.extend({
|
|||||||
});
|
});
|
||||||
let stripeConfig = stripeProcessor.config;
|
let stripeConfig = stripeProcessor.config;
|
||||||
stripeConfig.product = {
|
stripeConfig.product = {
|
||||||
name: this.get('settings').get('title')
|
name: this.settings.get('title')
|
||||||
};
|
};
|
||||||
if (key === 'isPaid') {
|
if (key === 'isPaid') {
|
||||||
subscriptionSettings.isPaid = event;
|
subscriptionSettings.isPaid = event;
|
||||||
@ -219,7 +219,7 @@ export default Controller.extend({
|
|||||||
secret_token: '',
|
secret_token: '',
|
||||||
public_token: '',
|
public_token: '',
|
||||||
product: {
|
product: {
|
||||||
name: this.get('settings').get('title')
|
name: this.settings.get('title')
|
||||||
},
|
},
|
||||||
plans: [
|
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) {
|
if (!isBlank(accept) && file && accept.indexOf(file.type) === -1) {
|
||||||
return RSVP.reject(new UnsupportedMediaTypeError());
|
return RSVP.reject(new UnsupportedMediaTypeError());
|
||||||
@ -283,11 +283,11 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
sendTestEmail: task(function* () {
|
sendTestEmail: task(function* () {
|
||||||
let notifications = this.get('notifications');
|
let notifications = this.notifications;
|
||||||
let emailUrl = this.get('ghostPaths.url').api('mail', 'test');
|
let emailUrl = this.get('ghostPaths.url').api('mail', 'test');
|
||||||
|
|
||||||
try {
|
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'});
|
notifications.showAlert('Check your email for the test message.', {type: 'info', key: 'test-email.send.success'});
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -297,7 +297,7 @@ export default Controller.extend({
|
|||||||
|
|
||||||
saveSettings: task(function* () {
|
saveSettings: task(function* () {
|
||||||
try {
|
try {
|
||||||
return yield this.get('settings').save();
|
return yield this.settings.save();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_saveTagProperty(propKey, newValue) {
|
_saveTagProperty(propKey, newValue) {
|
||||||
let tag = this.get('tag');
|
let tag = this.tag;
|
||||||
let isNewTag = tag.get('isNew');
|
let isNewTag = tag.get('isNew');
|
||||||
let currentValue = tag.get(propKey);
|
let currentValue = tag.get(propKey);
|
||||||
|
|
||||||
@ -61,13 +61,13 @@ export default Controller.extend({
|
|||||||
}
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
this.get('notifications').showAPIError(error, {key: 'tag.save'});
|
this.notifications.showAPIError(error, {key: 'tag.save'});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_deleteTag() {
|
_deleteTag() {
|
||||||
let tag = this.get('tag');
|
let tag = this.tag;
|
||||||
|
|
||||||
return tag.destroyRecord().then(() => {
|
return tag.destroyRecord().then(() => {
|
||||||
this._deleteTagSuccess();
|
this._deleteTagSuccess();
|
||||||
@ -85,6 +85,6 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_deleteTagFailure(error) {
|
_deleteTagFailure(error) {
|
||||||
this.get('notifications').showAPIError(error, {key: 'tag.delete'});
|
this.notifications.showAPIError(error, {key: 'tag.delete'});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -26,8 +26,8 @@ export default Controller.extend({
|
|||||||
ownerEmail: alias('two.email'),
|
ownerEmail: alias('two.email'),
|
||||||
|
|
||||||
usersArray: computed('users', function () {
|
usersArray: computed('users', function () {
|
||||||
let errors = this.get('errors');
|
let errors = this.errors;
|
||||||
let users = this.get('users').split('\n').filter(function (email) {
|
let users = this.users.split('\n').filter(function (email) {
|
||||||
return email.trim().length > 0;
|
return email.trim().length > 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -42,23 +42,23 @@ export default Controller.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
validUsersArray: computed('usersArray', 'ownerEmail', function () {
|
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;
|
return validator.isEmail(user || '') && user !== ownerEmail;
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
|
||||||
invalidUsersArray: computed('usersArray', 'ownerEmail', function () {
|
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 () {
|
validationResult: computed('invalidUsersArray', function () {
|
||||||
let errors = [];
|
let errors = [];
|
||||||
|
|
||||||
this.get('invalidUsersArray').forEach((user) => {
|
this.invalidUsersArray.forEach((user) => {
|
||||||
errors.push({
|
errors.push({
|
||||||
user,
|
user,
|
||||||
error: 'email'
|
error: 'email'
|
||||||
@ -67,7 +67,7 @@ export default Controller.extend({
|
|||||||
|
|
||||||
if (errors.length === 0) {
|
if (errors.length === 0) {
|
||||||
// ensure we aren't highlighting fields when everything is fine
|
// ensure we aren't highlighting fields when everything is fine
|
||||||
this.get('errors').clear();
|
this.errors.clear();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return errors;
|
return errors;
|
||||||
@ -76,8 +76,8 @@ export default Controller.extend({
|
|||||||
|
|
||||||
buttonText: computed('errors.users', 'validUsersArray', 'invalidUsersArray', function () {
|
buttonText: computed('errors.users', 'validUsersArray', 'invalidUsersArray', function () {
|
||||||
let usersError = this.get('errors.users.firstObject.message');
|
let usersError = this.get('errors.users.firstObject.message');
|
||||||
let validNum = this.get('validUsersArray').length;
|
let validNum = this.validUsersArray.length;
|
||||||
let invalidNum = this.get('invalidUsersArray').length;
|
let invalidNum = this.invalidUsersArray.length;
|
||||||
let userCount;
|
let userCount;
|
||||||
|
|
||||||
if (usersError && usersError.match(/no users/i)) {
|
if (usersError && usersError.match(/no users/i)) {
|
||||||
@ -100,7 +100,7 @@ export default Controller.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
buttonClass: computed('validationResult', 'usersArray.length', function () {
|
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';
|
return 'gh-btn-green';
|
||||||
} else {
|
} else {
|
||||||
return 'gh-btn-minor';
|
return 'gh-btn-minor';
|
||||||
@ -117,7 +117,7 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
invite() {
|
invite() {
|
||||||
this.get('invite').perform();
|
this.invite.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
skipInvite() {
|
skipInvite() {
|
||||||
@ -127,14 +127,14 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
validate() {
|
validate() {
|
||||||
let errors = this.get('errors');
|
let errors = this.errors;
|
||||||
let validationResult = this.get('validationResult');
|
let validationResult = this.validationResult;
|
||||||
let property = 'users';
|
let property = 'users';
|
||||||
|
|
||||||
errors.clear();
|
errors.clear();
|
||||||
|
|
||||||
// If property isn't in the `hasValidated` array, add it to mark that this field can show a validation result
|
// 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) {
|
if (validationResult === true) {
|
||||||
return true;
|
return true;
|
||||||
@ -159,17 +159,17 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
invite: task(function* () {
|
invite: task(function* () {
|
||||||
let users = this.get('validUsersArray');
|
let users = this.validUsersArray;
|
||||||
|
|
||||||
if (this.validate() && users.length > 0) {
|
if (this.validate() && users.length > 0) {
|
||||||
this._hasTransitioned = false;
|
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);
|
let invites = yield this._saveInvites(authorRole);
|
||||||
|
|
||||||
this.get('_slowSubmissionTimeout').cancelAll();
|
this._slowSubmissionTimeout.cancelAll();
|
||||||
|
|
||||||
this._showNotifications(invites);
|
this._showNotifications(invites);
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ export default Controller.extend({
|
|||||||
this._transitionAfterSubmission();
|
this._transitionAfterSubmission();
|
||||||
});
|
});
|
||||||
} else if (users.length === 0) {
|
} else if (users.length === 0) {
|
||||||
this.get('errors').add('users', 'No users to invite');
|
this.errors.add('users', 'No users to invite');
|
||||||
}
|
}
|
||||||
}).drop(),
|
}).drop(),
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ export default Controller.extend({
|
|||||||
}).drop(),
|
}).drop(),
|
||||||
|
|
||||||
_saveInvites(authorRole) {
|
_saveInvites(authorRole) {
|
||||||
let users = this.get('validUsersArray');
|
let users = this.validUsersArray;
|
||||||
|
|
||||||
return RSVP.Promise.all(
|
return RSVP.Promise.all(
|
||||||
users.map((user) => {
|
users.map((user) => {
|
||||||
@ -210,7 +210,7 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_showNotifications(invites) {
|
_showNotifications(invites) {
|
||||||
let notifications = this.get('notifications');
|
let notifications = this.notifications;
|
||||||
let erroredEmails = [];
|
let erroredEmails = [];
|
||||||
let successCount = 0;
|
let successCount = 0;
|
||||||
let invitationsString, message;
|
let invitationsString, message;
|
||||||
|
@ -30,7 +30,7 @@ export default Controller.extend(ValidationEngine, {
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
setup() {
|
setup() {
|
||||||
this.get('setup').perform();
|
this.setup.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
preValidate(model) {
|
preValidate(model) {
|
||||||
@ -54,16 +54,16 @@ export default Controller.extend(ValidationEngine, {
|
|||||||
this.set('session.skipAuthSuccessHandler', true);
|
this.set('session.skipAuthSuccessHandler', true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let authResult = yield this.get('session')
|
let authResult = yield this.session
|
||||||
.authenticate(authStrategy, ...authentication);
|
.authenticate(authStrategy, ...authentication);
|
||||||
|
|
||||||
this.get('errors').remove('session');
|
this.errors.remove('session');
|
||||||
|
|
||||||
return authResult;
|
return authResult;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error && error.payload && error.payload.errors) {
|
if (error && error.payload && error.payload.errors) {
|
||||||
if (isVersionMismatchError(error)) {
|
if (isVersionMismatchError(error)) {
|
||||||
return this.get('notifications').showAPIError(error);
|
return this.notifications.showAPIError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
error.payload.errors.forEach((err) => {
|
error.payload.errors.forEach((err) => {
|
||||||
@ -73,7 +73,7 @@ export default Controller.extend(ValidationEngine, {
|
|||||||
this.set('flowErrors', error.payload.errors[0].message.string);
|
this.set('flowErrors', error.payload.errors[0].message.string);
|
||||||
} else {
|
} else {
|
||||||
// Connection errors don't return proper status message, only req.body
|
// 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) {
|
_sendImage(user) {
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
let imageFile = this.get('profileImage');
|
let imageFile = this.profileImage;
|
||||||
let uploadUrl = this.get('ghostPaths.url').api('images', 'upload');
|
let uploadUrl = this.get('ghostPaths.url').api('images', 'upload');
|
||||||
|
|
||||||
formData.append('file', imageFile, imageFile.name);
|
formData.append('file', imageFile, imageFile.name);
|
||||||
formData.append('purpose', 'profile_image');
|
formData.append('purpose', 'profile_image');
|
||||||
|
|
||||||
return this.get('ajax').post(uploadUrl, {
|
return this.ajax.post(uploadUrl, {
|
||||||
data: formData,
|
data: formData,
|
||||||
processData: false,
|
processData: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
@ -102,7 +102,7 @@ export default Controller.extend(ValidationEngine, {
|
|||||||
let usersUrl = this.get('ghostPaths.url').api('users', user.id.toString());
|
let usersUrl = this.get('ghostPaths.url').api('users', user.id.toString());
|
||||||
user.profile_image = imageUrl;
|
user.profile_image = imageUrl;
|
||||||
|
|
||||||
return this.get('ajax').put(usersUrl, {
|
return this.ajax.put(usersUrl, {
|
||||||
data: {
|
data: {
|
||||||
users: [user]
|
users: [user]
|
||||||
}
|
}
|
||||||
@ -113,17 +113,17 @@ export default Controller.extend(ValidationEngine, {
|
|||||||
_passwordSetup() {
|
_passwordSetup() {
|
||||||
let setupProperties = ['blogTitle', 'name', 'email', 'password'];
|
let setupProperties = ['blogTitle', 'name', 'email', 'password'];
|
||||||
let data = this.getProperties(setupProperties);
|
let data = this.getProperties(setupProperties);
|
||||||
let config = this.get('config');
|
let config = this.config;
|
||||||
let method = this.get('blogCreated') ? 'put' : 'post';
|
let method = this.blogCreated ? 'put' : 'post';
|
||||||
|
|
||||||
this.set('flowErrors', '');
|
this.set('flowErrors', '');
|
||||||
|
|
||||||
this.get('hasValidated').addObjects(setupProperties);
|
this.hasValidated.addObjects(setupProperties);
|
||||||
|
|
||||||
return this.validate().then(() => {
|
return this.validate().then(() => {
|
||||||
let authUrl = this.get('ghostPaths.url').api('authentication', 'setup');
|
let authUrl = this.get('ghostPaths.url').api('authentication', 'setup');
|
||||||
|
|
||||||
return this.get('ajax')[method](authUrl, {
|
return this.ajax[method](authUrl, {
|
||||||
data: {
|
data: {
|
||||||
setup: [{
|
setup: [{
|
||||||
name: data.name,
|
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
|
// Don't call the success handler, otherwise we will be redirected to admin
|
||||||
this.set('session.skipAuthSuccessHandler', true);
|
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);
|
this.set('blogCreated', true);
|
||||||
return this._afterAuthentication(result);
|
return this._afterAuthentication(result);
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
@ -163,7 +163,7 @@ export default Controller.extend(ValidationEngine, {
|
|||||||
if (isInvalidError(resp)) {
|
if (isInvalidError(resp)) {
|
||||||
this.set('flowErrors', resp.payload.errors[0].message);
|
this.set('flowErrors', resp.payload.errors[0].message);
|
||||||
} else {
|
} 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);
|
this.set('flowErrors', error.payload.errors[0].message);
|
||||||
} else {
|
} else {
|
||||||
// Connection errors don't return proper status message, only req.body
|
// 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) {
|
_afterAuthentication(result) {
|
||||||
// fetch settings and private config for synchronous access before transitioning
|
// fetch settings and private config for synchronous access before transitioning
|
||||||
let fetchSettingsAndConfig = RSVP.all([
|
let fetchSettingsAndConfig = RSVP.all([
|
||||||
this.get('settings').fetch()
|
this.settings.fetch()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (this.get('profileImage')) {
|
if (this.profileImage) {
|
||||||
return this._sendImage(result.users[0])
|
return this._sendImage(result.users[0])
|
||||||
.then(() => (fetchSettingsAndConfig))
|
.then(() => (fetchSettingsAndConfig))
|
||||||
.then(() => (this.transitionToRoute('setup.three')))
|
.then(() => (this.transitionToRoute('setup.three')))
|
||||||
.catch((resp) => {
|
.catch((resp) => {
|
||||||
this.get('notifications').showAPIError(resp, {key: 'setup.blog-details'});
|
this.notifications.showAPIError(resp, {key: 'setup.blog-details'});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return fetchSettingsAndConfig.then(() => this.transitionToRoute('setup.three'));
|
return fetchSettingsAndConfig.then(() => this.transitionToRoute('setup.three'));
|
||||||
|
@ -34,18 +34,18 @@ export default Controller.extend(ValidationEngine, {
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
authenticate() {
|
authenticate() {
|
||||||
this.get('validateAndAuthenticate').perform();
|
this.validateAndAuthenticate.perform();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
authenticate: task(function* (authStrategy, authentication) {
|
authenticate: task(function* (authStrategy, authentication) {
|
||||||
try {
|
try {
|
||||||
let authResult = yield this.get('session')
|
let authResult = yield this.session
|
||||||
.authenticate(authStrategy, ...authentication);
|
.authenticate(authStrategy, ...authentication);
|
||||||
let promises = [];
|
let promises = [];
|
||||||
|
|
||||||
promises.pushObject(this.get('settings').fetch());
|
promises.pushObject(this.settings.fetch());
|
||||||
promises.pushObject(this.get('config').fetchAuthenticated());
|
promises.pushObject(this.config.fetchAuthenticated());
|
||||||
|
|
||||||
// fetch settings and private config for synchronous access
|
// fetch settings and private config for synchronous access
|
||||||
yield RSVP.all(promises);
|
yield RSVP.all(promises);
|
||||||
@ -53,7 +53,7 @@ export default Controller.extend(ValidationEngine, {
|
|||||||
return authResult;
|
return authResult;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (isVersionMismatchError(error)) {
|
if (isVersionMismatchError(error)) {
|
||||||
return this.get('notifications').showAPIError(error);
|
return this.notifications.showAPIError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error && error.payload && error.payload.errors) {
|
if (error && error.payload && error.payload.errors) {
|
||||||
@ -73,7 +73,7 @@ export default Controller.extend(ValidationEngine, {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Connection errors don't return proper status message, only req.body
|
// 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.',
|
'There was a problem on the server.',
|
||||||
{type: 'error', key: 'session.authenticate.failed'}
|
{type: 'error', key: 'session.authenticate.failed'}
|
||||||
);
|
);
|
||||||
@ -82,7 +82,7 @@ export default Controller.extend(ValidationEngine, {
|
|||||||
}).drop(),
|
}).drop(),
|
||||||
|
|
||||||
validateAndAuthenticate: task(function* () {
|
validateAndAuthenticate: task(function* () {
|
||||||
let signin = this.get('signin');
|
let signin = this.signin;
|
||||||
let authStrategy = 'authenticator:cookie';
|
let authStrategy = 'authenticator:cookie';
|
||||||
|
|
||||||
this.set('flowErrors', '');
|
this.set('flowErrors', '');
|
||||||
@ -91,11 +91,11 @@ export default Controller.extend(ValidationEngine, {
|
|||||||
$('#login').find('input').trigger('change');
|
$('#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 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 {
|
try {
|
||||||
yield this.validate({property: 'signin'});
|
yield this.validate({property: 'signin'});
|
||||||
return yield this.get('authenticate')
|
return yield this.authenticate
|
||||||
.perform(authStrategy, [signin.get('identification'), signin.get('password')]);
|
.perform(authStrategy, [signin.get('identification'), signin.get('password')]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.set('flowErrors', 'Please fill out the form to sign in.');
|
this.set('flowErrors', 'Please fill out the form to sign in.');
|
||||||
@ -105,15 +105,15 @@ export default Controller.extend(ValidationEngine, {
|
|||||||
forgotten: task(function* () {
|
forgotten: task(function* () {
|
||||||
let email = this.get('signin.identification');
|
let email = this.get('signin.identification');
|
||||||
let forgottenUrl = this.get('ghostPaths.url').api('authentication', 'passwordreset');
|
let forgottenUrl = this.get('ghostPaths.url').api('authentication', 'passwordreset');
|
||||||
let notifications = this.get('notifications');
|
let notifications = this.notifications;
|
||||||
|
|
||||||
this.set('flowErrors', '');
|
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 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 {
|
try {
|
||||||
yield this.validate({property: 'forgotPassword'});
|
yield this.validate({property: 'forgotPassword'});
|
||||||
yield this.get('ajax').post(forgottenUrl, {data: {passwordreset: [{email}]}});
|
yield this.ajax.post(forgottenUrl, {data: {passwordreset: [{email}]}});
|
||||||
notifications.showAlert(
|
notifications.showAlert(
|
||||||
'Please check your email for instructions.',
|
'Please check your email for instructions.',
|
||||||
{type: 'info', key: 'forgot-password.send.success'}
|
{type: 'info', key: 'forgot-password.send.success'}
|
||||||
|
@ -38,7 +38,7 @@ export default Controller.extend({
|
|||||||
|
|
||||||
signup: task(function* () {
|
signup: task(function* () {
|
||||||
let setupProperties = ['name', 'email', 'password', 'token'];
|
let setupProperties = ['name', 'email', 'password', 'token'];
|
||||||
let notifications = this.get('notifications');
|
let notifications = this.notifications;
|
||||||
|
|
||||||
this.set('flowErrors', '');
|
this.set('flowErrors', '');
|
||||||
this.get('signupDetails.hasValidated').addObjects(setupProperties);
|
this.get('signupDetails.hasValidated').addObjects(setupProperties);
|
||||||
@ -73,9 +73,9 @@ export default Controller.extend({
|
|||||||
|
|
||||||
_completeInvitation() {
|
_completeInvitation() {
|
||||||
let authUrl = this.get('ghostPaths.url').api('authentication', 'invitation');
|
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',
|
dataType: 'json',
|
||||||
data: {
|
data: {
|
||||||
invitation: [{
|
invitation: [{
|
||||||
@ -92,13 +92,13 @@ export default Controller.extend({
|
|||||||
let email = this.get('signupDetails.email');
|
let email = this.get('signupDetails.email');
|
||||||
let password = this.get('signupDetails.password');
|
let password = this.get('signupDetails.password');
|
||||||
|
|
||||||
return this.get('session')
|
return this.session
|
||||||
.authenticate('authenticator:cookie', email, password);
|
.authenticate('authenticator:cookie', email, password);
|
||||||
},
|
},
|
||||||
|
|
||||||
_sendImage: task(function* () {
|
_sendImage: task(function* () {
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
let imageFile = this.get('profileImage');
|
let imageFile = this.profileImage;
|
||||||
let uploadUrl = this.get('ghostPaths.url').api('images', 'upload');
|
let uploadUrl = this.get('ghostPaths.url').api('images', 'upload');
|
||||||
|
|
||||||
if (imageFile) {
|
if (imageFile) {
|
||||||
@ -106,7 +106,7 @@ export default Controller.extend({
|
|||||||
formData.append('purpose', 'profile_image');
|
formData.append('purpose', 'profile_image');
|
||||||
|
|
||||||
let user = yield this.get('session.user');
|
let user = yield this.get('session.user');
|
||||||
let response = yield this.get('ajax').post(uploadUrl, {
|
let response = yield this.ajax.post(uploadUrl, {
|
||||||
data: formData,
|
data: formData,
|
||||||
processData: false,
|
processData: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
|
@ -53,8 +53,8 @@ export default Controller.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
deleteUserActionIsVisible: computed('currentUser', 'canAssignRoles', 'user', function () {
|
deleteUserActionIsVisible: computed('currentUser', 'canAssignRoles', 'user', function () {
|
||||||
if ((this.get('canAssignRoles') && this.get('isNotOwnProfile') && !this.get('user.isOwner'))
|
if ((this.canAssignRoles && this.isNotOwnProfile && !this.get('user.isOwner'))
|
||||||
|| (this.get('currentUser.isEditor') && (this.get('isNotOwnProfile')
|
|| (this.get('currentUser.isEditor') && (this.isNotOwnProfile
|
||||||
|| this.get('user.isAuthorOrContributor')))) {
|
|| this.get('user.isAuthorOrContributor')))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ export default Controller.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
changeRole(newRole) {
|
changeRole(newRole) {
|
||||||
this.get('user').set('role', newRole);
|
this.user.set('role', newRole);
|
||||||
this.set('dirtyAttributes', true);
|
this.set('dirtyAttributes', true);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -83,35 +83,35 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
toggleDeleteUserModal() {
|
toggleDeleteUserModal() {
|
||||||
if (this.get('deleteUserActionIsVisible')) {
|
if (this.deleteUserActionIsVisible) {
|
||||||
this.toggleProperty('showDeleteUserModal');
|
this.toggleProperty('showDeleteUserModal');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
suspendUser() {
|
suspendUser() {
|
||||||
this.get('user').set('status', 'inactive');
|
this.user.set('status', 'inactive');
|
||||||
return this.get('save').perform();
|
return this.save.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleSuspendUserModal() {
|
toggleSuspendUserModal() {
|
||||||
if (this.get('deleteUserActionIsVisible')) {
|
if (this.deleteUserActionIsVisible) {
|
||||||
this.toggleProperty('showSuspendUserModal');
|
this.toggleProperty('showSuspendUserModal');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
unsuspendUser() {
|
unsuspendUser() {
|
||||||
this.get('user').set('status', 'active');
|
this.user.set('status', 'active');
|
||||||
return this.get('save').perform();
|
return this.save.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleUnsuspendUserModal() {
|
toggleUnsuspendUserModal() {
|
||||||
if (this.get('deleteUserActionIsVisible')) {
|
if (this.deleteUserActionIsVisible) {
|
||||||
this.toggleProperty('showUnsuspendUserModal');
|
this.toggleProperty('showUnsuspendUserModal');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
validateFacebookUrl() {
|
validateFacebookUrl() {
|
||||||
let newUrl = this.get('_scratchFacebook');
|
let newUrl = this._scratchFacebook;
|
||||||
let oldUrl = this.get('user.facebook');
|
let oldUrl = this.get('user.facebook');
|
||||||
let errMessage = '';
|
let errMessage = '';
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
validateTwitterUrl() {
|
validateTwitterUrl() {
|
||||||
let newUrl = this.get('_scratchTwitter');
|
let newUrl = this._scratchTwitter;
|
||||||
let oldUrl = this.get('user.twitter');
|
let oldUrl = this.get('user.twitter');
|
||||||
let errMessage = '';
|
let errMessage = '';
|
||||||
|
|
||||||
@ -222,12 +222,12 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
transferOwnership() {
|
transferOwnership() {
|
||||||
let user = this.get('user');
|
let user = this.user;
|
||||||
let url = this.get('ghostPaths.url').api('users', 'owner');
|
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: {
|
data: {
|
||||||
owner: [{
|
owner: [{
|
||||||
id: user.get('id')
|
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) => {
|
}).catch((error) => {
|
||||||
this.get('notifications').showAPIError(error, {key: 'owner.transfer'});
|
this.notifications.showAPIError(error, {key: 'owner.transfer'});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleLeaveSettingsModal(transition) {
|
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('leaveSettingsTransition', null);
|
||||||
this.set('showLeaveSettingsModal', false);
|
this.set('showLeaveSettingsModal', false);
|
||||||
return;
|
return;
|
||||||
@ -276,18 +276,18 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
leaveSettings() {
|
leaveSettings() {
|
||||||
let transition = this.get('leaveSettingsTransition');
|
let transition = this.leaveSettingsTransition;
|
||||||
let user = this.get('user');
|
let user = this.user;
|
||||||
|
|
||||||
if (!transition) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// roll back changes on user props
|
// roll back changes on user props
|
||||||
user.rollbackAttributes();
|
user.rollbackAttributes();
|
||||||
// roll back the slugValue property
|
// roll back the slugValue property
|
||||||
if (this.get('dirtyAttributes')) {
|
if (this.dirtyAttributes) {
|
||||||
this.set('slugValue', user.get('slug'));
|
this.set('slugValue', user.get('slug'));
|
||||||
this.set('dirtyAttributes', false);
|
this.set('dirtyAttributes', false);
|
||||||
}
|
}
|
||||||
@ -296,7 +296,7 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
toggleTransferOwnerModal() {
|
toggleTransferOwnerModal() {
|
||||||
if (this.get('canMakeOwner')) {
|
if (this.canMakeOwner) {
|
||||||
this.toggleProperty('showTransferOwnerModal');
|
this.toggleProperty('showTransferOwnerModal');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -331,20 +331,20 @@ export default Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_deleteUser() {
|
_deleteUser() {
|
||||||
if (this.get('deleteUserActionIsVisible')) {
|
if (this.deleteUserActionIsVisible) {
|
||||||
let user = this.get('user');
|
let user = this.user;
|
||||||
return user.destroyRecord();
|
return user.destroyRecord();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_deleteUserSuccess() {
|
_deleteUserSuccess() {
|
||||||
this.get('notifications').closeAlerts('user.delete');
|
this.notifications.closeAlerts('user.delete');
|
||||||
this.store.unloadAll('post');
|
this.store.unloadAll('post');
|
||||||
this.transitionToRoute('staff');
|
this.transitionToRoute('staff');
|
||||||
},
|
},
|
||||||
|
|
||||||
_deleteUserFailure() {
|
_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) {
|
updateSlug: task(function* (newSlug) {
|
||||||
@ -360,7 +360,7 @@ export default Controller.extend({
|
|||||||
return true;
|
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
|
// 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
|
// we end up with a slug that matches the existing slug, abort the change
|
||||||
@ -395,8 +395,8 @@ export default Controller.extend({
|
|||||||
}).group('saveHandlers'),
|
}).group('saveHandlers'),
|
||||||
|
|
||||||
save: task(function* () {
|
save: task(function* () {
|
||||||
let user = this.get('user');
|
let user = this.user;
|
||||||
let slugValue = this.get('slugValue');
|
let slugValue = this.slugValue;
|
||||||
let slugChanged;
|
let slugChanged;
|
||||||
|
|
||||||
if (user.get('slug') !== slugValue) {
|
if (user.get('slug') !== slugValue) {
|
||||||
@ -420,14 +420,14 @@ export default Controller.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.set('dirtyAttributes', false);
|
this.set('dirtyAttributes', false);
|
||||||
this.get('notifications').closeAlerts('user.update');
|
this.notifications.closeAlerts('user.update');
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// validation engine returns undefined so we have to check
|
// validation engine returns undefined so we have to check
|
||||||
// before treating the failure as an API error
|
// before treating the failure as an API error
|
||||||
if (error) {
|
if (error) {
|
||||||
this.get('notifications').showAPIError(error, {key: 'user.update'});
|
this.notifications.showAPIError(error, {key: 'user.update'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).group('saveHandlers')
|
}).group('saveHandlers')
|
||||||
|
@ -25,8 +25,8 @@ export default Controller.extend(PaginationMixin, {
|
|||||||
// getter/setter CP here so that we don't lose the dynamic order param
|
// getter/setter CP here so that we don't lose the dynamic order param
|
||||||
paginationSettings: computed('order', 'direction', {
|
paginationSettings: computed('order', 'direction', {
|
||||||
get() {
|
get() {
|
||||||
let order = this.get('order');
|
let order = this.order;
|
||||||
let direction = this.get('direction');
|
let direction = this.direction;
|
||||||
|
|
||||||
let currentSettings = this._paginationSettings || {
|
let currentSettings = this._paginationSettings || {
|
||||||
limit: 30
|
limit: 30
|
||||||
@ -43,8 +43,8 @@ export default Controller.extend(PaginationMixin, {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
columns: computed('order', 'direction', function () {
|
columns: computed('order', 'direction', function () {
|
||||||
let order = this.get('order');
|
let order = this.order;
|
||||||
let direction = this.get('direction');
|
let direction = this.direction;
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
label: 'Email Address',
|
label: 'Email Address',
|
||||||
@ -82,7 +82,7 @@ export default Controller.extend(PaginationMixin, {
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
loadFirstPage() {
|
loadFirstPage() {
|
||||||
let table = this.get('table');
|
let table = this.table;
|
||||||
|
|
||||||
return this._super(...arguments).then((results) => {
|
return this._super(...arguments).then((results) => {
|
||||||
table.addRows(results);
|
table.addRows(results);
|
||||||
@ -91,7 +91,7 @@ export default Controller.extend(PaginationMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
loadNextPage() {
|
loadNextPage() {
|
||||||
let table = this.get('table');
|
let table = this.table;
|
||||||
|
|
||||||
return this._super(...arguments).then((results) => {
|
return this._super(...arguments).then((results) => {
|
||||||
table.addRows(results);
|
table.addRows(results);
|
||||||
@ -100,7 +100,7 @@ export default Controller.extend(PaginationMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
sortByColumn(column) {
|
sortByColumn(column) {
|
||||||
let table = this.get('table');
|
let table = this.table;
|
||||||
|
|
||||||
if (column.sorted) {
|
if (column.sorted) {
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
@ -113,7 +113,7 @@ export default Controller.extend(PaginationMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
addSubscriber(subscriber) {
|
addSubscriber(subscriber) {
|
||||||
this.get('table').insertRowAt(0, subscriber);
|
this.table.insertRowAt(0, subscriber);
|
||||||
this.incrementProperty('total');
|
this.incrementProperty('total');
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -122,11 +122,11 @@ export default Controller.extend(PaginationMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
confirmDeleteSubscriber() {
|
confirmDeleteSubscriber() {
|
||||||
let subscriber = this.get('subscriberToDelete');
|
let subscriber = this.subscriberToDelete;
|
||||||
|
|
||||||
return subscriber.destroyRecord().then(() => {
|
return subscriber.destroyRecord().then(() => {
|
||||||
this.set('subscriberToDelete', null);
|
this.set('subscriberToDelete', null);
|
||||||
this.get('table').removeRow(subscriber);
|
this.table.removeRow(subscriber);
|
||||||
this.decrementProperty('total');
|
this.decrementProperty('total');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -136,7 +136,7 @@ export default Controller.extend(PaginationMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
this.get('table').setRows([]);
|
this.table.setRows([]);
|
||||||
this.send('loadFirstPage');
|
this.send('loadFirstPage');
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ export default Controller.extend(PaginationMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
initializeTable() {
|
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
|
// capture the total from the server any time we fetch a new page
|
||||||
|
@ -32,11 +32,11 @@ export default Mixin.create({
|
|||||||
|
|
||||||
this._clickHandler = event => this.bodyClick(event);
|
this._clickHandler = event => this.bodyClick(event);
|
||||||
|
|
||||||
return $(this.get('bodyElementSelector')).on('click', this._clickHandler);
|
return $(this.bodyElementSelector).on('click', this._clickHandler);
|
||||||
},
|
},
|
||||||
|
|
||||||
_removeDocumentHandlers() {
|
_removeDocumentHandlers() {
|
||||||
$(this.get('bodyElementSelector')).off('click', this._clickHandler);
|
$(this.bodyElementSelector).off('click', this._clickHandler);
|
||||||
this._clickHandler = null;
|
this._clickHandler = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import Mixin from '@ember/object/mixin';
|
import Mixin from '@ember/object/mixin';
|
||||||
import RSVP from 'rsvp';
|
import RSVP from 'rsvp';
|
||||||
// import {assign} from '@ember/polyfills';
|
// import { assign } from '@ember/polyfills';
|
||||||
import {computed} from '@ember/object';
|
import {computed} from '@ember/object';
|
||||||
import {inject as service} from '@ember/service';
|
import {inject as service} from '@ember/service';
|
||||||
|
|
||||||
@ -51,18 +51,18 @@ export default Mixin.create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
reportLoadError(error) {
|
reportLoadError(error) {
|
||||||
this.get('notifications').showAPIError(error, {key: 'pagination.load.failed'});
|
this.notifications.showAPIError(error, {key: 'pagination.load.failed'});
|
||||||
},
|
},
|
||||||
|
|
||||||
loadFirstPage(transition) {
|
loadFirstPage(transition) {
|
||||||
let paginationSettings = this.get('paginationSettings');
|
let paginationSettings = this.paginationSettings;
|
||||||
let modelName = this.get('paginationModel');
|
let modelName = this.paginationModel;
|
||||||
|
|
||||||
this.set('paginationSettings.page', 1);
|
this.set('paginationSettings.page', 1);
|
||||||
|
|
||||||
this.set('isLoading', true);
|
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);
|
this.set('paginationMeta', results.meta);
|
||||||
return results;
|
return results;
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
@ -88,13 +88,13 @@ export default Mixin.create({
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
loadNextPage() {
|
loadNextPage() {
|
||||||
let store = this.get('store');
|
let store = this.store;
|
||||||
let modelName = this.get('paginationModel');
|
let modelName = this.paginationModel;
|
||||||
let metadata = this.get('paginationMeta');
|
let metadata = this.paginationMeta;
|
||||||
let nextPage = metadata.pagination && metadata.pagination.next;
|
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('isLoading', true);
|
||||||
this.set('paginationSettings.page', nextPage);
|
this.set('paginationSettings.page', nextPage);
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ export default Mixin.create({
|
|||||||
},
|
},
|
||||||
set(key, value) {
|
set(key, value) {
|
||||||
// Not viewing a subview if we can't even see the PSM
|
// Not viewing a subview if we can't even see the PSM
|
||||||
if (!this.get('showSettingsMenu')) {
|
if (!this.showSettingsMenu) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
@ -46,7 +46,7 @@ key.setScope('default');
|
|||||||
export default Mixin.create({
|
export default Mixin.create({
|
||||||
|
|
||||||
registerShortcuts() {
|
registerShortcuts() {
|
||||||
let shortcuts = this.get('shortcuts');
|
let shortcuts = this.shortcuts;
|
||||||
|
|
||||||
Object.keys(shortcuts).forEach((shortcut) => {
|
Object.keys(shortcuts).forEach((shortcut) => {
|
||||||
let scope = shortcuts[shortcut].scope || 'default';
|
let scope = shortcuts[shortcut].scope || 'default';
|
||||||
@ -69,7 +69,7 @@ export default Mixin.create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
removeShortcuts() {
|
removeShortcuts() {
|
||||||
let shortcuts = this.get('shortcuts');
|
let shortcuts = this.shortcuts;
|
||||||
|
|
||||||
Object.keys(shortcuts).forEach((shortcut) => {
|
Object.keys(shortcuts).forEach((shortcut) => {
|
||||||
let scope = shortcuts[shortcut].scope || 'default';
|
let scope = shortcuts[shortcut].scope || 'default';
|
||||||
|
@ -5,7 +5,7 @@ import {run} from '@ember/runloop';
|
|||||||
// mixin used for routes that need to set a css className on the body tag
|
// mixin used for routes that need to set a css className on the body tag
|
||||||
export default Mixin.create({
|
export default Mixin.create({
|
||||||
activate() {
|
activate() {
|
||||||
let cssClasses = this.get('classNames');
|
let cssClasses = this.classNames;
|
||||||
|
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ export default Mixin.create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
deactivate() {
|
deactivate() {
|
||||||
let cssClasses = this.get('classNames');
|
let cssClasses = this.classNames;
|
||||||
|
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ export default Mixin.create({
|
|||||||
stopEnterKeyDownPropagation: false,
|
stopEnterKeyDownPropagation: false,
|
||||||
|
|
||||||
autofocus: computed(function () {
|
autofocus: computed(function () {
|
||||||
if (this.get('shouldFocus')) {
|
if (this.shouldFocus) {
|
||||||
return (this.userAgent.os.isIOS) ? false : 'autofocus';
|
return (this.userAgent.os.isIOS) ? false : 'autofocus';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ export default Mixin.create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
click(event) {
|
click(event) {
|
||||||
if (this.get('selectOnClick')) {
|
if (this.selectOnClick) {
|
||||||
event.currentTarget.select();
|
event.currentTarget.select();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -39,7 +39,7 @@ export default Mixin.create({
|
|||||||
// stop event propagation when pressing "enter"
|
// stop event propagation when pressing "enter"
|
||||||
// most useful in the case when undesired (global) keyboard shortcuts
|
// most useful in the case when undesired (global) keyboard shortcuts
|
||||||
// are getting triggered while interacting with this particular input element.
|
// 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();
|
event.stopPropagation();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -75,7 +75,7 @@ export default Mixin.create({
|
|||||||
_focus() {
|
_focus() {
|
||||||
// Until mobile safari has better support
|
// Until mobile safari has better support
|
||||||
// for focusing, we just ignore it
|
// for focusing, we just ignore it
|
||||||
if (this.get('shouldFocus') && !this.userAgent.os.isIOS) {
|
if (this.shouldFocus && !this.userAgent.os.isIOS) {
|
||||||
this.element.focus();
|
this.element.focus();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -13,7 +13,7 @@ export default Mixin.create({
|
|||||||
let authUrl = this.get('ghostPaths.url').api('authentication', 'setup');
|
let authUrl = this.get('ghostPaths.url').api('authentication', 'setup');
|
||||||
|
|
||||||
// check the state of the setup process via the API
|
// 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;
|
let [setup] = result.setup;
|
||||||
|
|
||||||
if (setup.status !== true) {
|
if (setup.status !== true) {
|
||||||
@ -22,8 +22,8 @@ export default Mixin.create({
|
|||||||
// NOTE: this is the same as ESA's UnauthenticatedRouteMixin,
|
// NOTE: this is the same as ESA's UnauthenticatedRouteMixin,
|
||||||
// adding that mixin to this and calling _super wasn't calling
|
// adding that mixin to this and calling _super wasn't calling
|
||||||
// the ESA mixin's beforeModel method
|
// the ESA mixin's beforeModel method
|
||||||
if (this.get('session').get('isAuthenticated')) {
|
if (this.session.get('isAuthenticated')) {
|
||||||
let routeIfAlreadyAuthenticated = this.get('routeIfAlreadyAuthenticated');
|
let routeIfAlreadyAuthenticated = this.routeIfAlreadyAuthenticated;
|
||||||
|
|
||||||
return this.transitionTo(routeIfAlreadyAuthenticated);
|
return this.transitionTo(routeIfAlreadyAuthenticated);
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,13 +87,13 @@ export default Mixin.create({
|
|||||||
model = opts.model;
|
model = opts.model;
|
||||||
} else if (this instanceof Model) {
|
} else if (this instanceof Model) {
|
||||||
model = this;
|
model = this;
|
||||||
} else if (this.get('model')) {
|
} else if (this.model) {
|
||||||
model = this.get('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}`);
|
validator = this.get(`validators.${type}`) || model.get(`validators.${type}`);
|
||||||
hasValidated = this.get('hasValidated');
|
hasValidated = this.hasValidated;
|
||||||
|
|
||||||
opts.validationType = type;
|
opts.validationType = type;
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ export default Mixin.create({
|
|||||||
// model.destroyRecord() calls model.save() behind the scenes.
|
// model.destroyRecord() calls model.save() behind the scenes.
|
||||||
// in that case, we don't need validation checks or error propagation,
|
// in that case, we don't need validation checks or error propagation,
|
||||||
// because the model itself is being destroyed.
|
// because the model itself is being destroyed.
|
||||||
if (this.get('isDeleted')) {
|
if (this.isDeleted) {
|
||||||
return this._super(...arguments);
|
return this._super(...arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@ export default Mixin.create({
|
|||||||
hasError: false,
|
hasError: false,
|
||||||
|
|
||||||
setHasError() {
|
setHasError() {
|
||||||
let property = this.get('property');
|
let property = this.property;
|
||||||
let errors = this.get('errors');
|
let errors = this.errors;
|
||||||
let hasValidated = this.get('hasValidated');
|
let hasValidated = this.hasValidated;
|
||||||
|
|
||||||
// if we aren't looking at a specific property we always want an error class
|
// if we aren't looking at a specific property we always want an error class
|
||||||
if (!property && errors && !errors.get('isEmpty')) {
|
if (!property && errors && !errors.get('isEmpty')) {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user