0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Merge pull request #6611 from dbalders/ember-navitems

Remove Nav Item Placeholder and Set as Base Url Value
This commit is contained in:
Kevin Ansfield 2016-03-22 16:18:28 +01:00
commit 94abaca531
5 changed files with 5 additions and 34 deletions

View file

@ -20,16 +20,11 @@ let isRelative = function (url) {
export default TextField.extend({
classNames: 'gh-input',
classNameBindings: ['fakePlaceholder'],
isBaseUrl: computed('baseUrl', 'value', function () {
return this.get('baseUrl') === this.get('value');
}),
fakePlaceholder: computed('isBaseUrl', 'hasFocus', 'isNew', function () {
return this.get('isBaseUrl') && this.get('isNew') && !this.get('hasFocus');
}),
didReceiveAttrs() {
this._super(...arguments);

View file

@ -122,6 +122,11 @@ export default Controller.extend(SettingsSaveMixin, {
addItem() {
let newNavItem = this.get('newNavItem');
// If the url sent through is blank (user never edited the url)
if (newNavItem.get('url') === '') {
newNavItem.set('url', '/');
}
return newNavItem.validate().then(() => {
this.addNewNavItem();
});

View file

@ -34,10 +34,6 @@
cursor: move;
}
.gh-blognav-url .fake-placeholder {
color: #c1c1c1;
}
.gh-blognav-line {
display: flex;
width: 100%;

View file

@ -150,11 +150,6 @@ describe('Acceptance: Settings - Navigation', function () {
find('.gh-blognav-label:last .response').is(':visible'),
'blank label has validation error'
).to.be.true;
expect(
find('.gh-blognav-url:last .response').is(':visible'),
'blank url has validation error'
).to.be.true;
});
fillIn('.gh-blognav-label:last input', 'New');
@ -165,11 +160,6 @@ describe('Acceptance: Settings - Navigation', function () {
find('.gh-blognav-label:last .response').is(':visible'),
'label validation is visible after typing'
).to.be.false;
expect(
find('.gh-blognav-url:last .response').is(':visible'),
'blank url still has validation error'
).to.be.true;
});
fillIn('.gh-blognav-url:last input', '/new');

View file

@ -189,21 +189,6 @@ describeComponent(
expect($input.val()).to.equal(`${currentUrl} /test`);
});
it('toggles .fake-placeholder on focus', function () {
this.set('isNew', true);
this.render(hbs `
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
`);
let $input = this.$('input');
expect($input.hasClass('fake-placeholder')).to.be.true;
run(() => {
$input.trigger('focus');
});
expect($input.hasClass('fake-placeholder')).to.be.false;
});
it('triggers "change" action on blur', function () {
let changeActionCallCount = 0;
this.on('updateUrl', () => {