2015-02-13 07:22:32 +03:00
|
|
|
import Ember from 'ember';
|
2015-09-16 20:02:06 +03:00
|
|
|
import ValidationStateMixin from 'ghost/mixins/validation-state';
|
2015-06-13 17:34:09 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
const {Component, computed} = Ember;
|
|
|
|
|
|
|
|
export default Component.extend(ValidationStateMixin, {
|
2015-05-25 16:17:14 +03:00
|
|
|
classNames: 'gh-blognav-item',
|
2015-09-16 20:02:06 +03:00
|
|
|
classNameBindings: ['errorClass'],
|
2015-01-18 03:16:54 +03:00
|
|
|
|
2015-02-03 19:29:01 +03:00
|
|
|
attributeBindings: ['order:data-order'],
|
2015-10-28 14:36:45 +03:00
|
|
|
order: computed.readOnly('navItem.order'),
|
|
|
|
errors: computed.readOnly('navItem.errors'),
|
2015-09-16 20:02:06 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
errorClass: computed('hasError', function () {
|
2015-09-16 20:02:06 +03:00
|
|
|
if (this.get('hasError')) {
|
|
|
|
return 'gh-blognav-item--error';
|
|
|
|
}
|
|
|
|
}),
|
2015-02-03 19:29:01 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
keyPress(event) {
|
2015-01-18 03:16:54 +03:00
|
|
|
// enter key
|
|
|
|
if (event.keyCode === 13) {
|
|
|
|
event.preventDefault();
|
2015-06-13 17:34:09 +03:00
|
|
|
this.send('addItem');
|
2015-01-18 03:16:54 +03:00
|
|
|
}
|
2015-09-16 20:02:06 +03:00
|
|
|
|
|
|
|
this.get('navItem.errors').clear();
|
2015-01-18 03:16:54 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2015-10-28 14:36:45 +03:00
|
|
|
addItem() {
|
2015-01-18 03:16:54 +03:00
|
|
|
this.sendAction('addItem');
|
|
|
|
},
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
deleteItem(item) {
|
2015-01-18 03:16:54 +03:00
|
|
|
this.sendAction('deleteItem', item);
|
|
|
|
},
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
updateUrl(value) {
|
2015-01-18 03:16:54 +03:00
|
|
|
this.sendAction('updateUrl', value, this.get('navItem'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|