Remove Nav Item Placeholder and Set as Base Url Value

Closes #6440

* Removed the `.fake-placeholder`class from the input, test, and css
* On adding a nav item, if the url value has not been set by the user,
then set it to the base url as shown in the input
* If url has been set by the user, just do what it has always done
This commit is contained in:
David Balderston 2016-03-18 08:32:03 -07:00
parent ef0945b09f
commit 9eb0a8a690
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', () => {