-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #5845, #5969 - when on mobile devices tag management UI will only display a list and when a tag is accessed the tag settings form will slide in from the right - tag settings form header has a 'back' button when on mobile to go back to tags list - switching from mobile to standard modes will auto load the first tag as per standard tags screen on desktop - if no tags are present then the blank-slate template will be shown when on mobile
- Loading branch information
1 parent
0c9befc
commit 983c6c8
Showing
14 changed files
with
214 additions
and
16 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
core/client/app/components/gh-tags-management-container.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import Ember from 'ember'; | ||
|
||
const {isBlank} = Ember; | ||
|
||
export default Ember.Component.extend({ | ||
classNames: ['view-container'], | ||
classNameBindings: ['isMobile'], | ||
|
||
mobileWidth: 600, | ||
tags: null, | ||
selectedTag: null, | ||
|
||
isMobile: false, | ||
isEmpty: Ember.computed.equal('tags.length', 0), | ||
|
||
resizeService: Ember.inject.service('resize-service'), | ||
|
||
_resizeListener: null, | ||
|
||
displaySettingsPane: Ember.computed('isEmpty', 'selectedTag', 'isMobile', function () { | ||
const isEmpty = this.get('isEmpty'), | ||
selectedTag = this.get('selectedTag'), | ||
isMobile = this.get('isMobile'); | ||
|
||
// always display settings pane for blank-slate on mobile | ||
if (isMobile && isEmpty) { | ||
return true; | ||
} | ||
|
||
// display list if no tag is selected on mobile | ||
if (isMobile && isBlank(selectedTag)) { | ||
return false; | ||
} | ||
|
||
// default to displaying settings pane | ||
return true; | ||
}), | ||
|
||
toggleMobile: function () { | ||
let width = Ember.$(window).width(); | ||
|
||
if (width < this.get('mobileWidth')) { | ||
this.set('isMobile', true); | ||
this.sendAction('enteredMobile'); | ||
} else { | ||
this.set('isMobile', false); | ||
this.sendAction('leftMobile'); | ||
} | ||
}, | ||
|
||
didInitAttrs: function () { | ||
this._resizeListener = Ember.run.bind(this, this.toggleMobile); | ||
this.get('resizeService').on('debouncedDidResize', this._resizeListener); | ||
this.toggleMobile(); | ||
}, | ||
|
||
willDestroyElement: function () { | ||
this.get('resizeService').off('debouncedDidResize', this._resizeListener); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 8 additions & 2 deletions
10
core/client/app/templates/components/gh-tag-settings-form.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
core/client/app/templates/components/gh-tags-management-container.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{yield this}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{{gh-tag-settings-form tag=tag setProperty=(action "setProperty") openModal="openModal"}} | ||
{{gh-tag-settings-form tag=tag setProperty=(action "setProperty") openModal="openModal" isMobile=isMobile}} |
43 changes: 43 additions & 0 deletions
43
core/client/tests/integration/components/gh-tags-management-container-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* jshint expr:true */ | ||
import { expect } from 'chai'; | ||
import { | ||
describeComponent, | ||
it | ||
} from 'ember-mocha'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
import Ember from 'ember'; | ||
|
||
const resizeStub = Ember.Service.extend(Ember.Evented, { | ||
|
||
}); | ||
|
||
describeComponent( | ||
'gh-tags-management-container', | ||
'Integration: Component: gh-tags-management-container', | ||
{ | ||
integration: true | ||
}, | ||
function () { | ||
beforeEach(function () { | ||
this.register('service:resize-service', resizeStub); | ||
this.inject.service('resize-service', {as: 'resize-service'}); | ||
}); | ||
|
||
it('renders', function () { | ||
this.set('mobileWidth', 600); | ||
this.set('tags', []); | ||
this.set('selectedTag', null); | ||
this.on('enteredMobile', function () { | ||
// noop | ||
}); | ||
this.on('leftMobile', function () { | ||
// noop | ||
}); | ||
|
||
this.render(hbs` | ||
{{#gh-tags-management-container mobileWidth=mobileWidth tags=tags selectedTag=selectedTag enteredMobile="enteredMobile" leftMobile="leftMobile"}}{{/gh-tags-management-container}} | ||
`); | ||
expect(this.$()).to.have.length(1); | ||
}); | ||
} | ||
); |