Ghost/core/client/app/components/gh-navitem.js
Kevin Ansfield 52089705d7 Fix nav regressions in admin client
issue #5841

- fix relative link checks in navlink url input component
- fix navlink url input component sending absolute URLs instead of relative URLs to action handler
- remove URL manipulation in navigation settings controller (url input handles URL manipulation, validator flags anything that's still incorrect)
- capture cmd-s in url input to ensure changes are actioned before save
- automatically add mailto: to e-mail addresses
- add gh-validation-state-container component so .error/.success validation classes can be applied to any container element
- add validation-state mixin that can be mixed in to any other component to give it access to validation status (used in gh-navitem component to keep alignment when inline error message elements are added)
- validate and display inline errors on save
- improve ember test coverage for navigation settings related controller and components
2015-09-23 17:05:41 +01:00

42 lines
1.1 KiB
JavaScript

import Ember from 'ember';
import ValidationStateMixin from 'ghost/mixins/validation-state';
export default Ember.Component.extend(ValidationStateMixin, {
classNames: 'gh-blognav-item',
classNameBindings: ['errorClass'],
attributeBindings: ['order:data-order'],
order: Ember.computed.readOnly('navItem.order'),
errors: Ember.computed.readOnly('navItem.errors'),
errorClass: Ember.computed('hasError', function () {
if (this.get('hasError')) {
return 'gh-blognav-item--error';
}
}),
keyPress: function (event) {
// enter key
if (event.keyCode === 13) {
event.preventDefault();
this.send('addItem');
}
this.get('navItem.errors').clear();
},
actions: {
addItem: function () {
this.sendAction('addItem');
},
deleteItem: function (item) {
this.sendAction('deleteItem', item);
},
updateUrl: function (value) {
this.sendAction('updateUrl', value, this.get('navItem'));
}
}
});