mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
fda94fedab
no issue - https://github.com/ember-cli/eslint-plugin-ember/blob/HEAD/docs/rules/alias-model-in-controller.md - replace `model` with a meaningful property name everywhere possible - refactor `design` and `general` settings controllers to use a directly injected settings service rather than passing it in as a "model" to be more explicit
69 lines
1.7 KiB
JavaScript
69 lines
1.7 KiB
JavaScript
import Component from '@ember/component';
|
|
import ValidationState from 'ghost-admin/mixins/validation-state';
|
|
import {computed} from '@ember/object';
|
|
import {readOnly} from '@ember/object/computed';
|
|
import {run} from '@ember/runloop';
|
|
|
|
export default Component.extend(ValidationState, {
|
|
classNames: 'gh-blognav-item',
|
|
classNameBindings: ['errorClass', 'navItem.isNew::gh-blognav-item--sortable'],
|
|
|
|
new: false,
|
|
|
|
errors: readOnly('navItem.errors'),
|
|
|
|
errorClass: computed('hasError', function () {
|
|
if (this.get('hasError')) {
|
|
return 'gh-blognav-item--error';
|
|
}
|
|
}),
|
|
|
|
keyPress(event) {
|
|
// enter key
|
|
if (event.keyCode === 13 && this.get('navItem.isNew')) {
|
|
event.preventDefault();
|
|
run.scheduleOnce('actions', this, function () {
|
|
this.send('addItem');
|
|
});
|
|
}
|
|
},
|
|
|
|
actions: {
|
|
addItem() {
|
|
let action = this.get('addItem');
|
|
if (action) {
|
|
action();
|
|
}
|
|
},
|
|
|
|
deleteItem(item) {
|
|
let action = this.get('deleteItem');
|
|
if (action) {
|
|
action(item);
|
|
}
|
|
},
|
|
|
|
updateUrl(value) {
|
|
let action = this.get('updateUrl');
|
|
if (action) {
|
|
action(value, this.get('navItem'));
|
|
}
|
|
},
|
|
|
|
updateLabel(value) {
|
|
let action = this.get('updateLabel');
|
|
if (action) {
|
|
action(value, this.get('navItem'));
|
|
}
|
|
},
|
|
|
|
clearLabelErrors() {
|
|
this.get('navItem.errors').remove('label');
|
|
},
|
|
|
|
clearUrlErrors() {
|
|
this.get('navItem.errors').remove('url');
|
|
}
|
|
}
|
|
});
|