mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 12:21:36 +03:00
d8728aad57
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
32 lines
827 B
JavaScript
32 lines
827 B
JavaScript
import Ember from 'ember';
|
|
|
|
export default Ember.Mixin.create({
|
|
|
|
errors: null,
|
|
property: '',
|
|
hasValidated: Ember.A(),
|
|
|
|
hasError: Ember.computed('errors.[]', 'property', 'hasValidated.[]', function () {
|
|
var property = this.get('property'),
|
|
errors = this.get('errors'),
|
|
hasValidated = this.get('hasValidated');
|
|
|
|
// if we aren't looking at a specific property we always want an error class
|
|
if (!property && !Ember.isEmpty(errors)) {
|
|
return true;
|
|
}
|
|
|
|
// If we haven't yet validated this field, there is no validation class needed
|
|
if (!hasValidated || !hasValidated.contains(property)) {
|
|
return false;
|
|
}
|
|
|
|
if (errors) {
|
|
return errors.get(property);
|
|
}
|
|
|
|
return false;
|
|
})
|
|
|
|
});
|