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:
commit
94abaca531
5 changed files with 5 additions and 34 deletions
|
@ -20,16 +20,11 @@ let isRelative = function (url) {
|
||||||
|
|
||||||
export default TextField.extend({
|
export default TextField.extend({
|
||||||
classNames: 'gh-input',
|
classNames: 'gh-input',
|
||||||
classNameBindings: ['fakePlaceholder'],
|
|
||||||
|
|
||||||
isBaseUrl: computed('baseUrl', 'value', function () {
|
isBaseUrl: computed('baseUrl', 'value', function () {
|
||||||
return this.get('baseUrl') === this.get('value');
|
return this.get('baseUrl') === this.get('value');
|
||||||
}),
|
}),
|
||||||
|
|
||||||
fakePlaceholder: computed('isBaseUrl', 'hasFocus', 'isNew', function () {
|
|
||||||
return this.get('isBaseUrl') && this.get('isNew') && !this.get('hasFocus');
|
|
||||||
}),
|
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,11 @@ export default Controller.extend(SettingsSaveMixin, {
|
||||||
addItem() {
|
addItem() {
|
||||||
let newNavItem = this.get('newNavItem');
|
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(() => {
|
return newNavItem.validate().then(() => {
|
||||||
this.addNewNavItem();
|
this.addNewNavItem();
|
||||||
});
|
});
|
||||||
|
|
|
@ -34,10 +34,6 @@
|
||||||
cursor: move;
|
cursor: move;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gh-blognav-url .fake-placeholder {
|
|
||||||
color: #c1c1c1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gh-blognav-line {
|
.gh-blognav-line {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
@ -150,11 +150,6 @@ describe('Acceptance: Settings - Navigation', function () {
|
||||||
find('.gh-blognav-label:last .response').is(':visible'),
|
find('.gh-blognav-label:last .response').is(':visible'),
|
||||||
'blank label has validation error'
|
'blank label has validation error'
|
||||||
).to.be.true;
|
).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');
|
fillIn('.gh-blognav-label:last input', 'New');
|
||||||
|
@ -165,11 +160,6 @@ describe('Acceptance: Settings - Navigation', function () {
|
||||||
find('.gh-blognav-label:last .response').is(':visible'),
|
find('.gh-blognav-label:last .response').is(':visible'),
|
||||||
'label validation is visible after typing'
|
'label validation is visible after typing'
|
||||||
).to.be.false;
|
).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');
|
fillIn('.gh-blognav-url:last input', '/new');
|
||||||
|
|
|
@ -189,21 +189,6 @@ describeComponent(
|
||||||
expect($input.val()).to.equal(`${currentUrl} /test`);
|
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 () {
|
it('triggers "change" action on blur', function () {
|
||||||
let changeActionCallCount = 0;
|
let changeActionCallCount = 0;
|
||||||
this.on('updateUrl', () => {
|
this.on('updateUrl', () => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue